Archive for October, 2007

Windows XP PowerToys: Open Command Window Here

Monday, October 29th, 2007

I discussed previously how to add an entry to the Windows context menu that would allow you to open a Cygwin bash shell with the current working directory set to the directory you clicked on. Someone commented on that entry that they have a similar entry for the Windows command prompt. I do as well (although it sees very little use compared to the Cygwin entry) and for those who work in Windows this is something of which they should be aware.

The tools is creatively titled “Open Command Window Here” and is one of the PowerToys for Windows XP from Microsoft. There are a lot of neat little tools in the PowerToys which probably should have been part of Windows XP from the beginning (in particular Tweak UI). If you’re working in Windows check out the PowerToys as they can make your life a little simpler.

Idiomatic C/C++: Avoiding Assignment Vs. Equality Errors

Thursday, October 25th, 2007

This is a bit of idiomatic c/c++, that is to say that this isn’t part of any standard, it is just “the way things are done” in c/c++. Ever made an error in a conditional using the assignment operator (=) instead of the equality operator (==)? I know I have, but not so much anymore. The trick is that when you are comparing a variable to a constant to put the constant first. This way if you mess up you will get a compiler error stating that you can’t assign to a constant. This is much preferable to a potentially subtle bug that will no doubt bite you when a deadline is looming. So instead of:

int x;
if( x == 5)
    ; //Do something

do:

int x;
if( 5 == x)
    ;//Do something

Picking and Matching Colors the Easy Way

Thursday, October 25th, 2007

If you’re developing a game or creating a web site for your game (or even just painting a room) you will need to pick out a color scheme. If you are anything like me you are a bit of a color idiot when it comes to this activity. I have found a great took that takes all the guesswork out of picking colors and makes it easy enough even I can do it: Agave. Agave lets you pick a color and it will generate a color scheme of your choice based on that color. It can generate any of the following six types of color schemes:

Complements
Split Complements
Triads
Tetrads
Analogous
Monochromatic

For a brief description of just what each of those color schemes are hit up the Wikipedia entry for Color Wheel. Once I started using Agave to pick out my color schemes, people stopped complaining about my color choices every time I asked for feedback. One more tool to keep in the arsenal.

Cygwin: Bash Prompt Here

Wednesday, October 24th, 2007

As I’ve already discussed it is quite easy to get yourself a nice little shell called Cygwin on Windows. Once you start using Cygwin it can be quite addictive, I can’t work on Windows without it. The biggest problem is that to get to any of your data outside of the home directory under Cygwin requires navigating through the sometimes unintuitive directory structure under Windows. Typically what happens is you locate the folder with the stuff you want to work on using the Windows explorer and then work your way to it again using Cygwin. This is a somewhat less than efficient use of your time.

Luckily Cygwin comes equipped with a little utility to help you out with this problem. It is called chere and make sure you install it when you install Cygwin. chere installs an entry in the context menu when you right click on directories named “Bash Prompt Here.” Selecting it will open a Cygwin shell with the current working directory set to the directory you right clicked on. To install it simply run this from Cygwin:

chere -i

For more information on chere run this from Cygwin:

man chere

From Madness to Synergy

Wednesday, October 24th, 2007

If you’re like me you have multiple machines all running at the same time (check this out to see how you can use some of that aggregate computing power to speed up your compile times). The problem becomes how to use all of those machines effectively. Do you give each machine a mouse, keyboard, and monitor? It works but it slows you down, you’re constantly moving to get to the keyboard and mouse and to see the monitor for another machine. It also requires an enormous amount of desk space. Do you buy a kvm switch and share a single mouse, keyboard, and monitor between the machines? This is somewhat less than ideal. You can’t see what you’re doing on one machine while working on another. There is no real coordination between the machines either. When you factor in the prices for a DVI kvm it really isn’t much cheaper than giving each machine its own accessories. The solution I’ve found is software-based and it is called Synergy.

Synergy allows you to share a single keyboard and mouse among a number of different machines. Those machines don’t even have to be running the same operating system! I have three machines and monitors set up with one for Linux, Windows XP, and Mac OS X. I share one keyboard and mouse among the machines using Synergy. You simply tell it the arrangement of your monitors and it will transfer keyboard and mouse input to another machine seamlessly as you reach the edge of the screen. That in and of itself is fantastic but on top of that Synergy will sync screensavers and, more impressively, will sync clipboards between machines (and operating systems). You read that right, you can copy on one machine (say running Linux) and paste what you copied onto another machine (say running Mac OS X).

For those running Mac OS X or Linux I highly suggest QuickSynergy. It allows you to more easily set up Synergy. For the Windows folks there is no QuickSynergy for you but the official Synergy software is fairly easy to set up.