« May 2006 | Main | July 2006 »

June 27, 2006

No Software Keys Required

Listen to this articleListen to this article

Ever since I made Simian available, I've had a strong belief that the software should be available for download in a non-crippled form. That is, whether you pay for it or not, makes no difference to the functionality; you are however left with a clean conscience :)

Unfortunately, this is something that many customers find quite difficult to come to terms with. Many of them, after parting with a relatively small sum, insist they be sent a license file, software keys, or something else tangible for their money. I'm at the point now where I'm considering simply sending out a file containing 128-bytes of randomly generated gibberish that they can place in the software directory just to give them that warm, fuzzy feeling.

Did I miss some unwritten rule that says a polite email thanking them for their purchase isn't enough?

June 21, 2006

svn:externals

Listen to this articleListen to this article

This relatively unknown feature of subversion allows you to include one subversion repository URL inside another. By that I don't mean export and add, rather svn:externals allows you to create a virtual directory that links to an external repository.

I'm sure there are plenty of other uses but I mostly use svn:externals for adding plugins to my rails projects. For example, if you wanted to link to the Foreign Key Migrations plugin, from inside your rails project directory you would type:

simon$ svn propedit svn:externals vendor/plugins/

Then add the following lines:

foreign_key_migrations svn://rubyforge.org//var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
schema_defining svn://rubyforge.org//var/svn/redhillonrails/trunk/vendor/plugins/schema_defining

And voila! Now when you update your project you'll see something like:

simon$ svn up 

Fetching external item into 'vendor/plugins/foreign_key_migrations'
External at revision 25.


Fetching external item into 'vendor/plugins/schema_defining'
External at revision 25.

At revision 2533.
simon$

Notice how subversion updates the virtual directories as well.

Be aware though that this does mean you'll always get the latest code when you update. This is exactly what I want but may not suitable on all projects. Sometimes a simple svn export is more appropriate.

We're currently toying with the possibility of using svn:externals to share common code between some projects that are presently all in one big code-soup project but will be split up over the next couple of months. I'll let you know what we decide to do in the end.

June 14, 2006

Perhaps Pluralize Means Something Other Than I Thought

Listen to this articleListen to this article

Besides the unfortunate use of a z where there really ought to be an s (yes, yes, I'm Australian), what does this word really mean?

pluralize v. tr.

  1. To make plural.
  2. Grammar. To express in the plural.

OK, that's pretty much what I thought it meant. So then riddle me this Batman:

simon$ ./script/console 
Loading development environment.
>> "country".pluralize
=> "countries"
>>

Good good. Just as expected. So, now let's try something else:

>> "countries".pluralize
=> "country"
>>

Huh??? Since when did country become the plural of countries?

June 08, 2006

They say we go through three career changes but really...

Listen to this articleListen to this article

Ok so I'm an Aikido guy but I'm sure this will amuse most non-aikido people as well. Apparently it's legit! So now I can't help but make up funny movie titles:

Pushed to the brink by the death of his movie career, a down and out martial artist gives it one last go...Steven Seagal in: Out of Tune...coming to a cinema near you.

June 04, 2006

Schema Defining Plugin

Listen to this articleListen to this article

Just a quick update on my plugins. Two of them—Foreign Key Migrations and Row Version Migrations—needed to know if they were being run as part of ActiveRecord::Schema.define() so I extracted the common code into yet another plugin: Schema Defining. This new plugin provides a class method—ActiveRecord::Schema.defining?—that returns true if ActiveRecord::Schema.define() is currently running; false otherwise. Probably not a hugely useful plugin in the main but certainly a must have if, like me, you have a number of migration plugins that need to alter their behaviour accordingly.

June 03, 2006

Row Version Migrations

Listen to this articleListen to this article

The more I use Rails, the more plugins I seem to create. Each time I start a new project, almost the first thing I find I want to do is to copy a chunk of code from an existing project. The moment that happens, I think: Plugin!

So here it is. A plugin that automatically generates the following row version columns for every table:

:created_at,   :datetime,  :null => false
:updated_at,   :datetime,  :null => false
:lock_version, :integer,   :null => false, :default => 0

Not so difficult. In fact it seems almost trivial (as usual) but it means all my tables now get date/time stamps and optimistic locking for free.

Enjoy. As always, feedback, suggestions, patches, criticism, all welcome.