Putty alias

Here's a quick code post from my Powershell profile. I keep copying this around every time I set up a new system, so maybe it will be useful to others. And to me, since I can copy it off the web in the future rather than having to dig it up or recreate it.

Being an old-school UNIX guy, I get used to just typing ssh hostname to access my servers. So the Putty syntax of loading a profile annoys me. To that end, I wrote a few little functions to add to my Powershell $profile to address this. They just let me load a session by typing the familiar commands and don't require me to change syntax when using a profile versus connecting directly to a hostname.


function _puttyHasProfile {
   $profile_name = $args[0].ToLower()
   $profiles = Get-ChildItem HKCU:\Software\SimonTatham\PuTTY\Sessions\
   foreach ($p in $profiles) {
      $lowerName = [System.IO.Path]::GetFileName($p.Name).ToLower()
      # Need the UrlEncode to account for profile names with spaces.
      if ($lowerName -eq [System.Web.HttpUtility]::UrlEncode($profile_name)) {
         return 1
      }
   }
   return 0
}

function ssh {
   $profile_name = $args[0]
   if (_puttyHasProfile($profile_name)) {
      putty -load $profile_name
   } else {
      putty $args
   }
}

function sftp {
   $profile_name = $args[0]
   if (_puttyHasProfile($profile_name)) {
      psftp -load $profile_name
   } else {
      psftp $args
   }
}

Early birthday

I got an early birthday present today. My birthday isn't until Monday, but my sister-in-law was over tonight, so she gave me my present.

Remember how I mentioned last week that I have a bit of a weakness for "vintage" games? Well, she got me a Logitech Extreme 3D Pro joystick. You rock, Theresa!

And what did I want such a joystick for? You guessed it - to play Wing Commander! I absolutely love the Wing Commander series, and have since I was in high school. I think I owned most, if not all, of the games. In fact, I think I still have copies of all of them, though the ones that were on floppies have long since died (I still have the files on my hard drive, though). I enjoyed pretty much every game in the series, though the original and the Privateer spin-off were probably my favorites.

So here I am, with a brand-new 12-button joystick, playing a 20-year-old video game in a little emulated DOS window. It's amazing the entertainment/time-wasting possibilities technology opens to us!

Post-vacation unhappiness

On the heels of the things that make me happy, here's something that makes me not so happy: when half your team quits while you're on vacation!

I spent the last week of July in Cape Cod, staying in a cabin by the beach. It was very nice. We relaxed a bit, saw some sites, did some shopping (they have a kick-ass used book store on Main St. in Hyannis), and generally enjoyed it a great deal. It was nice to unplug for a while - I only used my laptop on twice all week, both times for less than an hour.

And what do I discover when I get back? Our engineering team is deserting me. We only had three software engineers (including me), one Flash designer, and one QA person. Turns out both of the other engineers gave their notice while I was gone. So now it's just me. Sigh....

I don't blame them - you've got to look out for your own career - but it leaves us in a really bad place. Plus I'll miss having them around the office to talk to. But on the up side, it won't be hard to stay in touch - they're both going to the same company, which is located in the same office park we're in now.

Making my games work

Despite not considering myself a "gamer" (with the exception of Battle for Wesnoth), I do have a bit of a weakness for "vintage" games, by which I mean the ones I played when I was in high-school and college. While I don't have much time for games anymore, what with full-time employment and home ownership, I still like to come back to those old every now and then.

