Archive for December, 2007

Commuter, Rewarded

Monday, December 3rd, 2007

I had posted previously about an excellent commute database for the Atlanta metro community. As a fringe benefit, and to encourage logging, users have the chance to get small VISA gift cards at random. Either they are really good at fundraising or nobody else is logging their commute, because I got my second $25 gift card in the mail just a few days ago. I was randomly selected for the gift card reward; but my chances for selection were apparently increased because I was actually logging my commute fairly regularly (15 out of 31 days in October).

Here is the October summary of legs of my five-mile commute, broken down into mode of transportation:

Mode Count
Bicycle 4
Carpool 15
Drive Alone 10
Motorcycle 0
Telework 0
Transit 0
Vanpool 0
Walk 1

Better judgement would have me keep this quiet to increase my chances of winning again, but I actually think that the process of logging your commute style gets you to consider your alternatives more frequently — and that’s a good thing.

OptiFlag: Great Command Line Parser for Ruby

Sunday, December 2nd, 2007

I find myself writing a few simple Ruby scripts which need the flexibility of command line arguments. Having no more experience with the command line than ARGV[0], I thought the good old interweb could help me find a better way. Although I’m sure there are many command line parsing libraries and schemes out there for the Ruby community, I did not want to have to wade through loads of documentation and dozens of example scripts just to get a couple of flags in my program. Parsing is subtle, I know, and I don’t want to have to deal with all of the details on my own.

Luckily I came across OptiFlag, an extremely lightweight and unobtrusive command line parser written by (I guess) Daniel Eklund. All one needs to do is extend his OptiFlagSet module at the top of your script using a very simply DSL and voilá, your command line arguments are available within the script as ARGV.flags.my_option. By default, all flags are required, but that’s easily changed. Validation of the parameters is also possible using regular expressions.

The author does not claim that this parser will replace all others (I like modesty) but instead is meant to meet the needs of very simple use cases. In my short experience today, it does its job perfectly.