Rails, ORA-000972 and You

Lately I’ve been running up against “ORA-00972: identifier is too long”, when writing Rails migrations for Oracle. This particular error indicates that one of your identifiers is longer than 32 characters which is the maximum length for Oracle.

It’ll look something like this in your code:

class CreateLongTable < ActiveRecord::Migration
  def self.up
    create_table :long_table do |t|
      t.string :title
      t.references :someother_really_long_identifier

This migration will give you a foreign key id called someother_really_long_identifier_id which is obviously too long for Oracle. The solution is to use your own foreign key id name. In your migration add a shorter reference.

class CreateLongTable < ActiveRecord::Migration
  def self.up
    create_table :long_table do |t|
      t.string :title
      t.references :short_name

Then in your model use the shorter foreign key name.

class LongTable < ActiveRecord::Base
  belongs_to :someother_really_long_identifier,
             :class_name => 'ClassName',
             :foreign_key => 'short_name_id'

And everything should be sweet, your model will use someother_really_long_identifier and no-one need know that the table is really using short_name_id.


Ubuntu Server Update

I posted a while ago about switching to Ubtuntu for my home server.

I’ve got the basics up an running on my MacMini (artemis). Namely DHCP for the home network, DNS primarily as a caching DNS server and WWW for hosting my wordpress steup.

The setup of DHCP was easy enough. Followed the find documentation on the Ubuntu site. Same story for a caching DNS.

Setup Apache/PHP/MySQL was a quick ‘sudo apt-get install php5-mysql’ and I installed Wordpress via subversion checkout. I’ve also installed BIND9 as a caching DNS server.

Some services I’m not bothering to migrate:

  • Subversion, I’ve switched to github and migrated anything I cared about out of subversion. It was useful at the time I set it up 6 or so years ago, but other/better options exist now.
  • MediaWiki, most of the stuff in there was either related to a project in Subversion. So I’ll switch to using the github wiki associated with a project. No need to worry about security or keeping software up to date.

So all in all a success switching to Ubuntu.

Now onto my wish list:

  • Ruby/Rails using passenger and Postgres, for messing about with personal projects.
  • Virtual hosts in Apache or even switch to nginx
  • Monitoring system stats like Memory/CPU etc
  • DNS within home network so I can setup aliases like dns.home

IntelliJ IDEA Ubuntu Launcher

I’ve been using IntelliJ on Ubuntu 10.10 lately for work and rather than starting things from the terminal I wanted a pretty launcher in the top menu.

After a quick search I found this site:

IntelliJ Ubuntu Launcher

Following the instructions yielded a pretty launcher to sit in my top menu bar.

The only improvement I could add is to have an /opt/intellij-current directory and use

sudo ln -s /opt/idea-IU-99.18 /opt/idea-current

to redirect it around to point to the current version of IntelliJ you have.


Leaving OpenBSD For

I’m migrating my home server away from OpenBSD.

The things I was able to setup in OpenBSD have worked very well. Things like DHCP, DNS and SQUID have worked excellently. I found some fantastic guides on http://www.kernel-panic.it/openbsd.html that allowed me to get everything up and working in no time at all. I wont bother posting any details from my setup it’s better to just visit that site and decide which pieces you want.

Why move away? These are surely very personal reasons to make the switch and are not a general condemnation of OpenBSD which is still a fantastic piece of software.

  1. I wasn’t able to get DHCP & DNS to dynamically update DNS when a new host was added to the network. Instead I had a whole heap of static mappings for computers. Not an ideal situation!

  2. The upgrade path for OpenBSD confuses me. When a new version comes out how do I upgrade without nuking all my local configuration? I really don’t want to go back through the setup every 6 months when the BSD guys bring out a new version.

  3. I wasn’t able to get PHP + MySQL + Wordpress to play nicely together. Not being a PHP person I didn’t really grok how to setup the whole thing so I was forced to follow guides written by others. OpenBSD doesn’t really seem to be a Wordpress/PHP platform of choice for many so I struggled to find accurate docs on what to do.

  4. I wanted to add new services to the server like Ruby/Rails, Java/EE, Python/Django and Erlang/OTP. Doing all this and keeping it current on OpenBSD is more work that I was willing to expend.

