DBIx::Class default column value

Having read the docs for DBIx::Class::Row new() and DBIx::Class::ResultSource add_columns() it’s hard to know whether it’s better to (a) override new() for the Result module and set a default value in the method params, or (b) use default_value in the add_columns method and set the default within the database itself.

After some investigation, (b) requires fetching the row after creating it just in case there’s a default value being added by the database. Since I already had a custom new() method to validate one of the parameters anyway, I decided to go for option (a) and add a simple check to new()

$args->{ column_name } = $default unless exists $args->{ column_name };

DBD::mysql, MySQL and OS X Lion

I downloaded and installed MySQL Community Server 5.5.15 from http://dev.mysql.com/downloads/mysql/5.5.html

Using CPAN, I then tried to install DBD::mysql on a fresh install of OS X Lion and was presented with an error saying it was unable to load the library.

#     Error:  Can’t load ‘/private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle’ for module DBD::mysql: dlopen(/private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
#   Referenced from: /private/var/root/.cpan/build/DBD-mysql-4.019-H1RD6j/blib/arch/auto/DBD/mysql/mysql.bundle

Continue reading

Shartak internals – speech and translation

Within Shartak there are two main factions – natives and outsiders. To make things somewhat realistic (and interesting), when they first start off there is quite a hefty language barrier in that a native can’t really understand an outsider and vice-versa. This situation can be improved by gaining the various language skills that help with reading/hearing the other language, and then for writing or speaking the other language.

There are three levels of comprehension – basic, advanced and expert language – followed by foreign writing and foreign speech. As far as the translation of language goes, we’re only interested in the first three skills. The foreign writing/speech skills simply allow things to work in reverse.

One of the players posted the results of a fairly detailed examination of the translation system on the Shartak forum and he was quite accurate with a some of the information. It’s not possible to accurately translate the garbled text back into the original text – this is intentional because otherwise it would only be a matter of time before someone wrote a Greasemonkey script to translate it and thus render 5 skills completely useless.

Both native and outsider speech work in the same way, all that changes are the character sequences associated with each letter. The sequences were deliberately chosen (with assistance from someone who knows about such things) such that the outsiders have a less harsh sound than the natives.

Natives have sounds like kam, rak, hok and uck where outsiders have kar, rar, hum and uh.

Trivia: the name of the cannibals home camp Rakmogak is actually a slight variation of the native translation of “Raw meat”!

Shartak internals – Maps and movement

The map for Shartak is held in a database table with over 140,000 rows in it. Each row corresponds to a single location on the map, also called a tile. The initial island map was generated automatically based on a simple bitmap image with varying colours for the different terrain types. Since 2005 there have been many changes to it, most of which are done by manually editing the table one row at a time. Bear in mind that this system is probably not the best way to do it, but it works for Shartak and allows for some interesting map layouts if I ever need them.

Continue reading

IPv6 and Shartak

Over the last couple of weeks I’ve been trying to figure out IPv6. Having worked through some of the IPv6 certification at http://ipv6.he.net/ I now have an IPv6 enabled web server and mail server as well as IPv6 connectivity at home via tunnelbroker.net

I thought I’d update Shartak to allow access via IPv6 as well as IPv4 – mostly nothing needed to be changed, however…

Continue reading

iOS4.2 for the iPhone

iOS 4.2 for the iPhone 4 (and other generations) is now available – it includes a number of new features related to printing from the iPhone over wifi (AirPrint), streaming audio and video to AirMusic and AppleTV devices. Neither of those are particularly exciting to me since we don’t have any of those devices. The one new feature that I will make use of is that you can apparently now have custom SMS/MMS text tones and separate tones per contact. Continue reading

Conversion to WordPress3

After two years of not posting anything and letting my blog stagnate, I figured it was about time I started posting again. The first job was to update all the software and it seems Moveable Type (MT) has moved on considerably from the really old version that I was running. Since I last posted I’ve used WordPress for other things a few times and it seemed like a good idea to convert my blog over to it. The fact that WordPress 3 was recently released also meant it was a good opportunity to try it out and see what had changed.
Continue reading

Compiling on a 64 bit Linux

I’m currently in the process of upgrading my old server to a nice new 64 bit CentOS 5 install and came across a few issues rebuilding some of the packages.
In general I try not to use customised versions of packages since it makes updating the machine so much easier when there’s nothing to rebuild, however some things I do customise slightly such as Apache and Exim.
Whilst rebuilding the Exim RPM I came across some strange errors which I assumed (correctly) were to do with the fact that it was a 64 bit OS not 32 bit.

Continue reading