19 December 2008

Native Postgresql Data Types for ActiveRecord

In researching ActiveRecord migrations, I came across this bit of new information in their documentation:

Instantiates a new column for the table. The type parameter is normally one of the migrations native types, which is one of the following: :primary_key, :string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean.

You may use a type not in this list as long as it is supported by your database (for example, "polygon" in MySQL), but this will not be database agnostic and should usually be avoided.

So, what? Well, this came in handy immediately because I was creating a table that used Postgresql's native inet data type. I plan to use some of the related inet functionality at a later date so this is a big win.

Here's an abbreviated version of my migration that uses the inet datatype. I am running Ruby on Rails 2.2.

class CreateDevices < ActiveRecord::Migration
def self.up
create_table :devices do |t|
t.column("ip_address", :inet) # this works beautifully
# t.inet :ip_address # this won't work


def self.down
drop_table :devices

Notice that one has to be explicit and use the column method and not the shortcut.

18 December 2008

Ruby's native postgres gem on Windows

The ruby-postgres gem is a compiled and fast adapter. It has some dependencies for Windows, though, so follow these steps to get it running properly:

  1. go to the http://www.postgresql.org/ftp/binary/ and navigate to the release that matches the Postgres server that you installed.
  2. look for and download a file that follows the pattern postgresql-8.X-binaries-no-installer.zip where the X corresponds to the database release
  3. unzip the file and navigate to its bin subdirectory
  4. copy the following files into your ruby installation's bin directory
    • comerr32.dll
    • krb5_32.dll
    • k5sprt32.dll
    • libeay32.dll
    • libpq.dll
    • libiconv2.dll
    • libintl3.dll
    • ssleay32.dll
    • gssapi32.dll
  5. after you have done all that, you should be able to open an interactive ruby session (irb) and type require 'postgres' and get 'true' as a result, i.e., a non-error

17 December 2008

Pylons and SQLAlchemy

I recently gave Pylons and SQLAlchemy a spin. I mainly wanted to check out SQLAlchemy so that I could evaluate it for upcoming projects. Well, my opinion is that it is wildly flexible and, therefore, came with a steep learning curve. Pylons wasn't too hard to grasp although it seemed sort of arcane at times. I genuinely liked Pylons though.

This has been a disappointing experience for me. I wanted Pylons and SQLAlchemy to be fantastic so that I'd have a compelling reason to come back to Python full-time from Ruby. Not the case, I'm afraid. Looks like I'm going to be spending more time in the Ruby and Ruby on Rails camps in the future.

Ubuntu destop is so broken...

I've had it with Linux on the desktop.

Things that didn't work...
  • my office's Java based SSL VPN
  • flickr uploader
  • all sound and, therefore, dependent applications like Skype
  • and more...
To be fair, the issue is mostly with my computer's particular hardware. For example, my computer's NVidia card driver constantly pegged the processor at 25%. Not acceptable.

I am sad that Ubuntu on the desktop didn't work out for me. Oh well, back to XP for at least another year.

13 December 2008

So far, so good

The switch from XP to Ubuntu has gone just fine so far. There are a couple of things that I'd like to work out. One is that I can't seem to connect to my office's SSL based VPN which uses Java. I have the 1.6 JRE from Sun installed and configured but, when I connect to the office VPN, it just freezes up Firefox.

I also need to try the proprietary NVidia Geoforce graphics card driver. The screen transitions and scrolling with Firefox seem pretty jerky without it.

12 December 2008

Ubuntu - here we go again

So, I got a new laptop at work. It's a Dell Vostro 2510 with a 250gb 7200rpm SATA HD and 4 Gb RAM. It came downgraded to XP. I had installed Ubuntu to dual-boot with XP. That worked okay but for some reasons that I can't remember I wasn't quite satisfied and decided to remove Ubuntu. That happened on Monday.

After having settled for XP I started to set up my many applications. After a day or so I noticed that many fundamental programs were not working for me. That led to me conclude that I probably needed to wipe XP and reinstall from the source media that Dell provided.

Well, as long as I'm going to reinstall, why not put Ubuntu back on and force myself to use it for a week? Well, that's where I am now. I'm going to go Ubuntu whole hog for at least a week. The only thing that I know doesn't work is my soundcard. The graphics card will require a proprietary driver to do compiz. Even then, I think that the compiz didn't work quite right so I'll probably not get to use that. Small disappointment.

I hate that I have burned so much time on this laptop when I have more interesting things to be doing at work.