So the solution I’m turning to is Linux and specifically Ubuntu in all it’s glory.

What a spiffy system Ubuntu is? I remember struggling to install Debian way back when but Ubuntu is a pleasure and perhaps a little too easy. Kids these days don’t need to struggle for hours setting up XFree86 or a dodgy network card.

So over the next few weeks I’m migrating the essential services, DHCP, DNS and SQUID to Ubuntu. After that I’ll get a bit funky and start adding this blog on there and other bits and pieces.

Hooray for Ubuntu!!


Thoughts on ObjectiveC and Cocoa

I wanted to collect my initial impressions of ObjectiveC and Cocoa. I’ve started reading the Hillegas book again after and interrupted start last year with the goal of doing a lot more osx coding in the future.

The things I’m enjoying most about the language are:

  • the message passing nature of the method calls. It just seems like the right thing to do especially after experiencing Erlang and Ruby which both feature message passing.
  • the Cocoa APIs are beautifully self documenting and often read like pseudo code.
  • the fantastic use of Design Patterns within Cocoa, you can really see the benefits I using things like Delegates after spending some time doing ObjC.

The downsides so far are limited to manual memory management within ObjC. Granted there is a garbage collector on OSX but not on iPhones etc, so the common wisdom seems to be you need to know how to use both. I don’t see this will be an insurmountable problem as I managed to learn it for C++ which was a much larger language.

The Hillegas book I’m using is brilliant but what would you expect from a guy that has run training course on the subject for so long. The book does feel like running through a training course but one run by a guy genuinely exciting about the subject. My only wish is that there was an equivalent for the iPhone / iPad.


.emacs Publishing

I signed up for a BitBucket account earlier this month but I’ve only recently got around to using it. My first public project is my .emacs file. Check it out at lambda_foo/.emacs.

Includes partially working setup for:

  • CommonLisp and SLIME
  • Erlang/OTP
  • Ruby
  • Haskell
  • Groovy

The whole config is split into individual lisp files that are specific to a language or cross cutting feature. The inspiration for doing this work came from M-x all-things-emacs


Declaring .emacs Bankruptcy

Well really this is a post bankruptcy posting!

What? Cleanup .emacs file impossible you say. It must gather sediment like sandstone until you have a tremendous hard packed conglomeration of ideas, never daring to change something unless it breaks and not knowing if it worked in the first place.

The Motivation: Messy configuration file, no organisation, unused configuration/modes.

The Solution: Remembering a link I archived in delicious some time ago, I revisited their ideas.

What I got was a very short .emacs file that only has some Load Path additions and a heap of require statements for each customisation broken down into modes or languages.

I really like this because it’s quite simple to add a new mode or customise and existing one. Plus moving between Mac OS, Linux and BSD is a breeze, and sharing a config file for a particular mode is soooo much easier.

I highly recommend doing this sort of clean up to your own .emacs. After all who doesn’t like an organised workspace!

Original motivation here: http://www.emacsblog.org/2007/10/07/declaring-emacs-bankruptcy/


eBook Thoughts

I’ve become a convert to the whole ebook thing recently, but only in a limited capacity.

I still like having a paper book for most things I read like history and fiction. The real value comes from replacing all those technical books that you buy, like Java EE in 5 days.

There is a small subset of all the technical books I have that I really want a paper copy of. Stuff like my Operating System books that you cannot get anymore or are nice to have sitting on the bookshelf. But in general technical books date so quickly that if you’re looking at something more that a year and a half old it’s pretty much useless. The same goes for buying new book, I’ve started asking myself the question Am I going to read this in the next 6 months? if the answer is no then I don’t get the book. The only value in buying a technical book lies in actually learning the content of it, not in decorating your bookshelf.

Looking at my current bookshelf, there is probably half or more books that are severly outdated and aren’t any use in their current form. I’m currently in the process of thinning out their numbers.

What I’m planning on doing in the future is grabbing an eBook reader (and using my MBP) and keeping all my technical books there. Basically treating technical books more like magazines or newspapers, not that I really buy either of those anymore.


