ruby, rails, textmate, automation, etc.

Notes from the Ruby Manor (part 2)

Posted on November 23, 2008

So this is Ruby Manor part 2. After the Ruby Manor morning session we had a tasty pub lunch, rocked up a little late, and settled down to an interesting afternoon of Ruby talks…

Again, the errors and omissions are mine.

Notes from the Ruby Manor

Posted on November 22, 2008

I’m lucky enough to be at RubyManor today; a Ruby conference organised by Ruby users, for Ruby users, costing the grand total of twelve of your British pounds. A bargain, as you’ll see if you check the lineup of talks and speakers.

I started making notes, but it seems to have evolved into some kind of blog post. Apologies for typos, crap grammar and glaring errors.

Optimising PNG images for the web

Posted on November 17, 2008

Stoyan Stefanov has recently written an interesting series of articles on optimising image files for the web. In his latest article he shows how to use pngcrush to safely shrink your files, one file at a time:

$ pngcrush -rem alla -brute -reduce src.png dest.png

This evening I found myself wanting to repeat that command for all the PNG files in my current directory, and then (having reviewed the new images) overwrite the originals. Rather than do it by hand I did what all pragmatic programmers do these days, and wrote a script. Here it is in action:

$ pngcrushall 
Crushing test4012.png ... ok
Crushing test9200a.png ... ok
Crushing test9200b.png ... ok
Overwrite original files? (y/N) y
Overwriting test4012.png ... ok
Overwriting test9200a.png ... ok
Overwriting test9200b.png ... ok

You can get it from github – download pngcrushall.

Obviously you’ll need to install pngcrush too. On a Mac this is pretty easy with MacPorts:

$ sudo port install pngcrush

Integration Testing for Multiple Web Applications – Introducing Integral

Posted on November 11, 2008

I’ve recently been developing a Rails app that relies on a database that is maintained by another team as part of a different application. As you can imagine, unexpected changes to the database schema can bring our Rails app to it’s knees if they’re deployed to the live server before our application is updated.

So far we’ve been lucky, but the issue has been at the back of our minds for a while. So this week I sat down and cooked up a solution, and we’ve called it Integral.

Integral consists of some Thor tasks that:

  • Run tests on your test server.
  • Keep track of which versions of your applications work well together.
  • Can be integrated into your deployment recipes to ensure that deploying an app should never break your live server again…

All the Integral code is on github, and I’ve written some fairly extensive documentation on the Wiki. Please try it out, give us some feedback, fork it, burn it, give us some feedback, etc. etc.

Installing merb with thor

Posted on October 05, 2008

Update (22 October): Things move very fast around here – the merb.thor file has been overhauled and now all you have to do to get the latest edge is download a single .thor file and run one command.

Matt Aimonetti wrote a neat post on installing merb edge with thor. Thor seems to have become the defacto technique for installing merb edge these days, and I’m going to give it a go in preference to installing merb with sake, as I had been doing.

Since Matt wrote his article the merb.thor file underwent a serious overhaul during the sprint at MerbCamp – what you need to do these days is quite a bit simpler:

curl -L http://merbivore.com/merb.thor > merb.thor
sudo thor merb:stack:install --edge

The source code for all the Merb gems will be checked out into a directory called ./src.

To get the full low down on how to use Thor with Merb, head over to the Thor Howto on the excellent new Merb wiki.

Building do_mysql on a 64-bit Mac

Posted on October 02, 2008

Whilst installing merb with edgy I’ve had run into some trouble building the do_mysql gem on my Macbook Pro. It’s a 64-bit machine, so I installed the 64-bit version of MySQL, and that was my first mistake…

Debugging JavaScript in WebKit

Posted on October 02, 2008

If you do much web development you’re probably a big fan of the Firebug plugin for Firefox. It really is a rare gem in the web developer’s arsenal. When I’m not developing I prefer to use Safari – it seems faster and leaner, so I often find that I’ve got both browsers open at once.

A couple of days ago something rather fantastic happened – Safari got a makeover…

Configure the Expires header for Rails under nginx

Posted on September 13, 2008

The images, CSS and JavaScript files served up by your Rails application can usually be cached by the web browser, rather than being downloaded (or checked) every time the browser loads a page on your site. For a properly configured site the net effect is faster page load times and a vastly improved user experience. Rails gives you some help here, but it doesn’t happen automatically – you need to configure your web server to set the HTTP Expires header. This article explains how to configure the expires header for a Rails application running behind the nginx HTTP proxy server.

Learning Erlang with the Pragmatic Programmer Screencasts

Posted on June 18, 2008

I’ve been meaning to get around to playing with Erlang for a while now. Tonight I set aside 30 minutes to watch the first of the Pragmatic Programmer’s Erlang Screencasts by Kevin Smith: Erlang By Example.

Each screencast is very reasonably priced at $5 a piece. I bought the first one, in which you learn how to build a simple chat system. I downloaded it immediately, excited to think that in only 30 minutes time I’d know lots more about Erlang than I did when I woke up this morning.

database.yml should be checked in

Posted on May 24, 2008

It’s generally acknowledged to be good practice to keep your production database.yml file away from your version control system. Why? So that people snooping around your version control system don’t find your database password. There are plenty of examples out there that tell you how to achieve this with Capistrano.

I’m talking about the database.yml file that you use during development.

Easy git-svn for Rails (or "git-me-up")

Posted on April 24, 2008

I’ve been trying to persuade git-svn to work properly with Rails plugins that have been installed via svn:externals. Whilst working out how to do it I stumbled across several great articles, but I couldn’t get any of the solutions presented to work perfectly. Samuel Tesla’s article is especially informative, but for a long time I couldn’t stop git-svn from trying to commit Git metadata back into my Subversion repository…

After a bit of head scratching I got it sorted, and wrapped the process up in a little utility called git-me-up.