Dienstag, Jänner 10, 2006

Active Record vs. Og

Currently, I'm experimenting with the two most popular Ruby ORM APIs, namely Active Record and Og (by the way, convincing Og to work properly was quite time-consuming due its outdated documentation...). However, the philosophy of these two libraries are quite contrary. The most important differences I have spotted so far are:






RailsOg
Comprehensive documentationDocumentation is partially outdated
Database Driven (no need to define properties, all metadata is fetched from the database)Object driven
Common base class for all persistent classes (ActiveRecord::Base)No common base class needed
Default naming convention is "Name" (singular) for classes and "names" (plural) for database tablesDefault naming convention is "Name" for classes and "ogname" for database tables

What I like most about Og is, that it doesn't force you to inherit from a common base class. Actually, this was the most important reason for me to try out Og at all.

Active Record tries hard to help you produce readable code (and table names ;)). Personally, I like Active Record's pluralization approach very much. It looks like that after a few hours, Active Record's API appeals more to me than Og's. However, my opinion could change after gaining more experience with both libraries.

Donnerstag, Jänner 05, 2006

Ruby Gems on Ubuntu Linux

I've just installed the latest and greatest version of Ruby on my Linux box. So far so good. However, installing Rubygems was not straightforward: The setup aborted with a
No such file to load -- zlib (LoadError)
What gives? Well, some digging revealed the problem: the packages zlib1g and zlib1g-dev were missing on my system. So, I got them with apt-get. Unfortunately, that was not the whole story. The ruby bindings for zlib were missing too. Fortunately, a Japenese rubyist came to rescue and made my day. In short:

sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev
cd ruby-1.8.4/ext/zlib
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
sudo make install
and you are ready to run
cd ../../../rubygems-0.8.11
ruby setup.rb

Dienstag, Jänner 03, 2006

My wireless adapter and Linux: An odyssey

Today, an odyssey ended: I finally managed to get my Linksys WUSB 54g v4 running nicely on Ubuntu (Breezy Badger). According to current best practices, I have configured my router to use WPA encryption. As I didn't want to use the more insecure WEP just because it's straighforward to configure on Linux I have chosen the hard way. It took me several days, three Ubuntu installations, and quite a bit of experimenting and reading. However, now it's time to sit back and to document my heroic deeds. ;) Enough said, let's start:


  1. Install a fresh Breezy Badger.

  2. Install the package wireless-tools. You can install them with Synaptic as they are located on the CD.

  3. Download the driver. It's *not* the rt2500 driver as you may find in different tutorials, it's the rt2570 driver. That's a slight but significant difference. The rt2570 driver is fine if you have an USB network adapter, the rt2500 one is obviously suited for PCI based adapters. I got yesterday's CVS snapshot.

  4. Before you even try to compile the module, get gcc-3.4. You will need gcc-3.4 because modules have to be compiled with the same compiler version as your kernel has been. Unfortunately, Breezy Badger's kernel has been compiled with gcc-3.4 but the CD contains only gcc-3.3 and gcc-4.0. However, a simple
    apt-get install gcc-3.4
    will not do as we have no network connection yet. ;) Therefore, get the deb's for gcc-3.4, gcc-3.4-base and cpp-3.4 by using another workstation or boot up your Windows (you haven't kicked it of your hard drive yet, have you?). I have found them via www.rpmseek.com. Next, install them with dpkg according to their dependencies. You may need other dependencies as well. However, I haven't needed them because gcc-4.0 was already installed on my system due to my earlier experiments with the driver.

  5. Now unzip the driver to any directory, cd into this directory. Then cd into Module.
  6. Time for some bugfixing (only if you need WPA). Open the file rtusb_info.c and apply the following fix (in short, remove the constant IW_PRIV_SIZE_FIXED which is located around the string "wpapsk"):

    --- rtusb_info.c.orig 2005-12-14 00:54:26.000000000 +0100
    +++ rtusb_info.c 2005-12-14 00:14:14.000000000 +0100
    @@ -1290,7 +1290,7 @@
    { RTPRIV_IOCTL_WEPSTATUS,
    IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enc"},
    { RTPRIV_IOCTL_WPAPSK,
    - IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WPAPSK_STRING,
    + IW_PRIV_TYPE_CHAR | MAX_WPAPSK_STRING,
    0, "wpapsk"}, // Variable arg count
    { RTPRIV_IOCTL_PSM,
    IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "psm"}, // Variable arg count

    For more information see the driver project's forum.

  7. Now, you're really ready to compile your module. Run
    sudo make
    followed by
    sudo make install

  8. Your module is now located in /lib/modules/2.6.12/extra. cd to /lib/modules/2.6.12-9-386/kernel/drivers/net/wireless, create a new directory rt2570 and copy the file rt2570.ko from /lib/modules/2.6.12/extra into this directory.

  9. Open /etc/modprobe.conf as root and add this line:
    include /etc/modprobe.d/
    Otherwise you will get warnings at bootup.

  10. Go to /etc/modutils/ and create the file rt2570. Open it with an editor and insert
    alias rausb0 rt2570

  11. Almost done. Now we are ready to configure our network card. Open the file /etc/network/interfaces. The following settings worked for me. If you have other settings than me, get these weird integer values from the source (again, see rtusb_info.c).

    mapping hotplug
    script grep
    map rausb0

    auto rausb0

    #your WLAN card
    iface rausb0 inet static
    address 192.168.1.104
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    #from the source code: means WPAPSK
    pre-up iwpriv rausb0 auth 3
    #from the source code: means CIPHER_TKIP
    pre-up iwpriv rausb0 enc 3
    pre-up iwpriv rausb0 wpapsk your_wpakey_as_you_entered_it_during_router_configuration
    up iwconfig rausb0 essid name_of_your_wlan
    up iwconfig rausb0 rate 54M
    up iwconfig rausb0 key open
    up route add -net default netmask 0.0.0.0 gw 192.168.1.1 dev rausb0
    dns-nameservers 192.168.1.1


  12. Now issue
    sudo ifconfig rausb0 up
    If it doesn't work you may try to restart your system and cross your fingers. ;)

  13. Just in case you need to perform troubleshooting: With iwconfig you can check WLAN specific settings. Especially interesting is the link quality. Obviously, it should be greater than 0.

Montag, Jänner 02, 2006

What a sad day

Today, an ice skating hall in Bad Reichenhall (a small town in Bavaria, just a few kilometers away from Salzburg) collapsed due to heavy snow fall (see ORF news). Sadly, one person already died in this accident. Just by coincidence, I was there a few days ago. Such news make me a bit contemplative.