NetBSD 5.0 on an AspireOne 110L

After trying Ubuntu Linx on the AspireOne for a few months, I wanted to branch out and try something a bit different. Linux is so main stream theses days, I only had to mess around with the wireless. Far too easy. Why back in my day we entered our X11 config on punchcards!!!

Anyway, my options were either OpenBSD or NetBSD.

I’ve wanted to try OpenBSD on the desktop for ages, but being a bit fresh at the BSDs I decided to go for NetBSD. It was a bit less daunting and there are more online resources for NetBSD. But there is still something about OpenBSD, I’m sure I’ll get around to it soon.

So I started off with downloading the ISO images for the latest NetBSD release 5.0. The latest release of NetBSD includes improved ACPI support and the ath(4) wireless is (apparently) supported. Plus all the other goodies mentioned in the release notes.

NetBSD Install

NetBSD has a basic terminal based installer, anyone with some Unix experience should be comfortable and even without any experience, just reading the installer guide should get you a working system.

My AspireOne 110L came with:

  • Intel Atom 270 (1.6Ghz)
  • 1.5Gb RAM (upgraded from the base 512MB)
  • 8Gb SSD, and
  • 8.9”screen @ 1024x600

No CD drive meant that I needed a bootable USB drive. I followed these basic guidelines. Since this page was written for 4.0 some of the steps are different.

Step 7. change the url from

ftp -a ftp://ftp.netbsd.org/pub/NetBSD/iso/4.0.1/i386cd-4.0.1.iso



At Step 9 change it to look like this:

mount /dev/sd0a /stick
cp /image/i386/binary/kernel/netbsd-FLOPPY.gz /stick/netbsd.gz
cp -R /image/i386/binary/sets /stick/sets
umount /stick
rmdir /stick

I’m not sure I used the correct kernel here, the name suggests a bootable floppy kernel rather than the normal install kernel. I tried the netbsd-GENERIC.tgz but it started looking for things like “init” and “/etc/rc” which didn’t seem right so I went back to the other kernel.

After I had the bootable USB setup correctly I rebooted the Aspire and started the install. Initially I tried following the instructions on installing from the sets copied onto the USB stick but the installer couldn’t find them. So In the end I went for the HTTP install (Figure 3.20 from the Install Guide), a few hours later the installed finished. Rebooting the system brought this greeting:

Last login: Mon May 18 22:09:59 2009 from
NetBSD 5.0 (GENERIC) #0: Sat May 16 18:00:22 EST 2009
Welcome to NetBSD!

After poking around for a bit the 2 main outstanding issues are: X11 Setup and Wireless.

X11 Setup

Here the NetBSD docs are really lacking, they still explain how to configure XFree86 which is a complete pain. Instead NetBSD is shipping with Xorg, providing a vastly superior configuration experience.

Simply run X -configure as root. Nice!

It’ll dump an xorg.conf.new in root’s home directory.

To test the server with this file, run X -config /root/xorg.conf.new.

And if you’re happy with it copy it over to /etc/X11/xorg.conf.


The ath(4) driver doesn’t attach correctly with the default GENERIC kernel, so some customisation is required. Apply this patch:


Recompile the GENERIC kernel and reboot.

All the steps are documented here:


After a reboot it’s recognised:

 ath0 at pci3 dev 0 function 0
 ath0: interrupting at ioapic0 pin 18
 ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
 ath0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

Things to fix up

Installing NetBSD and getting productive certainly isn’t the seamless process that Ubuntu was. So there are a few minor things that need a bit of fixing.

  • Wireless on WPA2: Linux worked on this so I’m sure NetBSD can.
  • Booting straight into X: It’s in the docs so it won’t be hard.
  • Installing a decent WindowManager: XMonad here we come :–)



Forcing Snow Leopard to Use 64bit Kernel

How to force Snow Leopard to boot the 64 bit kernel, cause we all want to run the latest 64 bit goodness from Apple.

Open the file


with something like TextEdit and add arch=x86_64 to the Kernel Flags string:

<key>Kernel Flags</key>

This is posted just about everywhere, and is really only added here for my convenience.