Monday, November 3, 2008

Timezone changes in Linux

I moved across timezones recently, and booted up my Gentoo machine. I modified /etc/conf.d/clock, but the "date" command kept giving back the time in my old timezone. Turns out you also have to change /etc/localtime .

As seen in the Gentoo manual

Monday, September 8, 2008

Lowering process priority on the command line

If there's a process that you want to start from the command line, or through a shortcut, but you want it to automatically have a higher or lower priority, use this syntax:
C:\WINDOWS\system32\cmd.exe /c start "DC++" /low "C:\path\to\program.exe"

This will ensure that the program always gives up CPU time to other processes.

Friday, August 8, 2008

Remote Desktop to a Virtual Machine

A little while ago I tried to Remote Desktop to a Windows XP Virtual Machine (hosted on a Gentoo Linux system) from work, and it wouldn't connect. I knew I could Remote Desktop from my WinXP workstation, so I found out that I could still get in by Remote Desktopping to my workstation, then using Remote Desktop on the workstation to get to the VM.

That's a terrible work-around though, so I looked around for a proper solution. One of my friends told me a possible fix, I tried it, and it worked. You have to write "1" to /proc/sys/net/ipv4/ip_forward. This makes it so that the host OS will accept traffic not intended for itself, and forward it to the VMware net interfaces.

Here is the /etc/init.d script I used to make this happen automatically:
start() {
ebegin "Starting ${SVCNAME}"
echo 1 >> /proc/sys/net/ipv4/ip_forward
eend $?

stop() {
ebegin "Stopping ${SVCNAME}"
eend $?

Haven't had an issue since.

Tuesday, July 22, 2008

Making directories

Twice in the past month I've had great frustration because of tools that would create a file given a non-existent filename, but would not create the directory structure necessary to hold the file, if it didn't exist.

First off, the Ogg Vorbis encoder provided by RareWares is capable of auto-creating directories if they're specified in the output path. However, the Lame encoder, also provided by RareWares, does not. The directory needs to be created manually first if it doesn't exist, before a file can be written there.

I had the same issue with Perl's open() procedure. It will create a file that doesn't exist, but the directory has to be there already.

I know it's good practice to check for these things, but it's still annoying, chasing down an error like that.

Wednesday, July 9, 2008


I was having issues with a progress bar that was set to Marquee style. It was moving at a pretty good rate, and setting the MarqueeAnimationSpeed value seemed to have no effect. Turns out that you need to specify the speed before you set the ProgressBar to Marquee. In my case, the working code looks like this:

encodeProgress->MarqueeAnimationSpeed = 35;
encodeProgress->Style = ProgressBarStyle::Marquee;

I imagine that's the exact problem that this person had. It's a shame Microsoft didn't figure out what the person had done.

Friday, June 13, 2008

Visual Studio - Icons

There are a few things involved in adding icons to a Visual Studio project. Where applicable, this guide will reference GIMPshop, but the procedure should be very similar in Photoshop or GIMP (I don't know for sure, as I haven't recently used either one).

First, make your icon in a larger resolution. 255x255 works well, since that's the largest size that the end result can be (Vista allows 255x255/256x256 icons if you have "large icons" enabled). After you have it as you want it, save it as a PNG, then scale it down to 3 different resolutions: 48x48, 32x32, and 16x16. All of these should be scaled down from the original 255x255, as that will provide the best-looking icons. After scaling, some manual pixel manipulation might be needed in order to produce the best-looking results, depending on the nature of the icon.

After you have all 4 image files, open up the 255x255 file, then "Open as Layer" the same file twice more. Then "Open as Layer" each of the other three files three times each. Save the whole thing as an Microsoft Windows Icon file (.ico). A window will come up with each of the layers in it, and next to each layer is a dropdown box. The box lets you select the color bitrate for each layer. For each image size, you want one layer to be 32-bit, one layer to be 8-bit, and one layer to be 4-bit. Reducing the bitrate may require additional touching-up as well.

You now have an icon file that can be imported into Visual Studio. There are two places where it should be imported into your project. The first is in the main window. In the window's Icon field, select the file you just made. Then do the same in the application's properties page (though VS may like it more if you import the icon as a Resource, then add it that way).

With this, Windows should know when to use the right filesize and bitrate for any given situation. These 12 images are all that's recommended by Microsoft for Vista compatibility, but you can put in more if you want to be prepared for situations where Windows would otherwise scale the icons for you.

Tuesday, June 3, 2008

ClickOnce - Publisher Name

Something I'd forgotten: the item that determines the placement of a ClickOnce application within the Start menu is in Options->Publisher Name. I'm not sure how to publish to subfolders with ClickOnce yet though.