Blag o' dkam

p0wning tubez

Archive for October, 2007

Threading the Bookie

without comments

Bookie currently checks prices at 9 shops. When you view a new book or refresh the pricing, it checks each of those shops in sequence. A nice little optimisation is to check the shops in parallel. Threading in rails appears to be pretty straight forward — provided you clean up before the request-response cycle is complete.

Here’s the sequential version:

And the threaded version:

By default ActiveRecord doesn’t allow multiple threads to access its mysql connection, so you need to allow concurrency by adding the following line to your environment.rb file:

That last line in the example is used to close database connections which are no longer attached to a thread. You’d have thought that joining the thread would have closed it’s database connection, but there you go. Without this you’ll eventually exhaust your database connections.

Written by dkam

October 27th, 2007 at 3:00 pm

Rent or Buy?

without comments

blah adsklfj

Written by dkam

October 20th, 2007 at 11:54 pm

Posted in Geeky,Investment

Keith’s in the Age!

without comments

Check it — Keith made the Age. In Nangiloc, it’s on page 4 — but I didn’t find it in the edition we’ve got at work.

Written by dkam

October 18th, 2007 at 9:30 am

Posted in Family

Another Shop for Bookie

without comments

I’ve updated Bookie by adding another online Australian retailer, Fishpond. They seem to have good pricing on some books, and as a big plus, they have an Affiliate program which I’ve signed up for. I’ll get a cut on any books purchased via Fishpond, Amazon UK & Amazon US.

Adding Fishpond wasn’t as straight forward as the other stores. When searching for an ISBN, you can get multiple results, with different product ids and different prices. (According to their support guys, it’s because they give different product ids to books provided by different suppliers.) Just to make life difficult, the product id needed to generate Associate Links isn’t simply the ISBN. After a little bit of Hpricot work, I figured out how to grab all the data required to select the cheapest book ( if there’s multiple results ) and to generate Associate Links.

Written by dkam

October 13th, 2007 at 10:41 pm

Database migration

without comments

Lots of you have been noticing that “Bookie” craps out pretty frequently — turns out it’s due to SQLite3:

ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked: SELECT * FROM books WHERE (books.”isbn10” = ‘978-0596005696’) LIMIT 1):

Session data ( stored in the DB ) was a major culprit, but it looks like more than one concurrent user ( It happens! ) can cause this problem. SQLite’s homepage states that write operations lock the whole table, but since this should only take milliseconds, it shouldn’t be a problem.

I’ve migrated over to MySQL and performance feels much snappier. Maybe that’s just because I was hoping it’d be faster. With luck, bookie should be far more stable now.

Written by dkam

October 11th, 2007 at 9:48 pm

Farm with no water

without comments

Well, not quite yet. Currently my folks are on 16% of their water allocation. They normally require the full 100%. Avocados use a disproportionate amount of water, so they’re gone — bulldozed a few weeks ago. The Victorian government has known since at least 2001 that they’d over allocated the Murray’s water. They promised that it didn’t matter and that they’d manage the water so that they never ran out. Typical politicians.

So what can be done? In the short term, farmers with annual crops ( grasses and grain ) could be paid by the government to go without using their allocation, whilst permanent plantations citrus, avocados and vineyards receive their allocation. A year or two without water will do no harm to annual crops, but will kill off permanent plantations which take around 5 years after replanting to become productive.

Longer term solutions include government purchasing water rights ( at market rates ) from willing sellers. Replacing channels with pipes to reduce water wastage. Building dams.

Non of these solutions will be any help to the farmers who’ve relied on the Murray for water for the last 100 years.

Here we have some lovely green leafy avocado trees.

Here we have some dirt.

Written by dkam

October 8th, 2007 at 11:12 pm

Posted in Family,Politics,Water

Balanced Views

without comments

I saw this and thought it was funny:

Then I saw this, and also thought it was funny:

Written by dkam

October 8th, 2007 at 10:51 pm

Internet meetings

without comments

Written by dkam

October 8th, 2007 at 10:48 pm

Posted in Funny,Geeky

Chemical Brothers – The Salmon Dance

without comments

Such a cool song.

Written by dkam

October 5th, 2007 at 11:10 pm

Posted in Uncategorized

Watching the telly

without comments

We’re going to have some interesting ways to watch telly in the next few years. Video content is popping up everywhere now — the iPhone, Sony PS2, iPod Touch and iPod Video are pushing slowing into the mainstream — watching TV on the train on the way to work is not unusual now, and much more practical than whipping out your laptop. MythTV, Windows Media Centre and TiVO are growing slowly, bringing timeshifting into the mainstream. AppleTV brings ( or will bring ) shopping for TV shows and movies to the Telly.

And of course, BitTorrent is helping to sharing TV around.


Written by dkam

October 3rd, 2007 at 11:26 pm

Posted in Geeky,TV