Archives

Tags

Showing articles written in February 2009. Show all articles

My first Merb site

Just a quick note to my legions of loyal followers (hey, Mum), I've just finished my first website written using the Merb framework.

S'coolhouse Rock and Swing

Development travelled along relatively well. I ran into a few issues early on with dependency hell and some bugs and/or missing functionality in a few gems. I blogged about a few of my hacks.

Here is my (partial) technology stack:

  • ORM: DataMapper
  • Tests: RSpec
  • Views: HAML/SASS (which I won't be using again, even though it's very well written)
  • Hosting: Dreamhost (using Phusion Passenger, which was easy to use with a config.ru file for Rack)

I still haven't worked out how to properly get Capistrano working with the Dreamhost setup, but shit happens...

Auf wiedersehen!

Bash shells, curly braces, substitutions, attack!

Here is something I do all the time:

$ cp a-file-that-is-badass a-file-that-is-badass.old
...
$ cp a-file-that-is-badass.old a-file-that-is-badass

But, considering I'm a wannabe hacker, I knew there was going to be a much faster way of achieving the same thing. Enter the curly brace of doom!

Let me slip on my hack suit and try that again:

$ cp a-file-that-is-badass{,-old}
$ cp a-file-that-is-badass{-old,}

Here, we are utilising a feature in bash called brace expansion. Basically, it is telling the shell to prepend the contents of the command to the left of the first brace to each string inside the comma-delimited list within the braces. Anything remaining to the right of the braces is appending to each expanded string.

Brace expansion can take place anywhere inside your command. You can even nest them!

Another example (in the case of a collegue with horrible spelling):

$ mv lib/complex/{fisicks,physics}.py

The possibilities are endless...