Set PuTTY defaults, permanently

PuTTY or one of its forks is a standard tool for administering Unix and Linux machines from Windows. It provides SSH connectivity for command line access, as well as keypair management for compatible programs like WinSCP.

Unfortunately, PuTTY has some terrible defaults. For example, it limits itself to 200 lines of scrollback by default, which guarantees that you’ll lose some history in most SSH sessions.

There’s a way to fix this and other defaults.

First, load the “Default Settings” saved session:1-load-default Then, configure the defaults as you like. For example, I’m increasing my lines of scrollback from 200 to 20,000: 2-configure

Then, save the new default settings:

3-save-default

PuTTY will now have a sensible defaults whenever you’re connecting to a random server.

Fix VPN hostname resolution by flushing your DNS cache

Sometimes when my VPN connection to work goes down, certain applications that rely on intranet servers (e.g. Lotus Notes, Lotus Sametime) become unable to reconnect to their servers even after I reconnect to VPN. This is due to the operating system’s DNS lookup cache reusing the failed hostname lookup from when VPN was down rather than doing a fresh hostname lookup now that there is a fresh VPN connection.

On Windows, you can fix the issue by opening up the Command Prompt as Administrator and running the following command:

TurboTax 2012 crashes on startup

I had an exciting tax year (lots of RRSPs, bought a house), so I picked up a copy of TurboTax 2012 to help file my Canada income taxes.

Unfortunately, TurboTax crashed on startup and running it as Administrator did not help. It turns out there is a known workaround involving copying some DLLs around.

ODBC and 32-bit Excel on Windows 7 x64

I do some reporting in Excel. The reporting involves loading data via ODBC from a DB2 database. Excel is pretty zippy with its pivot tables once the data is loaded, but setting up the initial connection can be tricky.

Windows 7 is the first Microsoft operating system where the expectation is that the consumers would run the 64-bit version. However, Office hasn’t caught up yet, and 32-bit is the default for Office 2010.

32-bit Excel can’t see 64-bit ODBC data sources.

Windows comes with entirely separate 64-bit and 32-bit ODBC control panels. The 64-bit ODBC control panel is the default, and the 32-bit ODBC control panel is not even listed in the in the main control panel. You need to invoke it via Start > Run.

To invoke the 32-bit ODBC control panel, use the following command:

Once you have the control panel open, it should be straightforward to define a new System data source to your database.

Setting up a fresh Windows system

I’m setting up a new primary system and I thought I’d jot down some notes.

Ninite is probably the quickest way to install all the necessary software (Chrome, 7-zip, Dropbox, iTunes, Picasa, etc). You click the checkboxes and it rolls you a custom, hands-off installer. They upsell to an auto-update service, but there are free alternatives like FileHippo Update Checker.

Speaking of Dropbox, it proved a lifesaver. If you aren’t familiar with it, it’s a service that automatically syncs (and backups) a folder between all your machines. My last hard drive failed, but because all my personal files are on Dropbox I didn’t lose any of them. They have a free 2GB account available, and if you join they’ll toss some extra free space my way as well.

I also set up a few Firefox extensions. With extensions, the goal is always is to have as few as possible, as there is a history of extensions slowing down Firefox performance. Here are the ones I chose:

HTTPS Everywhere is of course a great security boon. LastPass is a secure cross-browser way to manage the hundreds of passwords we all have. Xmarks is a bookmarks synchronizer which I prefer over Firefox Sync because it’s cross-browser.

I have a few goals with the new system:

  • Keep the desktop empty of files
  • Keep all personal files in a single location (e.g. \Dropbox)
  • Keep all work files in a single location (e.g. \Projects)

The last one might be the trickiest, as all the different Eclipse-based IDEs I’ll need to install will all try to grab a workplace for themselves.

 

How to diff Word documents

It’s fairly straightforward to diff or compare different revisions of an Office document on Windows. The approach below applies to Word, Excel, and PowerPoint files, as well as to ones created by Lotus Symphony, OpenOffice.org, or LibreOffice.

  1. Download and install WinMerge. This is a free, open source utility.
  2. Download the xdocdiff plugin. Unzip it somewhere.
  3. Copy xdoc2txt.exe and zlib.dll to C:\Program Files\WinMerge
  4. Copy amb_xdocdiffPlugin.dll to C:\Program Files\WinMerge\MergePlugins
  5. Start WinMerge.
  6. Go to Plugins > List and check [x] Enable plugins.
  7. Go to Plugins and set it to [x] Automatic unpacking
  8. Close or restart WinMerge

You should now be able to select any two documents that you want to compare, right-click on them, and choose WinMerge to get a meaningful comparison of the textual differences between them.

If you are seeing line noise in the comparison, you need to make sure you enable the settings mentioned in steps 6 and 7 above.

Triggers in DB2 Express-C 9.7.4

My team at IBM recently released DB2 Express-C 9.7.4, the latest and greatest version of our free database.

Raul wrote up a detailed article with the technical nitty-gritty of what’s new. There’s a bunch of different improvements, but one thing that’s caught my eye are the enhancements to triggers.

A trigger is something defined to fire automatically when you insert, update, or delete a row in a table. Starting with 9.7.4, you can basically inline a whole stored procedure in the trigger definition. This is nice because it lets you keep the code for all the different actions on a table together.

Let me quote Raul’s example:

Ignore that last part. All salary increases should be > 10%.

Batch file look-up table for month names

The look up table goes in months.bat:

Given a month number, you can then look up the month abbreviation as follows:

  • ‘months.bat’ executes that file and pipes the output to the FOR /F command
  • delims== sets the delimiter to the equals sign
  • tokens=1,2 means you want the first two tokens (e.g. 1 and aug for 1=aug=August)
  • %%i means the first token will go in %%i, second in %%j, etc

Alternate solutions are welcome. I’m still a bit unclear on the difference between %%i, %i, and %i%.

Useful links:

CCleaner utility for Windows

CCleaner is one of my favourite utilities for Windows. It does several things very well.

CCleaner ScreenshotOne of them is removing the temporary files that various applications leave lying around. For example, the Windows temporary files directory gets filled up with various installers that have a tendency to never be removed as well as fragments of files left open during crashes. For another, Windows retains the option to let you uninstall every patch Microsoft issues. This may be useful in a mission-critical server situation, but on a regular machine it just wastes space.

I just had to clean up a very space-constrained virtual machine for work. CCleaner instantly freed up 1.4GB of space simply by removing crud left around by installers and other applications.

CCleaner also does a beautiful job of correcting Registry inconsistencies, finding dead Start Menu shortcuts, and various miscellaneous tasks like free space management and cleaning up the Add/Remove programs list.

Dynamic playlists in MusikCube

On Windows, my music player of choice is musikCube. It’s fast, clean, elegant, and powerful. Oh, and it has an embedded SQL engine underlying its song library.

musikCube in action

It has conventional playlists, but it also has dynamic playlists based on queries of the underlying SQL database. For example, this query gives the Top 10 Most Played songs:

And this gives 50 songs with a rating of 4 stars or better in random order:

Once created, a dynamic playlist is only a mouseclick away.

The documentation is incomplete, but the database schema is easy to look up by saving a copy of the library and opening it up with a tool like sqliteman:

musikCube database schema

I wanted to subdivide my music into playlists, and then find any song not on a custom playlist. A query similar to this did the trick:

It finds every song not added to the Gnarly, Radical, or Tubular static playlist. Using this, I finally got my music library sorted and organized.