Archive for the ‘Coding’ Category

PHP’s flexible variable typing makes determining a value to be empty… well, see for yourself. Check out this diff for the NotEmpty validator in Zend Framework.

That can’t be right, surely! ;)

Update: the unit tests reveal the intent behind the odd-looking code change. Now the validator can optionally be very specific about what is considered empty.

Last Sunday, after getting bored implementing error handling in the Ruby version of the food journal, I decided to take a stab at the ICFP 2009 Programming Contest. Although already finished, the problem is so intense and interesting that I had to try. My solution is written in the lovely functional language Haskell.

Today, I achieved a milestone. My program can load and execute the Orbit virtual machine, run a sequence of frames and reports a score of -1.0 when the controlled satellite’s fuel is exhausted.

Browse the code on GitHub. Remember, I’m still learning, so don’t expect anything miraculous!

Continue reading ‘Controlling Satellites With Haskell’ »

I’m not by any stretch of the imagination an early adopter of technology. Nor am I (mostly) an old stick-in-the-mud who thinks that all programming should be done in COBOL. I love new technology but prefer other people to work out the bugs and niggles before I can use them reliably as tools.

So it is with some pleasure that I’ve decided to take the plunge and begin studying the Ruby programming language. Ruby has been around for 15 years now so the foundations are solid. Many rave about its simplicity, utility and natural-looking syntax.

My goal is to learn the lanugage by porting an existing application (the food journal written in PHP that I recently used to play with Zend Framework) first to the Ruby language, then to the web application framework Rails.

As usual, I embark on this project by reading a manual!

Update 12-Jul-2009: Browse the code on Github
Continue reading ‘Playing With Ruby’ »

The Zend Framework is a long-established and well-respected set of libraries for building PHP web applications. I’ve not used it before and I’ve recently become interested in learning more about it so I’ve decided to have a play. Rather than start entirely from scratch, I’m going to re-use the database schema of a famous dive-logging web application and see how much effort is involved in re-implementing the basics; logging in and displaying a page of dives.

More importantly, how much fun is it to work with?

Update 12-Jul-2009: Browse the code on Github
Continue reading ‘Playing with Zend Framework’ »

Now my Ubuntu workstation, part-way upgraded to the 7.10 “Gutsy Gibbon” release, works almost as elegantly as my Windows machines have worked forever. My network music store now auto-mounts into my home directory when I login. Finally. I’ve been beating away at this, on and off, for bloody years. I’m just not a great sysadmin, I guess!

Method follows.

Continue reading ‘libpam-mount automounts SMB shares at login, just like Windows’ »

What could I do with this?


CREATE TABLE child (
  id BIGINT NOT NULL AUTO_NUMBER PRIMARY KEY
, parent_table VARCHAR(64) NOT NULL
, parent_id BIGINT NOT NULL
, FOREIGN KEY parent_table REFERENCES INFORMATION_SCHEMA.tables(name)
, FOREIGN KEY parent_id DEREFERENCES parent_table(id)
) ENGINE=fantasy COMMENT='Don\'t run this at home, folks!';

AND
Continue reading ‘(My)SQL Infection’ »

My friends know that I’m a bit of a political geek and like to keep abreast of what our elected representatives are doing, so I follow the Official Reports of the UK Parliaments with an almost religious fervour, although I’ve been a bit lazy recently and just been watching the BBC Parliament channel.

I’m also a huge fan of theyworkforyou.com, a volunteer-run website which republishes the Official Reports of the House of Commons, House of Lords and the Northern Ireland Assembly in a far friendlier form than the “official” sites, with the added bonus of public commentary and statistical analysis of the MP’s performance.

Missing from theyworkforyou.com is the Official Report of the Scottish Parliament, all the more sorely missing due to the now very interesting constitution of that body with its minority SNP government. Republishing an official record is no easy task, for a number of reasons that I’ll go into later, but I know for sure that I have all the requisite skills and tools to do it.

I’ve had this project on the back-burner for some months now and since I’m starting a new job soon, any spare time I might have to work on hobby projects is going to vanish.

So here I go. I don’t need to get it perfect – just far enough along so that someone else can pick up and complete the task.
Continue reading ‘Scraping the Scottish Parliament Official Record’ »

The following code works on Linux (3 rows returned) but not on Windows, which returns a SQL syntax error citing LIMIT "0", "3". See PHP bug 35801 closed as “bogus” by an idiot on Christmas Day 2005 for the bogus reason:

Limit statements cannot be part of prepared statements.

Anyone care to confirm?

Continue reading ‘Christmas Bogus Bogus PHP PDO Bug’ »

I logged my first dive for the third time today. I’ve paid £3.95 for one month in which time I can log as many dives, write as many stories and make as many changes as I please.

This post is password protected. To view it please enter your password below: