Categories
Uncategorized

Moved to Typo

After much delay, I’ve finally moved this blog to typo. It’s a good example of running rails in “production” mode.

Now I just need to find a good blog editor client. It’d be nice if it supported Textile, which I’ve recently been converted to.

Oh, and it’d be really cute if I could figure out how to get tags like pdcawley. I suspect that I need to run the trunk of typo to get that though. Or maybe there’s a plugin somewhere…

Categories
Uncategorized

FreeBSD / mod_fastcgi

Eventually, I managed to get mod_fastcgi to compile on FreeBSD. See PR#91190. It basically amounted to applying the patch in the mailing list automatically. But what really surprised me were the changes to the port’s Makefile. I trimmed out about 50 lines of confusion into this:

AP_FAST_BUILD=    yes
AP_GENPLIST=    yes
SRC_FILE=    *.c
PORTDOCS=    LICENSE.TERMS mod_fastcgi.html

This is all thanks to the new bsd.apache.mk support. It really works well. However, it is slightly underdocumented. But this isn’t much of a problem. less /usr/ports/www/mod_*/Makefile provided enough hints to get going quickly.

Now I just need to get the maintainer approval, in order to get this committed…

Categories
Uncategorized

Units

I love wikipedia: List of strange units of measurement kept me giggling for ages.

Categories
Uncategorized

Class::DBI transactions

This is something I did at work just before Christmas, which is kind of useful.

Some years ago, I came up with the original method do_transaction() for Class::DBI. However, it’s kind of clunky to use, as the example shows.

Music::DBI->do_transaction( sub {
  my $artist = Music::Artist->insert({ name => 'Pink Floyd' });
  my $cd = $artist->add_to_cds({
    title => 'Dark Side Of The Moon',
    year  => 1974,
  });
});

The thing that bugs me in particular is the mandatory use of sub {}. I’d rather it be like ruby’s blocks, more of a language feature. Thankfully, Perl allows you to do this with prototypes.

So I modified my base class for Class::DBI to look like this:

use Exporter 'import';
our @EXPORT = qw( do_transaction );
sub do_transaction (&) {
  my $class = __PACKAGE__;
  # Rest of function remains the same.
}

This lets you call do_transaction in a much simpler fashion:

use Music::DBI;
do_transaction {
  my $artist = Music::Artist->insert({ name => 'Pink Floyd' });
  my $cd = $artist->add_to_cds({
    title => 'Dark Side Of The Moon',
    year  => 1974,
  });
}

Now I have committed one of the cardinal sins of Perl OO here—I’m exporting from an OO module. In this case though, I feel it’s justified. Firstly, you need to call the function as a function and not a method for the prototype to have any effect. Secondly, it greatly reduces the amount of typing that I have to do. Overall, it’s a much nicer solution.

Of course, Ruby on Rails makes this much simpler, because it’s notion of blocks is so deeply embedded into the language. See ActiveRecord::Transactions::ClassMethods for details.

Categories
Uncategorized

Leap Seconds

Linux tells all:

Dec 31 23:59:59 seaweed kernel: Clock: inserting leap second 23:59:60 UTC

Sadly, freakiness still abounds:

% TZ=Europe/London date; TZ=right/Europe/London date
Sun Jan  1 18:02:48 GMT 2006
Sun Jan  1 18:02:26 GMT 2006