Freelancing Gods 2015

26 Nov 2007

Link: Eli Miller: Proper cache expiry with after_commit

Can use this for any actions after transactions are committed - ie: Thinking Sphinx's delta indexing

18 Oct 2007

Link: ar-backup - Google Code

"Active Record backup is a Rails plugin which lets you backup your database schema and content in a schema.rb file and fixtures."

10 Oct 2007


Just a quick post to highlight a MySQL function I’ve created that I’m finding to be very useful (perhaps others will as well).

I love it when sorting ignores prefixes of ‘The’ or ‘A’ – definite or indefinite articles, if you want the correct terms. To get this happening within a SQL SELECT request is a bit tricky, but inspired by someone else’s solution (Ok, so I pretty much copied their code), I’ve created the following function to make it a lot easier:

    WHEN SUBSTRING_INDEX(field, ' ', 1) IN ('a', 'an', 'the')
      THEN CONCAT(SUBSTRING(field, INSTR(field, ' ') + 1),
      ', ', SUBSTRING_INDEX(field, ' ', 1))
    ELSE field

It works in MySQL 5.0 and 5.1 – I’m sure something similar could be concocted for Postgres.

To use, just call the function on whichever fields you want in your order clause, such as:

FROM posts

Or, via Rails:

Post.find :all, :order => 'ANTIDEFINITE(subject)'

I’m not sold on the function name, though – it’s a bit long, but at least it’s clear. If you’ve got a better suggestion, let me know.

10 Oct 2007

Link: AS Workshop ยป How to sort MySQL results ignoring definite and indefinite articles (the, a, an)

A not-too-ugly method of sorting while ignoring 'The', 'A', etc

09 Oct 2007

Link: ActiveWarehouse: Let's Get Analytical

A library that looks really useful for when you're dealing with data to report on, as opposed to ActiveRecord models.

31 Jul 2007

Link: Sphinx - Free open-source SQL full-text search engine

07 May 2007

Link: top-secret tuned mysql configurations for rails :: evan weaver

30 Mar 2007

Link: Sexy Migrations

20 Mar 2007

Link: #48123 - Pastie - Migrations for secondary databases

17 Dec 2006

Link: Extending ActiveRecord

25 Oct 2006

Link: San Francisco, Sqlite3 :memory: Tests, Asteroids

18 Oct 2006

Link: PJ Hyett : Composite Primary Keys are Good

Handy bit of example code for keeping track of read/unread posts on forums

RssSubscribe to the RSS feed

About Freelancing Gods

Freelancing Gods is written by , who works on the web as a web developer in Melbourne, Australia, specialising in Ruby on Rails.

In case you're wondering what the likely content here will be about (besides code), keep in mind that Pat is passionate about the internet, music, politics, comedy, bringing people together, and making a difference. And pancakes.

His ego isn't as bad as you may think. Honest.

Here's more than you ever wanted to know.

Open Source Projects

Other Sites

Creative Commons Logo All original content on this site is available through a Creative Commons by-nc-sa licence.