rake db:version

Tuesday, September 26

I often find myself needing to know what migration version my database is at. There is the ./script/about script, which tells me the version number (and a host of other things), but I don’t want to have to look through all that. All I want is the migration number I’m currently at.

Here is a simple rake task you can plop in your lib/tasks directory that will print the current version.


# lib/tasks/db_migration_version.rake
namespace :db do
  desc 'Print the current database migration version number'
  task :version => :environment do
    puts ActiveRecord::Migrator.current_version
  end
end

Example usage:

$ rake db:version
29

Fun!

London power tour

Sunday, September 17

For the past two days Hampton and I have been doing a power tour of London. Hampton is a self-described information adict, and his wealth of trivial knowledge about the United Kingdom makes him a great tour guide.

Yesterday we did the Royal tour, visiting Buckingham Palace, Westminster Abbey, the houses of Parliament, and Big Ben. After a long day of walking we bought some beer and went back to the hotel room to get drunk and watch TV.

We continued our tour today, taking the tube to the Tower of London, a fortress along the River Thames that served as a prison and place of execution, among other things. Even Sir Isaac Newton lived there once upon a time.

Next we went to the British Museum, a huge and ornate structure that’s home to millions of artifacts from all over the world, all for the purpose of illustrating the story of human culture from its very beginning.

Now our feet are killing us and I’m starting to walk with a slight limp.

HAML: RoR's new templating engine

Saturday, September 16

I’m typing this from an internet cafe in London right now. One pound for one hour’s worth of internet access is a great deal.

So, I was holding off on writing about HAML until it was officially unveiled at RailsConf Europe where it’s creator and I were graciously flown by our employer, Unspace Interactive. Now that the conference is over, it’s time to spread the word.

HAML is a new templating engine for Rails that enables you to write truly beautiful templates. Created by one of my esteemed collegues, Hampton Catlin, I’m proud to say that I played a minor role in its evolution: I refactored the codebase, added some tests, and wrote the rdoc. The real credit goes to Hampton, of course. I’m merely a supplicant and a votary. But I’m the only HAML commiter besides Hampton, which makes me better than you.

HAML in action

Let’s take a breif look at HAML in action:

%html
  %head
    %title HAML Demo
  %body
    #container
      .content
        %p Stop. HAML time 

That’s it. No annoying tags to close, no need to specify the tag name when all we want is a div, and best of all, the # and . characters mimic those of CSS. Here’s the output:

<html>
  <head>
    <title>HAML Demo</title>
  </head>
  <body>
    <div id='container'>
      <div class='content'>
        <p>Stop. HAML time</p>
      </div>
    </div>
  </body>
</html>

Now that your mind has been completely blown, you should download HAML and try it for yourself.

Resources for your reading pleasure

Installation as a Rails plugin

HAML is available as a Rails plugin. To install it, type the following from the root of your Rails project:

./script/plugin install svn://hamptoncatlin.com/haml/trunk

Once installed, you can start creating templates with the .haml extension.

PS: I have yet to mention Unspace on this blog. Thankfully, I work there now. With Hampton, Pete, Ryan, Anthony, and John. More about that soon, swear to god.

Hello, I'm back

Tuesday, September 05

So, yeah, I’ve been neglecting the blog. It happens from time to time. According to the date of my last post it’s been, like, almost two months since I last wrote here. What can I say. I’ve been lazy. And busy. This, then is the obligatory post where I recount the details of what went on during my absence.

I went to RailsConf in June. Me, Pete Forde (of Unspace and Rails Pubnite fame), and Cloves piled into my efficient four-door and made the ten-hour trek to Chicago. Cloves and I took turns driving; Pete doesn’t drive standard. Amazingly, I refrained from smoking for the entire car ride, out of respect for my non-smoking companions. This meant that we made frequent stops at convenience stores and gas stations, during which I would plough back a couple of smokes while Cloves and Pete bought beverages and candy. One of our stops found us at a ghetto roadside restaurant that Pete couldn’t resist. He has a penchant for these types of places. I ordered a coffee and a BLT sandwich because it seemed safe. The only remarkable thing about this meal was the fact that the coffee was served in the kind of promotional mugs that you get free from local car dealerships, or that teachers get for Christmas gifts. Mine read Dave Barron Chevrolet.

By the time we arrived at the hotel in Chicago we were worn and tired from the road, suffering from that affliction whereby everything seems funnier than it should be and is typical of long trips with little movement of legs. We had a few beers at the hotel bar, chatted with other Rubyists, and gawked at our favorite Rails celebrities.

What can I say about the conference that hasn’t been said already? Yes, _why was quite hilarious. A true showman. It’s also worth noting that the audience looked like a sea of silver. Seriously, I’ve never seen so many Power/MacBooks in my life. The cult of the Mac is strong in Rails culture; the guys with Dells hid them in embarrassment—unless of course they were running Linux. Such is the usual case when Macs abound: the people that have them bring them out, flaunting them dangerously (I even saw more than one person using their 17” MacBook as a cafeteria tray, loaded up with muffins and cookies); the ones that don’t, hide them.

