11 December 2013

UFT8 in string literals using MySQL client over ssh

MySQL documentation ain't what it used to be; it took some experimenting to figure out how to get a utf string into my db from the command-line client interface.

The problem is that for some reason when I run mysql on my server through ssh, non-latin characters just get dropped. It might be an ssh config thing, you never know, but I explored the mysql avenue first.

Here's what I found. Suppose you want to update a field containing some non-ascii character, like "à", like this:

update events set timetable = 'de 10h à 12h' where id > 100000;

But after you paste this into your shell, the "à" is missing:

update events set timetable = 'de 10h  12h' where id > 100000;

And your data doesn't get updated the way you expect.

This is the mysql documentation on string literals: string-literals.html

And here's a handy utf8 lookup table: http://www.utf8-chartable.de/

And here's the solution:

update events set timetable = concat(_utf8'de 10h ', _utf8 0xC3A0, _utf8' 12h' where id > 100000);

To explain: _utf8 0xC3A0 gives you your "à", you concatenate that with the rest of your string and away you go. It's ugly, but it works, so stop complaining.

13 November 2013


Yo, my rubygems.org profile has just hit 10,000 downloads!

I'm guessing that 99% of these downloads are bots though ...

Although not entirely ... the gems at the bottom of the list are either very recent (rspec_numbering_formatter), or kinda utterly pointless (ageism). On average, older gems have more downloads. Top of the list is protopack, which is actually useful as a way to store objects as YAML for later resurrection, kind of like test fixtures, but in a production context, with liberal meta-data sprinkled on top. You would think that sepa would end up being most popular though, as it's made for a critical bit of business - preparing SEPA direct debits, using the ISO 20022 xml standard (also known as "pain.008.001", although all banking standards are a pain so in this case "pain" is banking shorthand for "payments initiation"). It's newer than protopack though, so time will tell.

One more piece of data: none of the corresponding github repositories have issues opened. There are several ways to interpret this:

  • an army of bots is dedicated to downloading my stuff and archiving for posterity it all over the internet, but they don't take any more interest beyond downloading
  • real people download my stuff, decide it's unusable, and run away fast
  • real people download my stuff, it fits their needs perfectly and is 100% defect-free, and they're using it happily

Please feel free to draw your own conclusions. Then colour them in.

03 October 2013

World Wide Web for sale (slightly used)

An EFF article reports that Tim Berners-Lee, director of W3C, the standards body that attempts to specify what web browsers do, approves the inclusion of DRM restrictions in a forthcoming HTML specification.

As the EFF article points out, this new direction is likely to damage the W3C's already less-than-stellar reputation as a respectable standards body. Which is a pity, because the web is a better place when we can all agree on interoperability standards.

Your web browser, whether on your laptop or on your phone, behind the scenes, is called a User Agent. This means it represents you, the "User", giving you much freedom in the way you experience the internet. With DRM restrictions built-in, your browser becomes a copyright-enforcement-agent, and you risk losing many of the freedoms you have enjoyed up to now. We are entering a terrifying new era where government itself is the enemy; DRM is a major piece of armour in favour of centralised power and against The People.

Disappointing, Mr. Berners-Lee. Perhaps it's time to resign and let Mr. Stallman take the helm?