rwec.co.uk

Rowan's World, Et Cetera

The Non-Semantic Web: A blog entry is not a database

by Rowan - January 31st, 2010

There has long been a hope – an expectation, even – that the Web will somehow develop into something “smart”; that it will move from being a mere store-house of information to something that will actually “know the answers”.

But the vision tends to overlook the nature of both computers and humans. On the one hand, humans have a limited memory, and a flawed ability to apply consistent logic; on the other hand, we have abilities at creatively interpreting knowledge and ideas that are far beyond the capacity of any computer so far designed.

Continue reading »

Atomic Translations – Part 2 – Translated Text as a Data Type in PostgreSQL

by Rowan - December 12th, 2009

[Part 1: Database i18n as a Data Type Problem | Prototype Postgres Library]

In my last post (longer ago than I intended), I discussed the approaches I’ve come across to adding i18n to a database schema, and outlined my theory that the whole problem could be recast as one of data types. In order to explore how this would work in practice, I’ve put together a prototype “library” using only a standard install of PostgreSQL that shows how simple it could be, and why it makes sense.

Continue reading »

Atomic Translations – Part 1 – Database i18n as a Data Type Problem

by Rowan - November 23rd, 2009

[Part 2: Translated Text as a Data Type in PostgreSQL | Prototype Postgres Library]

The most obvious task when making any application multi-lingual is to make the UI translatable; there are absolutely tons of options for this, libraries in all sorts of languages, recipes, discussions, etc. But for many applications there’s another task, just as important, which is taking a database, and allowing someone to translate the data inside that.

There are various approaches to “database i18n” too – generally involving re-designing your schema in such a way that the translations are to some extent part of the “normalised” data. But these tend to make the schema somewhat unwieldy, and writing ad hoc queries and reports becomes tricky. So it occurred to me that if you treat i18n not as a schema problem, but as a data type problem, you could save some of that pain.

Continue reading »

A script for rotating digital camera videos!

by Rowan - September 20th, 2009

A while ago, after flickr launched the ability to upload “long photos”, I shot a clip of waves crashing on the beach, and wanted to share it. But there was a catch: being taken on a compact camera, it felt perfectly natural to turn it upright, and shoot the video in a “portrait” orientation. So, like a lot of my photos, it needed turning 90° clockwise – but unlike a photo, there was no obvious way to do this.

I hunted around at the time, and found that while plenty of players can transform video during playback (my copy of VLC seems to have got stuck, and now rotates everything!), few video editing tools could save a rotated video. I finally managed it with a power-utility which required me to import the video, tweak a large number of output options I didn’t understand, and hope the result wasn’t too mangled. Hardly ideal.

But while reading up on it, I discovered that most digital cameras – including my Casio Ezilim EX-Z1050 – shoot videos in a format called “Motion JPEG” or “MJPEG”, which is basically a bunch of JPEG pictures stuck together. So if I could extract the images from the video, they should be easy to rotate, and all I’d need to do was stick them together again…

Well, yesterday I was playing with lossless image rotation using jpegtran, and then managed to find MJPEG tools – a bunch of commandline tools for manipulating MJPEG data, actually designed for video capture utilities. And guess what? It works! I can split the AVI file from my camera into a bunch of JPEGs, rotate them, and stitch them back together, with minimal loss of quality!

Oddly, the biggest sticking point was sound – the mjpegtools utilities can’t see the sound stream in my source files. In fact, the only utility I could was FFmpeg, which at over 10 times the size of all the other tools put together is like the proverbial sledgehammer to the sound streams nut.

So, with my meagre Windows batch-scripting skills, I’ve put together something which might, just about, be useful, and called it VidRotate. Go forth, download! But beware – I make absolutely no guarantee that it won’t blow your computer up at this stage…

Channel Zero

by Rowan - September 6th, 2009

A couple of years ago, when IMP (“what later turned out to be the BBC iPlayer”) was still in closed previews, and I started building my over-complicated watch-PC-on-TV setup, I formed the opinion that the future of TV was not “Digital”, it was “Internet-based”. An article in Saturday’s Grauniad suggests that things are still heading in that direction, and reminded me of my prediction that the “channel” as we know it will not be with us much longer.

