NotImplementedError Must Have Battered Wife Syndrome

I’ve been doing something very wrong my whole life.  I think it’s time to confess and seek help.

You see, like so many developers I see the NotImplementedError class in various languages and think, to my self “I haven’t had a chance to fully implement this class, so in my methods that my colleagues call that I didn’t finish yet, I will raise that exception to let them know.”

I am ashamed of myself.  And it’s time to get help.

You see the actual purpose of the NotImplementedError (as defined by the Ruby docs) is:

Raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception if the underlying operating system or Ruby runtime does not support them.

ERMERGERD!  I am a terrible person. Abusing this error class just because  my sub classes cannot meet the contractual obligation of the super class.

And I know I am not alone.

So whats the best practice, then?

Well, in Ruby’s case it turns out the answer is super simple; don’t raise an error at all! Instead, document the expectation and if a subclass fails to meet it a NameError, or often its subclass NoMethodError, will be raised automatically.

 

Converting TEXT columns to JSONB in PostgreSQL

Recently I had a text field being used to store JSON data from my web application. I hadn’t yet discovered the amazingness of the PostgreSQL JSONB datatype.

JSONB is an amazing datatype because Postgres understands how to query the structure and the keys and values can be indexed.

So if you have a text fields you want to convert to JSONB (provided the existing data is in properly formed JSON already) You can change the datatype and convert the existing data using this simple SQL command:

alter table tbl_name alter column col_name type jsonb using col_name::JSON;

You may be inclined to covert the text using the to_json function like: ‘USING to_json(col_name);’ – BUT DON’T DO THAT! What happens with that is you get a single string encapsulating the valid JSON, containing your JSON. Effectively a double-encoding bug.  The former (casting the column to JSON is the correct way).

Playing Day of the Tentacle…Again (with ScummVM)

UPDATE: There is literally no reason anyone should or would do this anymore, since Double Fine already HD remastered this classic! Go buy it – NOW – http://store.steampowered.com/app/388210/


One of my favourite teenage memories is that of playing Day of the Tentacle on my old 386 PC. I still remember how much the art and animation (quite excellent for it’s day) impacted on me; and even at today’s standards I feel warm affection whenever I see old screen-shots of the LucasArts classic point-and-click adventure game.  Others prefer others, such as Monkey Island or the Original Sam & Max, but for me, the pinnacle of adventure game goodness was the time traveling story of how the 3 protagonists (Bernard, Hoagie, and Laverne) stop (evil) Purple Tentacle from taking over the world and enslaving humanity.

I’ve been wanting to replay this game for over a decade, but as operating systems advanced, it seemed like short of a re-make my wishes were likely to remain a fantasy.  Until I discovered ScummVM.  From the ScummVM website:

ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed!

ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, …), many of Sierra’s AGI and SCI games (such as King’s Quest 1-6, Space Quest 1-5, …), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment’s children’s SCUMM games (including Freddi Fish and Putt Putt games) and many more.

You can find a full list with details on which games are supported and how well on the compatibility page. ScummVM is continually improving, so check back often. Among the systems on which you can play those games are Windows, Linux, Mac OS X, Dreamcast, PocketPC, PalmOS, AmigaOS, BeOS, OS/2, PSP, PS2, SymbianOS and many more…

But hands down the BEST news about this is that the ScummVM has binaries available to run on virtually every OS you can imagine (except iOS obviously, or at least, not to my knowledge) and the original DOS versions of all these original adventure games seems to run on any platform.  I’ve only tested this with Day of the Tentacle, but sure enough an ISO of the original DOS game, was simply copied to a folder on my Mac, and the ‘DOTT’ directory in that folder selected as the game folder for ScummVM which detected the game and added it to a list.  Form there, I just selected Day of the Tentacle from the list and hit ‘play’ – which launched right into the game, with sound and everything.

I did the same thing on my kids Windows 7 PC’s and it worked well, although I found that I needed to turn the subtitles and voices on, because the speech audio sample-rate is very low and occasionally difficult to understand.  But then the game is 18 years old and under 300Mb. The menu can be accessed in-game by pressing the F5 key, and the game paused with the space bar.

Other than that, its still as good as the day it was released and hopefully ScummVM will get me through my itch for this classic long enough until a possible remake comes along.  Let’s hope the rumors of a Telltale remake are true!

 

Users Manual for an LG Split System Air-Conditioner (LST243H-2)

When we moved into our house 5 years ago, the previous owners had installed a LG Split System Air-Conditioner (LST243H-2) but had failed to leave the users manual behind. Through trial and error we eventually discovered the important features (a.k.a how to turn the damned thing on) but there was a whole bunch of modes for which we simply couldn’t fathom. The remote control had very little text, and more hieroglyphics than an Egyptian Tomb. It never occurred to me before to Google the model number until today.

Sure enough, I found a PDF version of the users manual for a LG LST243H-2. Woot!

Explore the Twitterverse with Mentionmap

I’ve just stumbled across a neat little web application which allows you to visually explore your Twitter network. It allows you to discover which people interact the most and what they’re talking about, as well as traverse the Twitter-verse and finds links to people you might otherwise not have found. Think “six degrees of separation” for your Twitter followers.

The visualization runs right in your browser and displays data from the Twitter API.  According to the maker, Asterisq, it works like this:

Mentionmap loads each user’s Twitter status updates (tweets) and finds the people and hashtags they talked about the most. The data is displayed using Constellation Framework, a graph visualization library for Actionscript.

In this data visualization, mentions become connections and discussions between multiple users emerge as clusters.

Clicking a user will display their network of mentions as well as details from their profile. You can also search for friends by typing their Twitter user-names into the search box.

Mentionmap - A Twitter Visualization

I think this visualization is really neat, and I’d really recommend you check it out and have a play.  I found it very interesting to see the relationships between the people I primarily converse with on Twitter.