Wednesday 26 December 2007

I don't rock!

Tanya got me Guitar Hero III for wii for chrissie!

While I love playing it it goes to show that:
  • I'm monodextrous
  • I lack rhythm
  • I have zero hand-eye co-ordination
But none of that stops me playing until the world feels like its moving upward when I look away from the screen. (anyone who's ever played it for an hour or two will know what I mean)

Tuesday 4 December 2007

Thunderbird Exchange IMAP Workaround

Just wanted to document somewhere the workaround for corrupted
attachments from Exchange IMAP servers.

Details are at:

https://bugzilla.mozilla.org/show_bug.cgi?id=92111

  • Go to Tools->Options or Edit->Preferences
  • Go to 'Advanced' Tab
  • Click 'Config Editor' button
  • Enter 'mail.server.server' as the filter
  • Browse through your servers until you find the one that is your Exchange
  • IMAP server. eg in my case it was 'server3'
  • Right-click in the table and add 'New->Boolean'
  • Enter the name mail.server.server<number>.fetch_by_chunks, and set it to
    'false' (eg i have mail.server.server3.fetch_by_chunks=false).

Done

Tuesday 27 November 2007

Best,... Concert,... Everrrr

Ok, I wasn't going to post about this given that Tanya already had, but it really was the most phenomenal concert. Take a look at these pics. There's only three of them, but the sound, the complexity of the music is just amazing. Its all done on either guitar, bass, drums, or piano, base, drums, but with all the pedals and foldbacks, and they way Matt's fingers move, its some of the most amazing music you'll ever hear. I still can't believe that the amazingly complex sounds cycling non-stop on my mp3 player (see here for proof - the weekly and overall stats especially) comes from out of just three guys, one of whom is a drummer!

And since we've seen it a few people we've mentioned it to have asked "who's Muse?". So right, now, go to sanity.com.au and buy their three previous albums for $9.99 each. The best $30 you will ever spend (well, on music). Trust me.

Friday 2 November 2007

Anti-Business

Everywhere I go I see the '70% of Labour front-bench are unionists' ads. Um, hello, its the Labour party.

What fascinates me is that the way the government is portraying it we should all be scared of the unions because,... um,..., because, well,... just because. Maybe something about militant unions 20 years ago. Its a scare campaign without a boogeyman.

Ah, but they do try a bit. 'Anti-business'. I'm sure a bunch of people see unions as evil (militant, obstructionist) and business as good (progressive, employment), but they probably wouldn't vote labour. And i'm sure a bunch of people see the unions as good (defend the little guy, anti-IR laws) and business as bad (greed, fat cats), but they probably wouldn't vote liberal.

Surely most people are ambivalent to both sides - unions do some good work, but get over aggressive and hold more power than they deserve - but, then business answers to money rather than people or best-interest of the country, even though we all need jobs and pay. It just seems like a rather pointless exercise to spend all this advertising on an ideological battle thats not shared by most of the swing-voting population.

Bring on Nov 24th so I don't have to wait for my disappointment.

Monday 2 July 2007

Culture of fear

This morning on Alexandra Ave, while stopped at the Smith Street traffic lights I saw in my rear-view mirror an ambulance trying to get through traffic stopped at the lights on the street before. People in the Ambo's lane were scattering to let it through until it got to the second car from the lights. They guy at the front wasn't moving, so the second guy couldn't get out of the way.

The way I see it there were three possible reasons for why:
(1) The guy didn't notice the big ambulance with flashing lights and sirens;
(2) The guy did notice it but chose maliciously not to get out of the way;
(3) The guy did notice but didn't want to go through the red-light-camera and have to somehow convince the powers that be that he did it for a good reason.

I know what I think is most likely.

Sunday 1 July 2007

has_many, :through (captain obvious)

You know how you would create a database to model a multiple relationship especially where each object is independent. eg Objects X and Y are modelled in tables X and Y, and the relationship between them is modelled by a table containing (key(X), key(Y)). So how to do this in Rails?

The documentation on join-associations, ie has_many :through, has the following example, but its missing some obvious details for the Rails-newbie who knows DB stuff, but doesn't know Rails.
  class Author < ActiveRecord::Base
has_many :authorships
has_many :books, :through => :authorships
end

class Authorship < ActiveRecord::Base
belongs_to :author
belongs_to :book
end
What's missing is the background stuff, how to get here, and what the DB needs to look like for this to work. The belongs_to association implies that the table associated with the object (eg Authorship) contains a foreign-key for that object. In this case the table "authorships" must have columns with foreign-keys for book and author. In the normal rails setup this means two columns called book_id and author_id.

So to get this example going head to your rails directory and run:
  ./script/generate model Authorship
./script/generate model Book
./script/generate model Author

You now have (among other things) 3 files in db/migrations called nnn_create_authorships (and book and author). The skeleton is already in place to create the "authorships" table. It needs the two foreign keys, so add them:
...
create_table :authorships do |t|
t.column :author_id, :integer # foreign key for author
t.column :book_id, :integer # foreign key for book
end
...
You can add any columns you want to the migration definitions for the other tables (names would be obvious) but bear in mind that there will (if you don't do anything special) be a hidden primary-key defined for each one as if you included the line:
  t.column :id, :integer
You don't need to add any external references to either the books or authors table.

To make these new tables take effect in the DB you use the db:migrate task. This allows you to move the databases between the different versions (this is the nnn_ prefix on the files in the db/migration directory). So use the command
  rake db:migrate
(you can choose any given version of your DB by appending VERSION=N to the line above - N corresponds to the nnn_prefix as above).

The belongs_to and has_many relationships are defined in app/models/authorship.rb (and author.rb, book.rb), so make them now. The has_many relationship in author will add a list called .books which hides all of the details of the join-relationship.

To see if any of this works its best to use the unit-tests for your model - eg with the example in test/units/author_test.rb. You should create fixtures for each model - these are sample data-sets that will be available for in your test-harnesses and development database, so go create some books, authors and authorships now. The generated fixtures will have the id: field, keep this, and remember you'll need this to fill in the authorship foreign-keys (book_id, author_id). Add values for the other fields (eg name of book,..).

To get our author_test working, and check the Author#books methods work we'll need the authorship and book data as well as author data. So add authorships and books to the fixtures list at the top of author_test.rb. If you don't do this you'll probably spend hours wondering why your tests fail, returning empty lists.

So create a quick test to verify everything is plumbed together properly, check that all of your test-data correctly fills out the lists as expected. Example test code:

# Test the books relationship works as expected using the test data defined in fixtures
def test_fixtures_books_relationship
author = Authors.find(1) # grab the author you defined with id: field of 1
assert author # ensure author was found

assert_equals 2, author.books.length # check the authorship connections
# you defined in your fixtures
book_names = ["Some book", "Another Book"]
author.books.each do |book|
assert book_names.find(book.name) # ensure that each of the books was
# one of the two expected
end
end
Run your test using:
  rake test:units

Captain Obvious

This is the first in a series of post on things that should probably be obvious, but for which the documentation on the web is useless if you don't know what you're doing. At least this way the answer should be somewhere on the web.

At the moment I'm playing with Ruby-on-rails a lot so most of the captain obvious stuff is going to be on that.

Saturday 23 June 2007

Ice?!?

Ok blogs are for ranting, among other things so here goes.

Ad on TV for "Disney's Finding Nemo on Ice". A fun filled frolick for the family. Ok I understand that kids like Nemo, but what's the fascination with ice??? Its a fish, if it were on ice it would be in a display cabinet in the fish-department of a supermarket. I understand live action, all singing all dancing, spectacular shows for the kiddies, but I just can't come up with any explanation for the "on ice bit".

Ice doesn't even exist in Australia, outside of petrol stations and (later) eskys.