Continue reading »

Cadbury goes Fair Trade!

by Rowan - August 24th, 2009

I’ve always felt that the real mark of success for Fairtrade, and particularly Fairtrade chocolate, would be if an existing and successful brand was “converted” to Fairtrade – mainly so that the product would be a great chocolate bar first, and Fairtrade as it happens. But I wasn’t going to hold my breath in this age of Capitalism Supreme.

So I was pleasantly surprised when I walked into my local Co-op on Saturday, and saw a bar of Cadbury’s Dairy Milk bearing the Fairtrade logo! Continue reading »

iCalendar for English Bank Holidays

by Rowan - August 10th, 2009

I’ve been making increasing use of Lightning (backed onto Google Calendar) recently, for both work and personal use, and being able to see bank holidays in my calendar would be very handy. But for some reason, all I can ever find is calendars for “UK Holidays”, which are pretty useless – for one thing, not all parts of the UK have the same bank holidays, and for another, they tend to include random events like Saints’ Days which aren’t “holidays” in the sense of a day off work!

So I decided to make my own calendar, showing bank holidays, in England, and nothing else. And, just for the sake of it (and because there was a very nice-looking library available), I wrote my first ever Ruby script to generate the iCal file for it! A seasoned Ruby coder will probably look at it and laugh, but hey, it works!

The dates are based on this government website, which currently has data up to 2011. The resulting files should work fine in Lightning, and as imports to Google Calendar, so feel free to “subscribe”.

The Case for a better Switch

by Rowan - August 8th, 2009

The C-style switch-case construct – used in various programming languages, including PHP – is a curious beast. Most commonly used as a streamlined form of if-elseif-else, it actually has more in common with the oldest of control statements, the goto, since control jumps to the first match and carries on until you tell it to stop.

Firstly, am I the only person in the world who thinks that the break should be indented to the same level as the case, not the level of the commands between? If you are using it as a series of separate elseif blocks, then surely the two form a matching pair, with the code block “enclosed” within them. Of course, you can generally break early inside the code, just like you can return early from a function, which is hard to make stand out – but that’s just an argument not to do it too often!

And, of course, the fact that another case comes along does not mean that the code won’t carry on. Which brings me neatly to my next thought: is there any language that insists you declare when you’re falling through to the next case – and if not, why not? What if every time you put a case, you had to end it with either a break or a continue? It seems to me it would prevent a lot of bugs caused by cases inadvertently falling through and running completely the wrong code. And if overloading an existing term like continue is too confusing, lets just have a fallthrough – anyone got a case against? [No pun intended; probably...]

New Mozart, Old Hat?

by Rowan - August 4th, 2009

So, apparently 2 “new” pieces of music by Mozart have been “discovered”. Is this the latest case of “I was looking in my attic and guess what I found…”? Well, no – the attic in question was the archive of something called the “Mozarteum Foundation“, and they knew they were there all along. But now that they’ve decided they were by Wolfgang Amadeus Mozart (and not, say, his Dad), suddenly they’re really interesting.

Now, I’m not saying they’re rubbish, but isn’t this a bit like saying “It may just be a doodle on a napkin, but I’ve just discovered it’s Picasso’s doodle on a napkin, which makes it Important”? Or, contarily, “I’ve had this great painting for years, but I didn’t know who it was by, so I didn’t put it on my wall…” Either it’s good music, in which case it should be performed regularly whoever it’s by, or it’s not, in which case it’s of interest only to music historians. Continue reading »

Watching Le Tour on ITV. Or trying to.

by Rowan - July 5th, 2009

I’m a bit of an annual cycling fan – that is, I get really into the Tour de France every summer, and barely follow the sport at all the rest of the year. It’s a bit like only watching Tennis when Wimbledon’s on, or football when it’s the World Cup. Which, come to think of it, I do a bit too – but not as regularly.

Now, part of this is because the Tour de France is the only professional cycling race that’s generally covered on “mainstream” TV – I’ve never had the “luxury” of Eurosport. A few years ago, even that was in doubt, with Channel 4 suddenly dumping the rights, and ITV rather half-heartedly taking them over. Which brings me to this year’s “good news, bad news” story.