Song Lyrics to Live By

Posted by mick on August 31st, 2009 filed in Uncategorized

Every now and again I hear a song lyric that really resonates with me for some reason or another. In particular, for many years I’ve had a couple of lyrics that I’ve called my “life mottos”. The first one is from John Lennon:

Life is what happens to you while you’re busy making other plans.
John Lennon, from the song Beautiful Boy.

and the second from Stephen Stills:

Love the one you’re with.
Stephen Stills, from the song of the same title.

A couple of years ago I heard a song that had a line that I just knew instantly I wanted to elevate into my “Song Lyrics to Live by” list. It’s not a recent song by any stretch, but I hadn’t heard it (or taken notice of it) before, and so it was new to me. Anyway, here’s the line from that song that has now made it into my list:

Don’t confront me with my failures. I had not forgotten them.
Jackson Browne, from the song These Days.

None of these songs is one of my all time favourites, but the lyrics are my favourites of all time. Not necessarily the lyrics of the whole song either. Just the one liners that I’ve mentioned above.

I was going to explain why they mean a lot to me, but then I got lazy, and anyway, life is happening to me while I spend time writing this post.

So there you have it: Mick’s list of Song Lyrics to Live By.

Centering in IE7. Beware of quirks mode!

Posted by mick on July 3rd, 2009 filed in CSS, HTML
1 Comment »

I was scratching my head today (and doing a bit of swearing) when a web page that should have been centered no longer was on Internet Explorer. The page was still correctly centered in Safari and Firefox. The CSS for the centered element looked something like:

  width: 960px;
  margin: 0px auto;

It took me a while to work out what was wrong. It turned out that my problem was that my html file had a comment before the !DOCTYPE element. That is, while the top of the file should have looked something like:

    "-//W3C//DTD XHTML 1.0 Strict//EN"

it actually looked like something like this:

<!-- this comment mucks things up - - >
    "-//W3C//DTD XHTML 1.0 Strict//EN"

The problem is that that innocent looking comment is enough to put the IE7 renderer into its backwards compatibility quirks mode. And in that mode, margin: 0px auto does not center things as planned.

Creating a shadow with RMagick

Posted by mick on June 26th, 2009 filed in Ruby
Comment now »

RMagick is a ruby library for performing image manipulation. Whenever I use it I’m amazed at what can be achieved with just a few lines of code, so I thought I’d share my latest experience.

The context was that I was working on the website for 2WayFitness and I wanted to have screenshots that had a shadow effect behind them. For example, I wanted to turn the following:


into this:


Turned out, that to do that all I needed was the following code:

require 'rmagick'
include Magick

image ="image.png").first

shadow = image.shadow(0,0,3.0)
shadow = shadow.colorize(1, 1, 1, "gray45")
image = shadow.composite(image, 0, 12, Magick::OverCompositeOp)


I think that’s pretty cool! Kudos to the RMagick guys and to the people who developed the ImageMagick and GraphicsMagick image processing libraries upon which RMagick is built.

Using url helpers in Rails functional tests

Posted by mick on March 13th, 2009 filed in Ruby on Rails
Comment now »

Today I wrote a very simple functional test that had a line as follows:

    assert_redirected_to new_session_url

When I ran it I got the following error:

Missing host to link to! Please provide :host parameter or set default_url_options[:host]

The fix was simple. Instead of using a url helper, I should have been using a path helper.

    assert_redirected_to new_session_path

After this change, the test worked perfectly.

Capistrano hanging on svn export

Posted by mick on October 29th, 2008 filed in Capistrano, Ruby on Rails, ssh
Comment now »

I’ve been running into a problem lately where my attempts to deploy new versions of my rail app were hanging. Specifically, when I ran:

cap deploy

Capistrano would hang executing the svn export command. It took me a while to work out what was happening, but it turned out that the ssh connection being used by Capistrano to connect to the server was timing out. To fix the problem you can edit the ~/.ssh/config file on your client machine, and define values for the following settings:

ServerAliveCountMax 30
ServerAliveInterval 120

On the server, edit the file /etc/ssh/sshd_config and define values for the following:

ClientAliveInterval 60
ClientAliveCountMax 60

and then restart the ssh daemon on the server:

sudo /etc/init.d/ssh start

The exact values to use for the various settings are up to you. For more info on how they work, you can consult the online doco on your client machine:

man ssh_config

Rails page.replace and Ext JS

Posted by mick on June 21st, 2008 filed in Ext, Ruby on Rails

I tore my hair out tracking down a problem last week and figured I should share my solution.

I’m currently experimenting with using the Ext Javascript library to create much of the front end of a Ruby on Rails application. I hit a problem where using Rails’ page.replace was failing on Firefox. Specifically any script tags embedded in the html were not being run.

Turns out the problem is caused by both Ext and the Prototype library defining a defer() method, each with different parameters and semantics from the other. Due to the order I include things, the Ext version of defer wins, and is used everywhere. Rails’ page.replace eventually causes defer() to be called, but it needs to call Prototype’s defer rather than Ext’s defer.

The problem has been discovered by various people. For example, there have been some posts on the Ext forum about it (here and here) and the rails community feel it should be fixed in Ext.

A solution

There are no doubt many ways to consider addressing this problem, but the simplest I can think of is to patch /ext/adapter/prototype/ext-prototype-adapter.js so that the Ext defer function changes from:

    defer: function(C, E, B, A) {
        var D = this.createDelegate(E, B, A);
        if (C) {
            return setTimeout(D, C)
        return 0


    defer: function(C, E, B, A) {
        if(arguments.length == 0) {
            // this is for compatability with the Prototype
            // library which has a defer() function
            // that takes no parameters, and whose
            // meaning is the same as Ext's defer(10)
            C = 10;
        var D = this.createDelegate(E, B, A);
        if (C) {
            return setTimeout(D, C)
        return 0

That way the Ext defer provides the same semantics as the Prototype defer in the case where the caller provides no parameters. As such, it no longer matters that page.replace ends up calling Ext’s defer since Ext’s defer now does what page.replace expects.

Alternatively …

Another way around this problem is to stop using page.replace and to use Ext’s Ext.Updater facility instead. Converting an app from using page.replace to Ext.Updater is not a trivial exercise, however, and so I’d still suggest applying the above patch even if you do plan to convert across to Ext.updater, especially since the patch addresses the defer problem directly, and defer may be used by prototype (and Rails) in many places.

Hello World

Posted by mick on January 3rd, 2008 filed in Uncategorized
Comment now »

This is a place to hold the musings of me, Mick Hollins.

I’ve recently started my own company and so hopefully I’ll get some time to write about some of my experiences.

I’m a software developer. I’ve spent most of my adult life coding in C++/Java, and could never understand how these dynamic language guys just “didn’t get it”. I’ve finally decided to get out from under the rug and give dynamic languages a real go, and so far … I’m loving it. I will hopefully get to write more about my experiences with dynamic languages in the future. A friend suggested to me that I call my blog “Dynamic Eye for a Static Guy”. I just might do that …