Gavin Panella

Archive for the ‘Computing’ Category

Twitter API encoding is somewhat bonkers

without comments

Take a look at the Encoding section in the Twitter API docs:

The Twitter API supports UTF-8 encoding. Please note that angle brackets (”<” and “>”) are entity-encoded to prevent Cross-Site Scripting attacks for web-embedded consumers of JSON API output. The resulting encoded entities do count towards the 140 character limit.

Does anyone notice the weirdness there? Apart from the MAGIC_QUOTES smell.

If I were feeling pathological, I could tweet a message of 140 characters all between the Unicode code-points U+010000-U+10FFFF. I think that would end up as 560 bytes. And I think that would be all fine with Twitter. Which is another way of saying that Twitter would, I assume, be happy to exceed 140 bytes for a message if it were written in, say, Japanese.

By contrast, while on my pathological holiday from good sense, I would only be able to tweet a message of 35 angle brackets – hence 140 characters, 140 bytes in UTF-8 – because the encoded angle-brackets count toward the number of characters. Seems a bit backwards doesn’t it?

Does anyone know the reasoning here? Or are the docs at fault?

Back to the angle-bracket quoting. Just as the PHP folk are finally ending their own embarrassing journey through that silliness, it looks to me like Twitter are now making a similar mistake. JSON should safely encapsulate angle-brackets, so perhaps I don’t understand the problem that they are trying to solve?

One more question: what if I tweet “&gt;”? When using the API, can that be distinguished from a “>”?

(You might have noticed that I’ve have so far been too lazy to experiment with all this stuff; I just wanted to write it down before I forgot. I’ll add a comment if I get the time to play.)

Written by Gavin Panella

December 18th, 2008 at 3:57 pm

Posted in Computing

Tagged with ,

Mac OS X, I’m going to kill you!

with 3 comments

Farking hell, Mac OS X is really annoying me now. This, in case you hadn’t guessed already, is going to be a vitriolic rant, and is really for my own benefit rather than yours. But please read on anyway…

Read the rest of this entry »

Written by Gavin Panella

July 18th, 2008 at 6:40 pm

Posted in Computing

Tagged with , ,

Shell FTW!

without comments

Ha, do this with a GUI:

lsof -p $(ps ux | egrep [/]opt/local | awk '{print $2}' | xargs | sed 's/ /,/g') | fgrep opt/local | awk '{print $9}' | sort -u | xargs port provides | sed 's/.*: //' | sort -u | xargs port -f upgrade

The command line rules!

Read the rest of this entry »

Written by Gavin Panella

September 3rd, 2007 at 9:05 am

Disable Java

without comments

A few weeks ago I disabled Java in every browser I use. No more applets. It feels liberating. Flash might be next.

Read the rest of this entry »

Written by Gavin Panella

July 31st, 2007 at 4:59 pm

Convert all your Apple Lossless files to FLAC

without comments

I’ve written a Python script that converts audio files from Apple Lossless (.m4a) to FLAC (.flac) format. Crucially, it copies meta-data, with the exception of the cover art (for now at least).

Read the rest of this entry »

Written by Gavin Panella

February 2nd, 2007 at 10:10 pm