Highlights of the conference included Hampton’s patch getting mentioned in Dave Thomas’s keynote, and Pete rounding everyone up (including a few members of Rails core) for some famed deep dish Chicago pizza and then realizing by the time we got to the restaurant that we wouldn’t have enough time to eat and make it back in time for Paul Graham’s Keynote. We conferred in the parking lot and drove back to the hotel with empty stomachs. We tried it again the next night, though, this time with success. It was good getting to chat with Obie Fernandez, Tobi, and Marcel about assorted Ruby-related topics. And the pizza was fucking delicious. We made it back just in time for DHH’s keynote, during which I drank a beer.

Almost immediately after RailsConf, Cloves and I had our workshop in Toronto with David Black. In fact, David flew straight from Chicago to Toronto. Having arrived home a day in advance, we spent some time getting our ducks in a row, renting the projector, making handouts. It worked out well that Mr. Black was at RailsConf as we were able to do most of the planning in person. David is a great guy. If you haven’t bought his book yet, you should be shamed into buying two.

The workshop went well, save for the fact that I showed up late (traffic is to blame, I swear), and the conference room was booked under the wrong name. We had a crowd of about twenty. Most attendees had very little knowledge of Ruby or Rails, and some were new to programming in general. Nothing wrong with newbs by any means, but for some reason I was expecting slightly more Rails literacy. Another surprise (though in hindsight, it shouldn’t have been) was that nearly everyone was using Windows. Seriously, I think only one person had a Mac. And no Linux in sight. David handled it well. He’s such an intelligent guy, and a greater command-line hero I’ve never seen. He did everything on the console and in vim. A true hacker. I hope that students came away with the notion that Rails is a powerful tool in the hands of a skilled programmer, not a magic robot that will write your applications for you. Of course, I also hope they learned the basics of constructing a Rails app from scratch.

After the workshop, we hung around for a while and picked David’s brain, and then went out for beers where we exchanged thoughts on the state of Rails, our musings about the conference in Chicago, and the joys of Ruby. I dropped David off at his hotel and then Cloves and I went back to his house where his wife made us dinner.

After all this I took a couple of days off.

When I finally got back to hacking, it was in Toronto at Unspace. That’s right, I’m now one of their famed non-employees (I think). Unspace is great. Working with really smart people makes all the difference. The only downside to this arrangement is that I have a fairly long commute. Actually, it’s about an hour and a half each way. Yeah. It’s ever so slowly killing me. The drive home is worse than the drive in. Once it took me four hours. Don’t ask.

This week I’m enjoying a brief break from the commute as I’m staying at Ryan’s condo here in Toronto (Ryan is a partner at Unspace and is effectively my boss). This is a good thing, since I have a lot of personal work to catch up on (more on that later).

Cloves moves to Dubai today; Amy and I stopped by and visited he and his wife, Jane, last night on our way to Toronto. Yeah, you read that correctly: Dubai. I’m quite happy for him actually; he’s been talking about moving ever since I met him last year, and now he’s finally doing it. Perhaps it goes without saying, but making a move to the middle east isn’t the easiest undertaking in the world. I wish him the best of luck.

I’ll be going there at Christmas to visit.

The Cobbler's Children Have No Shoes

Friday, September 01

Okay, so I’ve been busy. Too busy, actually; I haven’t had a lot of time for hacking on my open source projects, including the surprisingly popular Scribbish theme for typo.

In the time since I last posted here on this lowly blog, Scribbish has been added to the main typo distribution as one of the default themes. This makes me happy. But it also means that it’s slightly harder to maintain. Now, instead of just pushing changes whenever I feel like it, I have to make a patch against typo and submit it to the typo trac. This is probably why I’ve put off updating it for so long.

Being part of the default typo distribution means an increase in visibility, however, and the lack of maintenance was making me look bad. There are a lot of blogs running Scribbish (it’s allure, I think, stems from the fact that it’s dead simple), so the internet is now rife slightly borked versions. Fuck. I finally broke down and decided to fix it.

Alas, it has now been updated. Fixes include the flickr sidebar that liked to float right, detail pages that would produce invalid xhtml in the event of zero comments, comments and trackbacks that would display even if they weren’t published, and a few other odds and sods. The patches have been submitted and are patiently awaiting application.

Thanks to everyone who sent me suggestions and patches. Much appreciated.

I’ve also updated the Scribbish subversion repository with the latest patches; I’m not sure how much longer I’m going to maintain this branch. I might use svk to maintain both versions, but then again, I might not. For now, though, I’ll continue to maintain both, and the subversion version (that sounds funny: ‘subversion version’) will be up to date with the latest patches submitted to the typo version. This should make it easier for the folks who are so graciously porting it to other applications (word on the street is that a Mephisto version is in the works).

So, yeah. Scribbish is updated; I’ll post a notification when the patches have been applied. Then you can update typo and all will be right with the world. If you want to live dangerously, you can always delete the themes/scribbish directory from typo and use svn:externals to stay in sync with the development branch.