echo "hey, it works" > /dev/null

just enough to be dangerous

Joy of version control


I'm a two-bit hacker. Most code I've written to date is small and self contained, rarely more than a couple of files. For that reason, I always thought that version control was a bit overkill--a good idea, but not really worth the effort on small projects. However, at work we do use version control and it's been an interesting experience. The main selling point for version control software is the ability to track changes, but I've found that the changes that using version control software has made to my coding practice have been the most useful. Instead of hacking away at whichever bit of code that's in front of me, I'm having to consider the changes that I'm making as commitable chunks. This has clarified my thinking about what I'm doing and improved my focus. So, from now on, version control on everything more than a five line shell script.

Passing information to Camping


If you want to pass information to a Camping controller, all you have to do is define the class like this:
class Index < R '/(\d+)' get(id)
Now whatever was matched by the regex \d+ can be retrieved by the variable id. If you want to pass more than one variable, just chain them like this:
class Index < R '/(\d+)/(\w+)' get(id, action)
Each of your regex groups will be passed as a variable.

If you forget to add the arguments to the get method, you'll get an error like this:

Camping Problem!

MyApp::Controllers::Index.GET

ArgumentError wrong number of arguments (1 for 0):

Screen in a screen


I have GNU screen running on a couple of boxes. Occasionally I accidentally ssh from inside screen to the other box and attach the remote screen, purely out of habit. That means that C-a sends a signal to the outer screen. You can send a real C-a to any application through screen with C-a a, so to detach the inner screen you use C-a a DD.

Snippets for Vim


One of the most raved about features of TextMate is snippet expansion. Felix Ingram has written a Vim plugin that emulates this behaviour, SnippetEmu. I haven't had much of a play with it yet, but it looks like a real time saver. You need Vim 7, and make sure you have the following in your vimrc:
filetype on filetype plugin on

Yahoo Pipes


I've just created my first Yahoo! Pipe, and it was incredibly easy. I subscribe to Lifehacker, which is full of really good ways to procrastinate - ah, improve your productivity. However, I use a Mac, so I really don't want to see all the Windows tips. The screenshot below shows what 30 seconds in Yahoo! Pipes let me do; filter out all the Windows tips.
Lifehacker feed in Yahoo! Pipes
Here's the feed.

PHP build fails to find MySQL libraries


I'm trying to build PHP against the MySQL supplied binary on my Mac mini running 10.4.9. For some reason it's looking in the wrong place for libraries, so I get the following error:
/usr/local/mysql/lib/mysql/libmysqlclient.15.dylib Referenced from: /Users/michael/build/php-5.2.3/sapi/cli/php Reason: image not found

/usr/local/mysql/lib exists and contains the libraries. It seems like a horrible fix but the following "fixes" the problem:

sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

__PHP_Incomplete_Class


When you save an object to a session in one file, say write.php, and then retrieve it from another, say read.php, PHP needs to know about the class definition so that it knows how to unserialize it from the session. If you don't include the class in read.php, you'll get an error complaining about __PHP_Incomplete_Class.

MacPorts Tomcat5 install borks on antlr


In the middle of the Tomcat 5 installation, MacPorts was unable to download the required version of antlr, 2.7.7. After a bit of digging, it became clear that this was because the antlr website only has the latest versions available for download.

The required version of antlr is available in the gentoo distribution, so you can get around the problem.

  1. Download antlr-2.7.7.tar.gz from gentoo or I mirror. I got it from Planet Mirror.
  2. Edit the antlr portfile (by default it's at /opt/local/var/db/dports/sources/ rsync.rsync.darwinports.org_dpupdate_dports/lang/antlr/Portfile (line split for readability)). You need to change master_sites to the location of the antlr source you downloaded, for example file:///Users/michael/Desktop/.
  3. Run port install tomcat5, and all should be well.

Error message hell


While trying to book an international flight online through Emirates, clicking submit on the second last step in an involved process I got the following error message:

ERR_shortmiddlename_1

So friendly. Certainly gives me a way forward, like step-by-step instructions about how to solve the problem. My middle name is part of my profile, and there are certain things in your profile you can't edit. Like your name. When I joined Skywards, the Emirates reward program, I'd entered "C" as my middle initial, and after a recent "upgrade" the full middle name was required. The error message was a show stopper, so it was on to the phone centre to get them to change my name, or no flight. Which I wouldn't have minded if the error message had said:

Our booking system requires you to have a middle name longer than one character. Please send an email to blah or call blah to update your profile.

I hate the mouse


I hate using a mouse. I much prefer to work with the keyboard. I also do a lot of work in a browser. One of the most useful keyboard shortcuts I've come across in Firefox is the apostrophe. If you want to go to a link, simply type ' and start typing the link text. For example, gootodo doesn't have any keyboard shortcuts, but I can create a new todo by typing 'new and hitting enter. That's quicker than moving my hand to the mouse and moving to the link.

You can also go to the detail of a particular todo by typing the todo (if you have the 'Find text as you type' option selected), pressing tab to get to the detail link and hitting enter.