Category Archives: Coding

Deploy a specific revision with Capistrano

Just about every website that I release, be it at work or at home, is stored in a Git repository, and deployed using Capistrano. I’ve been debugging this PHP application at work that was written by a 3rd-party. After cleaning … Continue reading

Posted in Coding Tagged ,

Matching Printable Characters

Who doesn’t love regular expressions? They’re fucking awesome. I use’em at least 10 times per day. Sometimes, there’re restrictions on what patterns you can use. I wanted to change a regex for validating passwords. Originally, it allowed letters, numbers, and … Continue reading

Posted in Coding, GNU/Linux, Uncategorized Tagged

Hashes and Frozen Keys

The hash class freezes keys that are strings: This can be a problem if you want to use those keys later on…more specifically, if you want to extract and edit those strings: Unfortunately, those strings will have to be duped … Continue reading

Posted in Coding Tagged ,

Sinatra and Passenger/mod_rails

If you want Apache to serve up a Sinatra app, your best bet is to use Passenger (AKA mod_rails). All your app needs is the usual Rackup config file (config.ru) in the app’s root directory, and the directory public/ . … Continue reading

Posted in Coding Tagged , , ,

Ruby in Etch

As some of you may know, Ruby and Debian’s ways of packaging software go together like Darwin and religious zealots…as in, they don’t. So how should you install Ruby when using Debian Stable? How do you stay up-to-date with new … Continue reading

Posted in Coding, GNU/Linux Tagged , ,

Default stegosaurses

Ever heard of Jonathan Viney’s active_record_defaults plugin? It’s fantastic. In a nutshell, it enables you to specify default values for model attributes. If an attribute isn’t set when initialising a new instance, the attribute’s set to whatever the default value … Continue reading

Posted in Coding, Ruby Tagged , , ,

Friends don’t let friends code without tests

But what if your friends don’t write tests? Or what if you’re just lazy? Well, if the latter applies, that’s your own damn fault. But if nobody around you tests their code, you’re probably not going to be motivated to … Continue reading

Posted in Coding Tagged , , ,

Testing…it’s what life’s all about

I just read a great call to action by John Nunemaker. He wants to see everyone writing tests for their code, and has decided to “post like a superhuman fiend until everyone is testing”. He’s on to something! With that … Continue reading

Posted in Coding Tagged , , ,

Rails Resources:   :as   vs   :controller

As you may or may not know, when configuring routes and resources in config/routes.rb , you can pass the :as or :controller options to map.resources . When I first read about these two options in the Rails Routing From The … Continue reading

Posted in Coding Tagged , ,

Convention and reasoning

When coding in the past, I rarely used the switch/select/case-conditional. However, since I started using Ruby, I’ve found it to be quite useful in some situations. Vim formats them like this: case foobarwhen ‘something’ # Do something.when ‘another thing’ # … Continue reading

Posted in Coding Tagged