Month: August 2009

Cadbury goes Fair Trade!

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

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”.

Update: For those still finding this after the end of 2011, I should point out that I have been regularly updating this calendar as new dates are added to the government website, and will continue to do so whenever I think to check.

Additional Note: The best way to use these links is not to download the files themselves, but to right-click and copy the URL. Then in Lightning, or Google Calendar, or whatever other calendar you use, find the option to set up a new calendar and paste in the URL (calendar type is “iCal” if it can’t guess). That way, when I update the files (generally once a year to add the next year’s dates, but occasionally to fix a typo), it will update like any other shared calendar.

The Case for a better Switch

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?

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