Refresh Icon Cache In Windows 7

This keeps me from having to reboot:

C:\Windows\system32\ie4uinit.exe -ClearIconCache

Posted in Snippets | Leave a comment

Hash File Using POCO

This is the first time I have had to create MD5 hashes for files in C++. I did find a library called POCO that has some very handy classes for doing this. I didn’t want to copy and paste code from work, so I created this simple example for hashing a single file and outputting the MD5 hash in a hex encoded string.

The hashing uses a chunk size of 1 MiB changes so the whole file is not loaded at once.

I will soon create another post on how to do this in Qt5 and post it then, updating this post with the link.

Check out the open source POCO C++ libraries at pocoproject.org/. There are downloads for Windows. For Linux, you may be able to get packages from the main repositories for your distro.

[code language=”cpp”]

#include <iostream>
#include <fstream>
#include <Poco/DigestStream.h>
#include <Poco/MD5Engine.h>

int main(int argc, char** argv)
{
Poco::MD5Engine md5;

std::ifstream ifHash(“../DSC_0002.JPG”, std::ios::binary);
if (ifHash.is_open())
{
Poco::DigestInputStream isMd5(md5, ifHash);
size_t bufSize = 0x100000;
char* buf = new char[bufSize];

isMd5.read(buf, bufSize);
while ( (isMd5.rdstate() && std::ifstream::failbit) == 0 )
{
isMd5.read(buf, bufSize);
}

if ( (isMd5.rdstate() && std::ifstream::eofbit) != 0)
{
std::string digest;
digest = Poco::DigestEngine::digestToHex(md5.digest());
std::cout << digest.c_str() << std::endl;
}

delete [] buf;
}
}
[/code]

Posted in C++, Cryptography | Tagged | Leave a comment

Keep Your Gnome Desktop Awake

These little bash snippets tell you how long in seconds before your screen locks and how to
keep your screen from going to sleep. This is for Gnome 3 in Linux.

To find the time in seconds before your screen goes to sleep:

[me@mybox ~]$ gsettings get org.gnome.desktop.session idle-delay
uint32 300

Set this setting to 0 to keep your screen from going to sleep:

[me@mybox ~]$ gsettings set org.gnome.desktop.session idle-delay 0

NOTE: Don’t set the idle-delay to 0 and leave the room for too long, because anybody has access to your logged in session.

Posted in Uncategorized | Leave a comment

Jenkins Snippets

Wipe out workspaces for all projects:
Thanks to Stefan Bäumler at https://wiki.jenkins-ci.org/display/JENKINS/Wipe+out+workspaces+of+all+jobs, I made a copy right here.
[code language=”groovy”]
import hudson.model.*
// For each project
for(item in Hudson.instance.items) {
// check that job is not building
if(!item.isBuilding()) {
println(“Wiping out workspace of job “+item.name)
item.doDoWipeOutWorkspace()
}
else {
println(“Skipping job “+item.name+”, currently building”)
}
}
[/code]

Delete all builds for all projects:
We tweak the script above to delete all builds.

[code language=”groovy”]
import hudson.model.*
// For each project
for(item in Hudson.instance.items) {
// check that job is not building
if(!item.isBuilding()) {
println(“Wiping out builds of job “+item.name)
item.builds.each { it.delete() }
}
else {
println(“Skipping job “+item.name+”, currently building”)
}
}
[/code]

Posted in Jenkins, Snippets | Leave a comment

Jira Snippets

Let’s face it, when there are cool new tools to lean such as RoR and ASP .NET MVC 4, Grails, why throw away time you could spending learning these to becoming experts at Jira? We just want the answers so we can do what we need here, keep our project managers happy, and move on.

Here are some snippets for finding issues. After all, managing your issues is most important.

Find all issues created by you:

reporter = currentUser()

Find all non closed issues assigned to you and for a particular project:

(status != Closed ) AND assignee = currentUser() AND component = YourProjectName

Posted in Uncategorized | Leave a comment

A Tiny Linux Virtual Machine

More or less, this is a note to myself, but for anyone stopping by, this is definitely worth looking at:

http://mikelev.in/2011/08/virtual-machine-runs-anywhere/

Looks like a decent blog also.

Posted in Uncategorized | Leave a comment

Open Source Collection Libraries For .NET

In the Linked In .NET Developers group, someone posted a question asking about a good open source tree structure in C#. I suppose if you use a library it does shouldn’t matter what .NET language you use. I got to thinking about how little I new of various collection type libraries for .NET. I am think along the lines of stuff like Boost and STL for C++. Well, maybe not that big. Here is a couple that I got from the discussion.

C5 Generic Collection Library
MIT-style open license

data-structures-csharp
License Unknown…

Posted in Uncategorized | Leave a comment

Guid To Windows Clipboard Using Cygwin

Guid Generation
This will give you a guid to your Windows clipboard using Cygwin.

uuidgen | awk '{print "{" toupper($0) "}" }' | putclip

If you don’t like the newline that gets added, you can do this:

uuidgen | awk '{print "{" toupper($0) "}" }' | tr -d '\n' | putclip

Now, for Bash on Linux, maybe you can substitute xclip for putclip to get it into your X Windows clipboard. There may be some additional arguments for that also.

Change To Directory in Clipboard
This handy alias to stuff in your ~/.bashrc file allows you to change to directory in Windows clipboard. Copy path using ^C in Windows Explorer and then issue this command to switch to it at the Cygwin bash prompt.

alias cdw='cd "$(cygpath "$(getclip)")"'

Posted in Bash, Cygwin, Snippets | Tagged , | Leave a comment

Cannot Open MS Office Application From SkyDrive

Sometimes when I would open my Excel spreadsheet up on SkyDrive, I’d get a message saying that the document was open by another user and that I could only open it read-only, save as another copy, or cancel, or whatever, even when I did not have the document open at all. This would be really annoying. Sometimes I would reboot my box and the problem would be fixed. But now, try this:

1) From Task Manager, find this process: msosync.exe.
2) Right click and select End Task
3) Problem solved 🙂 – well hopefully, worked for me last time.

Posted in Uncategorized | 1 Comment

How To Install Subversion 1.7 on CentOS 6.3

I have done this and forgotten, done this and forgotten, too many times.

1) Import the Dag Wieers key:
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

2) Install the rpmforge repo:
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

3) Install Subversion:
yum install --enablerepo=rpmforge,rpmforge-extras subversion

This just gets you the Subversion 1.7 client and svnserve server.

Posted in Uncategorized | 3 Comments