Archive of posts from 2011

Rails 3.1 replacement for filter_chain

In previous versions of rails, you could do MyController.filter_chain to get an object representing the filters on a controller.

Bundle Install Git Post Merge Hook

Who wants to type "bundle install" all the time? Not me, that's who!

Rails 3 counter_cache with has_many :through

After an evening of getting knee deep in the Rails core debugging and issue with counter_cache on a has_many :through, it seems this [has been reported on lighthouse](, and [a fix has been applied in edge](

Rubix Cube 5x5 Parity Algorithm

Nothing to see here, just an aid to memory:

CakePHP pagination and filtering

Here's another little trick in CakePHP - it's quite often that someone will request a big old list of paginated data, along with filters on that data.

CakePHP get controller from model

As much as MVC is great, sometimes there's that little requirement that forces you to go against the standard way of doing things.

Binding energy, fusion and fission

There seem to be two conventions for binding energy, one treating it as the (negative) potential energy due to the nucleons being close together, the other treating it as the (positive) energy needed to separate the nucleons.

SPF and Email Craziness

Email terrifies me - I just find it incredibly complex. Luckily, some folks have made it really easy to generate and add SPF records.

Html5 Canvas Tetris Clone

Here's a little tetris clone I made in html5 and canvas.

CakePHP Remove Time Printout On AJAX

One of the projects I'm working on at work has a load of this scattered around the codebase for AJAX, which really grates on me:

JQuery validation onkeyup

The JQuery validation plugin is pretty cool, but it doesn't validate on keyup by default unless the field has already been marked as invalid (by a form submit or a blur for example).

Natural Constant clock

Inspired by my friend Rob, I've created a clock based on natural constants.

CakePHP asset versioning

Yet another undocumented feature in CakePHP - very useful if you're looking for it, that auto-versions images, css files and javascript files to force cache invalidation by browsers.