Ruby One-Liner

I know it’s not good engineering practice, but I do love code golfing and writing one-liners in Ruby. This turns a tab-delimited flat file into an imperfectly compliant CSV file:

File.open($*[0]) { |f| puts f.readline.strip.split(”\t”).inject([]) { |newfields, field| newfields << "\"#{field}\"" }.join(',') until f.eof? }

It works well as long as there are no commas in your fields.

Thanks Again, Merlin

This is one of the reasons I keep reading Merlin Mann:

Except inasmuch as it can help move aside barriers to finishing the projects that you claim matter to you, “productivity” is often a sprawling ghetto of well-marketed nonsense for people who really just need a ritalin and a hug.

New Feature on GuitarCardio.com

No, it’s not an application feature - it’s new content. I’ve posted my first guitar gear review! And I’ve already got a second item lined up.

Of course, in my rare spare minute, I’m still working on added features for GuitarCardio.com - I think mode-based drills will be next.

Fix for sad sed

I love that Mac OS X is really BSD under the hood, but sometimes it causes unexpected pain. More than once I’ve tripped over the differences in date between Linux and Mac OS X, and over this weekend I’ve had trauma with sed.

Specifically, if I have a single character I want to replace in a file - like replacing an out-of-band delimiter in a flat file with a TAB character - I’d normally say sed ’s/\d197/\d009/g’ < foo > bar. Sadly, this doesn’t work with Mac OS X’s sed.

Ruby to the rescue, in the form of my own sadsed.rb:

#!/usr/bin/env ruby

f = File.open $*[0]

until f.eof?
  puts f.readline.strip.gsub(/\xc7/, "\t")
end

And then just ./sadsed.rb foo > bar and away you go.

And for the record: I’m dealing with some big files, and Ruby’s Regexp is pretty snappy.

CSS Floats and Quantum Mechanics

Yesterday, I spent more time dealing with the getting floated page elements to look right than I care to admit. I am not kidding when I say that I found quantum mechanics more intuitive than I find CSS floats now.

Of course, I put more effort into studying quantum mechanics. And maybe there’s some similarity here - once you learn a few hairy rules and what they really mean, the weird results make sense.

That was more gripe-y than educational. I’ll post something meatier next time.

New GuitarCardio Features

I’ve deployed a shiny new user profile feature at GuitarCardio.com, visible details of which are described in the relevant blog entry.

As for the under-the-hood stuff, the Restful Authentication Plugin made it embarrassingly easy.

Late, late. Must sleep now.

Vote Kristin!

I have plenty to report, but not a lot of time to do it just now. What’s really important here is that you go check out Kristin’s latest blog entry. My darling wife has entered an online karaoke contest being run by a well-known composer and lyricist, and could use your vote.

I’ll update about coding and websites and all that later.

Vote Kristin!

The Second Wave

Lifehacker is one of my favorite blogs. I hadn’t thought to submit a link to GuitarCardio.com to them, mainly because GC seemed to me to have a niche appeal, rather than being the sort of general-interest productivity tool that LH usually features.

So imagine my surprise when I saw GuitarCardio turn up on Lifehacker’s RSS feed!

Thanks to the Lifehacker crew for thinking enough of the site to post about it.

And I’ll tell you what, I can’t WAIT to log into Google Analytics tomorrow.

Lessons from an Unintentional Launch

As I mentioned previously in this space, I’ve written a web app called GuitarCardio.com. Of course, posting about it here informs nobody but a few family and friends, and then only a few days later when they get around to checking the site. Likewise with my Twitter feed (which as an even more circumscribed set of people who care), Facebook, etc.

I also post to a few guitar-related blogs and fora, and I got a few hits from that. It’s not lots of traffic, but the people who came were at least interested in the topic.

The other night night, on a lark, I put GuitarCardio on StumbleUpon, which is a neat little tool for finding new stuff on the web. Within hours, I had over 5,000 new visitors. In the past 48 hours, it became over 12,000 new visitors, many of whom were staying at the site. GC peaked at #2 on the del.icio.us popular links, and made the front page of popurls. People actually gave pleasant, useful comments on the blog, and I got linked on Twitter and on multiple blogs.

I’m not so much bragging about any of this, but more expressing how agog I am at the whole notion. It had not occurred to me that any of that stuff might happen.

The even better news is that the site stayed hyper-responsive (within the limits of a good shared host) through the whole traffic wave. A few 500 errors or “sorry, my database is bogged” messages, and you’ve dug a pit of negative goodwill from which your site might never emerge.

So, lessons learned:

  • The site stayed responsive in part because currently there is no database component to the site (though this will change soon). Response codes for every one of the tens of thousands of requests over the past 48 hours have been either 200 or 302 - no 500’s, which is the bane of Rails apps on shared hosts.
  • I host no graphics on the page, which I think also helped performance. It is possible to make an eye-catching design with just HTML and CSS.
  • If you’re going to use a service like StumbleUpon, be ready. If my site weren’t able to handle the traffic, I wouldn’t have been able to do anything about it from work yesterday morning. I kind of lucked out there, due to my minimalist design decisions.
  • Services like StumbleUpon can work for you, if you’ve made something people actually want.

All the activity was really a surprise to me, as this is the first time I’ve put something (of my own, anyway) on the web that anyone I don’t know was actually interested in. (This is no great surprise - my interests and priorities intersect with those of the general population only rarely.) So thanks to all those who did care enough to say something nice about GuitarCardio - who voted it up on StumbleUpon, and who tweeted, blogged, and bookmarked it.

Now, I need to digest some of the great feedback I’ve gotten on the GuitarCardio blog, pore over the Google Analytics data, see how my ads performed, &c.

And then, I’ll be making the site even better. The GC blog will cover the features I add and when I’ll be unveiling them, and I’ll be posting about technical lessons learned here.

w00t!

How Many Pushups Was That?

Here’s something for your pecs: hundredpushups.com. This site offers a six-week program that claims (plausibly, I’d say) to be able to get you from your current fitness level to the ability to do 100 pushups in six weeks. I started a little over a week ago, and the workouts seem well-calibrated, because I sometimes struggle to get to the end, but I can make it. At the beginning, I was able to do 16 pushups at a go. There’s another test at the end of this week, and I’ll be interested to see how much progress I’ve made.

Anyway, if you’re looking for something to shake up your exercise routine, give it a shot.