Well, when I tried to fire up my PlayStation emulator, ePSXe, to mess around with one of my old copy of Final Fantasy Tactics, I ran into a problem - I no longer have GTK+ 1.2 installed! Apparently it was removed when I upgraded to Ubuntu 10.04 (or possibly even 9.10, I'm not sure). However, according to this LaunchPad bug, this particular issue is by design and will not be fixed. That kind of stinks, because I have several old closed-source Linux-based games that depend in some way on GTK+ 1.2 (often for the Loki installer).

This sort of thing is a little bit of a sore spot for me, and has been for some time. On the one hand, I can understand te Ubuntu team's position: GTK+ 1.2 is really old and has not been supported for some time. You really shouldn't be using it anyway, so there's not much reason for them to expend any effort on it.

On the other hand, how much effort is it to maintain a package that's no longer being updated? Why not at least make it available for those who need it? This is the sort of user-hostile thinking that's always bothered me about the open-source community. There's hardly any compatibility between anything. Binary compatibility between library version is sketchy, as is package compatibility between distributions. Even source compatibility breaks every few years as build tools and libraries evolve. Ever try to compile a 10-year-old program with a non-trivial build process? Good luck.

And that seems to be the attitude - "Good luck! You're on your own." It's open-source, so you can always go out and fix it yourself, if you're a programmer, or hire someone to do it for you otherwise. And while it's absolutely great that you can do that, should that really be an excuse for not giving users what they want or need? Should the community have to do it themselves when it's something that would be relatively easy for the project maintainers to set up?

Not that I can blame them. As frustrating as decisions like this can be, you can't look a gift horse in the mouth. The Ubuntu team is providing a high-quality product at no cost and with no strings attached. They don't owe me a thing. Which, I suppose, is why it's so great that members of the community can fix things themselves. The circle is complete!

But anyhow, that's enough venting. That LaunchPad thread had several posts describing how to install GTK+ 1.2 on 10.04. I chose to use a PPA repository.

sudo apt-add-repository ppa:adamkoczur/gtk1.2
sudo apt-get update
sudo apt-get install gtk+1.2

Ta-da! I'm now back at the point I was at a year or so ago when all of my old games actually worked.

Things that make me happy

Since I haven't posted anything in a really long time, with the exception of the Press Your Luck post of a couple weeks ago, I thought I'd do a little list to get back into the swing of things. So this is just a list of thing technical/computery that have made me happy, to some extent, over the course of this year.

  1. Windows 7. I've preferred Linux for a long time, but I've got to say, Win7 is awfully nice. I fact, it's so good I'm actually thinking of dumping Linux on my main desktop at my next upgrade. And for reference, I haven't had Windows on my home desktop since 2002 - and I was dual-booting then.
  2. Subversion. Not that Subversion is that great in and of itself (although it is a perfectly good revision control system), but this year my team finally migrated from CVS to Subversion, and it sucks so much less! Yes, you read that right - my company was actually using CVS for new projects until the beginning of 2010. It's nice to finally step forward into 2005!
  3. The new versions of Opera. I've been an Opera user for a very long time, and version 10.50+ has gotten really nice. The updated UI is pretty nifty, Opera Link is a very handy feature I've always wanted, and I actually find Opera Unite really cool. I use it to access my home PC fairly regularly. I don't care how fast Chrome is, Opera's still better in my book.
  4. Not coding in JavaScript and HTML. Our new product at work is implemented in Adobe's FLEX. Yeah, FLEX is based on Flash, which sucks, but it's actually a pretty nice framework. Way more pleasant to work with than JavaScript and HTML. Even if you include jQuery, which takes most of the suck out of JavaScript, FLEX is still nicer. Now if only Flash didn't suck so much.... Too bad there's no viable alternative. (Silverlight doesn't have the market penetration and nobody with half a brain thinks HTML 5 is comparable. And yes, that implies Steve Jobs doesn't have half a brain.)
  5. Not using Web TimeSheet. Last year, our company was using Web TimeSheet for our time tracking. If you've never used it, suffice it to say it sucks beyond all rational belief. Seriously - I can't describe how bad it was. It took damn near 30 seconds to load the time entry form. And that wasn't even waiting for an HTTP response - it was actively loading a bajillion things during that time. Now, we're doing our time/task tracking in Jira instead. Sadly, Jira still sucks, but not nearly as bad as Web TimeSheet.
  6. I have a window. For the first time ever, I have a desk by the window. The president of our company left for another job a couple weeks ago, and since we're not replacing him, the CEO gave our four-man dev team permission to move into his office. It's just big enough for all four of us (only slightly smaller than big-ass the cube we all shared), and two of the four walls are all window. And I got the corner where the two windows meet. This is a far cry from when I was in public service and had the "cube" that used to be a printer nook and was exactly large enough to hold my desk - and nothing else.
  7. Whipping out SQL For Smarties. A couple months ago I actually had an excuse at work to whip out my copy of Joe Celko's SQL For Smarties and apply one of the chapters. I needed to store a nested folder structure in the database, so I turned to the trees and hierarchies section, did a little reading, and settled on the path enumeration method. One of my colleagues had suggested adjacency lists, which Celko calls "the most commonly used and worst possible" model for trees. I love that book - it always makes me happy when I have an excuse to use something from it.

Seven seems like a good number. Time to call it a night. I get up early enough to go to the gym and still make it to the morning scrum. Perhaps I can continue the list later.

No Whammy

After six months of silence, here's a random "I'm writing this so I don't have to keep Googling it" post.

The "no whammy" game show was called "Press Your Luck". According to Wikipedia, it was hosted by Peter Tomarken and featured announcer Rod Roddy, in case anybody cares that much.

That just jumped into my head again as I was merging my private dev branch in Subversion back to trunk. For some reason - probably a version mismatch between clients and the server, which is only on 1.4 - we've been getting a lot of tree conflicts on merge. So this morning I found myself watching the merge progress saying, "No conflict, no conflict, no conflict, STOP!"

Annoying mtools inconsistency

I hate upgrading Ubuntu, because every time I upgrade, something breaks. Sometimes it's small things, sometimes not so small. For instance, the last time I tried upgrading to a newer version of KDE 4, I ended up irreparably borking the installation and just switching to GNOME. (And by "irreparably", I mean messing it up bad enough that I had neither the time nor inclination to repair it.) Interestingly, the change was much less disruptive than I thought. Apparently I just don't care that much about desktop integration anymore. Chalk it up to switching back and forth between platforms all the time.

Anyway, this time the breakage was in the permission fixing script for my Sansa e280 MP3 player. The short version is that when the script ran mattrib -h to clear the "hidden" attrbiute on a directory, it just printed out the mattrib usage message, despite the fact that there was no error in the command syntax. After all, the same script had been working flawlessly for over a year in Ubuntu 8.10 and 9.04.

Well, after an hour or two of messing around and fruitless Googling, I finally stumbled upon the answer. It turns out that in the build of mtools 4.0.10 that ships with Ubuntu 9.10, the option to remove the hidden attribute has changed from -h to -H. Of course, the usage message still says -h and the man page still says -h, but it's -H that actually works. So, basically, I lost an hour of my life because somebody, whether in upstream of the package maintainer in universe, screwed up and forgot to update the documentation.

Anyway, I did my duty and filed a bug report. We'll see if anything comes of it. I'm sure it's not a high priority, though - if the Google results are any indication, I'm about the only person in the world who uses mattrib on a regular basis anymore.

Sansa repair

I finally got around to fixing my MP3 player this weekend. I have a Sandisk Sansa e280 running the Rockbox open-source firmware replacement. Despite being a little light on capacity (8GB internal flash plus 2GB for the non-HC microSD slot), I like it a lot. However, recently the headphone jack had gotten very loose. If I jiggled the jack a little, the sound would cut in and out. After a while, it reached the point where I had to pull the cord at just the right angle to maintain enough contact to listen to anything.

Fortunately, this turned out to be relatively easy to fix. I found some instructions on the abi forum, along with links to pictures. It took a little time, but I got the headphone jack working like new again.

The main problem I had was prying up the plastic headphone jack. The plastic part is only held to the board by the metal contacts, which are soldered on. So you can just lift it off to get to the contacts themselves. However, I didn't want to use too much force to pry up the plastic, lest I break one of the contacts or crack the board. After fiddling around with it for a while, I decided to try the opposite route, taking advantage of the fact that you can see the top of the contact poking through the plastic. So, rather than pulling on the plastic, I held onto the plastic part and held the board up off the table. Then, I pushed down on the top of the contacts with a pin and they slid out without too much effort. So I bent the contacts in a bit and put small pieces of a rubber band behind the to try to prevent them from bending in the future. Then, to get the plastic back over them, I gently pushed on the top of the contacts with a straight screwdriver to guide them back into the channels in the jack.

Worked like a charm! I listened to my Sansa all day today and didn't have the sound cut out once. I was starting to fear I'd have to get a new MP3 player. And while the Sansa View and Sansa Fuze look nice enough, and have high-capacity microSD slots, Rockbox isn't stable on them yet. And frankly, Sandisk's native firmware isn't that great. If nothing else, I just like that Rockbox lets you use both database and file system navigation. Not to mention those handy plugins and the extra media formats.

The @depends annotation in PHPUnit 3.4

OK, I'm not crazy! At least, not for the reason I thought.

I was playing with adding some dependencies to my Selenium PHPUnit tests. See, PHPUnit 3.4 has this handy little test dependency feature, the @depends annotation. It's basically a PHPDoc comment that includes a test name. You add that to a test and, if PHPUnit hasn't run the dependency yet, it skips the current test.

Well, I'm working on Windows. And every time I added an @depends to a test, PHPUnit would skip it. Even if the dependency had run! Even on the example from the documentation! I thought I was losing my mind.

However, it turns out that it's a known bug in PHPUnit. Basically just a line ending issue. The bug ticket has a 2 character patch that fixes it, or you can just save your files with UNIX line endings. Go figure.

Update: Wow, talk about weird timing. It turns out this issue was fixed in PHPUnit 3.4.1, which was released the day after I posted this.

A little Selenium and PHPUnit oddity

Here's a weird little "feature" I came across the other day. It seems that Selenium discriminates between spacing in source and rendered HTML. I suppose this shouldn't be that surprising, but I just hadn't thought to account for it.

Here's what happened: I was writing a Selenium test case using PHPUnit's Selenium extension and I kept getting a failure on a simple assertTextPresent() call. I checked the page manually, and the text was definitely there. I selected the text and right-clicked to try the assertion in Selenium IDE, and it worked there. Then I tried copying the expected string out of my PHP test case and checking that in the IDE, and that's where it failed.

The only difference: one extra space in the PHP string. The real kicker is that that space is present in the page source. But when I stopped to think about it, it make perfect sense. Selenium interacts with the page through the DOM, and multiple spaces get rendered as one in HTML. The source is irrelevant - it's the rendered code that counts. I'll have to remember that for next time.