Viewing Outlook vCalendar meeting invites in Thunderbird

I received an Outlook meeting invite in my email recently but because I use Thunderbird as my email reader I received the raw vCalendar data rather than a nicely formatted email with details of the meeting. After a quick google search I found a post on Daniel Tome's blog regarding Viewing Calendar Events in Mozilla Thunderbird.

His suggestion was to install a Thunderbird add-on called Lightning. This adds a calendar into Thunderbird and also adds support for understanding vCalendar events. More information can be found at Lightning's home page.

I installed the add-on and restarted Thunderbird and now the raw vCalendar email was transformed into a nicely formatted meeting invite - you even get the option to accept or decline the meeting. Just remember to right-click on the green "Install Now" button to download the add-on otherwise you will install it into firefox.

Thanks again Daniel!.

Technorati Tags: , , , , , , ,

Opening winmail.dat (TNEF) files in Thunderbird (on Ubuntu)

UPDATE: I have an improved version of the script available here.

I'm not going to repeat the many, many websites taking (and complaining) about Microsoft's proprietary e-mail attachment format called TNEF.

I'm assuming that if you are reading this then you have found that these fixes are not working for you (or not possible to enforce). I'll also assume that the LookOut Thunderbird Add-on by Aron Rubin is also not working correctly for you (this was my experience on Ubuntu Edgy Eft).

The best solution I could come up with was getting Thunderbird to run a script to unpack the winmail.dat extension into a folder on your Ubuntu desktop.

It relies on the tnef command-line program, so make sure that is installed first (it's bundled with Ubuntu):

sudo aptitude install tnef
Below is my little script, save it in a file called '' somewhere and make sure it's executable (chmod +x - or just download it here.


/usr/bin/tnef -C $LOCATION --save-body -f $1
Now find an email in Thunderbird with a winmail.dat attachment. Double click it and select to open it with the newly saved file:

Look on your desktop - there should be a 'winmail.dat' directory with the full contents of the attachment.

Double-clicking on any future winmail.dat file will result in the contents of the attachment to also be added to that directory.

Technorati Tags: , , , ,

How to stop schema.rb from being generated when running Rails Migrations

A couple of days ago I blogged about why rails migrations caused the database schema to be dumped into schema.rb. I've now found a way to stop it from happening without changing the schema_type or modifying any core Rails or Rake classes.

What I planned to do was override the db:migrate rake task to do the same as the default one bar the schema dump. My first attempt failed as it appears that rake will allow more than one task to have the same name, it runs then one after the other. The result of this was some strange migrations plus the delay due to dumping the schema!

After a little googling I found an excellent post on Matthew Bass's blog entitled Overriding existing Rake tasks. This described a similar situation and I've based my code on his advice.

I needed to delete the existing db:migrate task before adding my new one. You can't just call delete task on the Rake::Application class (there's no such method) so Matthew's suggestion was to add a delete_task method to the Rake::TaskManager module (that has access to the tasks) and then call this method before we define our new db:migrate task. The finished script is given below:

# add a delete_task method to the TaskManager and delete db:migrate
Rake::TaskManager.class_eval do
def delete_task(task_name)


# define a new db:migrate that did the same as the old one bar the schema dump
namespace :db do
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x, don't run db:schema:dump at the end."

task :migrate => :environment do
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
Technorati Tags: , , , , ,

Why do Rails Migrations cause the database schema to be dumped into schema.rb?

Have you ever wondered why rake db:migrate took so long to complete when you ran a simple migration script? The reason is that it's dumping your database's entire schema into db/schema.rb just like rake db:schema:dump does.

I had to get to the bottom of why this was happening and searching the internet was not providing any answers, so I took to searching the Rails codebase to see if I could find any clues.

databases.rake in /usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/ showed the root cause:

namespace :db do
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
If the 'schema_format' is set to':ruby' then run the rake task 'db:schema:dump' after we have finished running the migrations. But where is schema_format set? A look in config/environment.rb gave a clue:
  # Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
This configuration value is commented out and indicates that if this is enabled then the schema dumps will be in SQL format rather than the more portable (and in my mind preferable) Ruby format.

base.rb in /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/ gave the final clue:
    # Specifies the format to use when dumping the database schema with Rails'
# Rakefile. If :sql, the schema is dumped as (potentially database-
# specific) SQL statements. If :ruby, the schema is dumped as an
# ActiveRecord::Schema file which can be loaded into any database that
# supports migrations. Use :ruby if you want to have different database
# adapters for, e.g., your development and test environments.
cattr_accessor :schema_format , :instance_writer => false
@@schema_format = :ruby
So base.rb sets the schema_format variable to be ruby and therefore enables the automatic dumping of the schema after every migration.

Now I just have to figure out how to disable it...

Update: I've figured out a way to disable schema.rb from being generated.

Technorati Tags: , , , , ,

Undefined 'define_a_column' method when using Rail's Oracle OCI adapter?

One of the first hurdles I ran into when I started with Rails migrations was:

undefined method define_a_column' for class OCI8::Cursor'

It means that your LD_LIBRARY_PATH environment variable does not include the Oracle client binaries.

(I got my clue on how to solve this issue from this old defect ticket on the Rails Trac).

Technorati Tags: , , , ,

Where's dos2unix? In Ubuntu's tofrodos package!

I had a strange error recently to do with a bash script not running correctly. I couldn't see anything wrong with the file until I noticed that VIM was reporting that the file's type was DOS.

What I needed was to convert the downloaded file to UNIX file format using dos2unix but which package does it live in? A quick search of the Ubuntu packages database revealed tofrodos:

Converts DOS <-> Unix text files, alias tofromdos

DOS text files traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters while Unix text files traditionally have LFs (line feeds) to terminate each line.

Tofrodos comprises one program, "fromdos" alias "todos", which converts text files to and from these formats. Use "fromdos" to convert DOS text files to the Unix format, and "todos" to convert Unix text files to the DOS format.

This functionality is also available via the dos2unix/unix2dos symlinks.
To install it run:
sudo aptitude install tofrodos
And then use dos2unix and unix2dos to convert the file between the two different formats.

Technorati Tags: , , ,