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.

Watchout Folks, Dodgy Teachers Will "Get" You on Facebook (Apparently)

I’m sorry but things like THIS – really pisses me off!

TEACHERS have been banned from contacting students on Facebook, MySpace, YouTube and other social networking sites amid growing concern over inappropriate relationships.

There are so many reasons why this is wrong, that I’m not even really sure where to start. I am further infuriated by the comments on that article. Are these people serious? Really? Dodgy teachers engaging in inappropriate conduct with students, do not do so in open and transparent mediums. They’d actively disengage from these becasue they’d get caught! Dark and dodgy people cannot exist in the light. They run from it.

It’s funny how the general public demand the goverment to protect them and their children, despite having little or no understanding of social media (and technology more generally). They don’t understand the medium and they don’t understand the minds of those who would seek to target their children. Becasue if hey did, they’d understand that its a futile and pointless policy. Much like the proposed “clean feed”.

Grr….this kind of trivial, thoughtless, primitive thinking really makes me mental!

Plans of the Taylor House (from "Home Improvement")

I have recently been watching re-runs of the 90’s sitcom “Home Improvement” and I think the design of the Taylor’s house is just perfect.  After some googling, I stumbled across this site, which among other things had a plan of the ground floor and (modified) basement of Tim the Tool-man’s house.  I grabbed the downloads and posted them here (in case that site ever goes down).

combined_plan

I created here (hosted as a mirror to the original here and here).

Connecting to Postgres Through a SSH Connection

Production level servers can be tricky.  Mostly because of the inherent, increased security needed to protect online (and exposed?) assets.  Our Postgres server is one such asset.

But opening the necessary ports to allow access to the database server (for maintenance) can expose the server to possible attack.  Fortunately, if your Postgres server is on a UNIX or Linux based machine with SSH installed, you can forward the Postgres port through the SSH tunnel.

ssh -L 1234:localhost:5432 username@server.dns.addressorip.com

In PGAdmin, simply connect to localhost:1234, and you will connect to the production server through the SSH connection without the need to open a port on the external firewall.

Freed Student Uses Twitter to Demand Translator's Release

So we have some good news and  some bad news.  First, (the bad) is that Twitter still doesn’t have a monetization strategy, but on the plus side, CNN claims it has given one American Student the ability to force the Egyptian Authorities to release his translator from prison.

James Karl Buck was released from a Mahalla jail after sending a one-word blog post from his cell phone through the Twitter Web site. The message — “Arrested” — alerted all of his friends on the site of his detention.

When his college found out about the situation, they hired a lawyer who then got him out of prison. Now that he’s a free man, Buck is using his Twitter network (611 followers as of writing) to help free his friend Mohammed Maree.

Apparently, by uttilizing the massive network effects of social media, he was able to build public pressure, eventually to demand Maree’s release. He used everything from Twitter updates, blog posts on his own Web site to an electronic petition signed by more than 900 people.

As I have always said, the amazing thing happening with social media (and microblogging sites in particular) is soon going to be the most powerful lobby group in the world.  Ever.

Governments and Enterprises are going to have to realise that you can’t ingore the social media space, because of the devistating network effect poor public relations can have, with a very large group of highly motivated and highly coordinated social networks.  In the Chinese Earthquakes this year in fact, much of the relief and recovery was coordinated over Twitter.

With even more mainstream users comming onto sites such as Facebook and Twitter, this new “lobby group” will only increase in power and effectiveness.