I blog when I go abroad, and occasionally when I do stuff in the UK too. There's a nicer interface over here.

Thursday, June 25, 2009

Heathrow to Suvarnabhumi

Went to the gate as soon as it was announced. As with the rest of T3, it was a zoo, this time full of teenagers or young twentysomethings all off to, as far as I could tell, Thailand. Not really surprising I guess, given the airline and destination: Thai Airways flight TG917 London Heathrow to Bangkok Suvarnabhumi.

The best thing, in fact the only good thing, about getting to the gate early, is that they did early boarding for Royal First, Royal Silk, and people with gold cards. Business class is Royal Silk, and that's what I was booked in, thanks to having forked out ~£500 and half the miles I'd spent the best part of 3 years accruing with BMI. I always feel privileged and lucky to fly in such comfort, but yesterday this feeling was topped up with a significantly high amount of snobbish fuck-me-glad-I'm-not-in-the-same-cabin-as-those-fuckers. Early boarding gave me the opportunity to stride past them with a huge sense of superiority (or, OK, shuffle past them, a little put out by all the "why's he going up when they've called the posh people only?" stares I was getting). Either way: win.

Upstairs on a 747 is so cosy. Every time I've been there (once with Cathay Pacific, a few times with BA, and now once with Thai) I've loved it. It's kind of better than business class because it's such a private cabin, in which you never see anyone else. I felt out of place. Not in a I-don't-belong-here kind of way -- I got over that ages ago -- but more in an "oh, everyone else is Thai, and the staff are speaking Thai, and in fact the staff and the punters all seem to recognise one another" kind of way. I think there were only 2 non-Thais, me included, amongst the 26 passengers. Eek! So there's no reason why this should really have surprised me at all, it just felt more ... foreign, than, say, Singapore Airlines or Cathay Pacific.

I certainly didn't see what was so funny about the guy dishing out champagne having a Chinese name, but it caused semi-uproar among some passengers.

My bag didn't fit in the overhead compartment. I blame Jeremy Kyle. In fact it almost didn't fit in the one between the seat and the window either, and JK had to come out so I could squash it in. In the compartment behind that one I spotted 3 huge Boeing 747 Schematics manuals. Ace.

Aircon was either off or broken. It was sweltering. I had a couple of orange juices and a very cold hot towel (which also happened at the end of the flight) and settled down to check out the entertainment magazine. Unfortunately mine only had the cover, not the actual pages. Oh well.

The entertainment system -- including the giant projector screen at the front of the cabin -- was stuck in soothing music and map display mode while everyone boarded. Much better map than on BA, including the 3D pilot view of win (though, sadly, not an actual camera out from the cockpit). And while I had to make sure my seat remained upright with my footrest folded yadda yadda yadda for take-off, I availed myself of the in-seat massage button. It lasted AGES. I'm sure someone else I flew with in 2006 has a similar thing. Cathay? Qantas? Someone in that part of the world.

The headphones Thai give out are SHIT. Really really bad. I had to have the volume at maximum to have any chance of hearing all the dialogue in Frost/Nixon; after half hour or so I gave up and plugged my own in, and the difference was astonishing. It's only a pair of £30 noise-isolating JBL things, but bloody hell. I turned the volume down to almost the minimum from then on!

Frost/Nixon itself was preceded by a short video about wellbeing in the air. All that stretch your legs, roll your neck, draw circles with your ankles, etc etc stuff. Presented by a wacky cartoon character called STAN THE EXERCISE MAN. A real "what the fuck?" moment, that -- but not as bad as the laughable dubbing in the film itself, where Kevin Bacon clearly says "fuck" or some other disgraceful curse. What I heard was someone completely different, about an octave higher, say "If you cheat us on the 60 per-cent" before KB took over the rest of the sentence. AWFUL.

Didn't see all the film. Fell asleep. Saw the ending, not sure how much I missed though, I think about half hour. A combination of being really tired, not having had much Diet Coke, and the Thai business class seat being preposterously comfortable meant I actually, for the first time ever, didn't see a complete film on a long-haul flight. I tried to watch Anchorman -- which the system said is 191 minutes long, really!? -- and fell asleep half hour in, waking up as it was finishing... so I started it again, and did exactly the same thing. FAIL. Or alternatively, win, since sleep is actually what you're meant to do.

Ah yes, the seat. It goes flat, but not 180 degrees, so there's a real sliding-forwards danger. I avoided that. It also felt comfortably wider than BA's business class seat. I could look up the actual seat pitch etc, but instead I'm going to go "yay, I'm smaller than I used to be!", or something.

At about 7am UK time, I felt a buzzing in my pocket. It was my phone's alarm going off. Oops. By "my phone", I mean the second handset I've brought with me, having bought a Vodafone SIM just before so I can do texts and calls in Australia for a pittance. At home it had been sitting on the side with its battery out, but now that it's back in it remembered there was an alarm set... and it wasn't on silent mode. Thankfully I caught it before, as far as I could tell, anyone else noticed. Though they may have noticed the fat western bloke flinching like crazy and playing with a mobile phone. The upside of this incident was that, well, it woke me up, around 5 minutes before the crew were going to anyway: it was time to serve the pre-descending-into-Bangkok meal.

I've turned the alarm off now.

The cabin crew were wearing different uniforms when serving breakfast. What the hell? Seems like a lot of effort to go to. Sure you might want to change into something fresh, but something actually different? Nice touch I guess.

When the staff were making an announcement, the monitor said PA IN PROGRESS. Without much of a gap between PA and IN. My leg's fine, ta.

Wednesday, June 24, 2009

Surbiton to Heathrow

My cab turned up on time. The driver even knocked on the door! Nice bloke, drove a strange route but got me there quickly enough. Heathrow T3 is a fucking ZOO, and strange things were afoot at entrance D -- people just wandering up and going in, but one special queue for one airline in particular, not sure which. Maybe Etihad?

Anyway it's a horrible, shabby terminal. I checked in at the Thai business desks which used to be the Singapore Airlines desks -- I know because Ruth checked in there last year. I'd already done it online, with baggage, all the way to Australia, despite the website telling me last night I hadn't done the second leg.

The first security question I was asked was "have I asked you the security questions?". Nice. Got directed to Lounge B near gate 11 after the formalities were over. She'd said "You know where the lounge is?" to the bloke in front of me, but not to me, just straight out with the directions. Possibly he had status with Thai Airways on his boarding pass, but more likely he looked the part while I don't. BASTARDS.

Up to departures and another scrum. Fast track was merely faster track. In 2006 I had this down pat -- all metal out, shoes off, laptop out, straight through, bingo. These days I'm clumsy and stupid: dropped me laptop, prepared to take shoes off without noticing that no-one else was doing it (ie, we didn't have to), and I left the m2-to-USB-stick adapter in my pocket which set the bloody alarm off. Grr. Tiny little thing had to go through separately again while I was putting my belt back on.

Sent a message to twitter (and therefore Facebook) before I even got the lounge. As if anyone expected anything different.

This lounge has self-service beer -- like all* business lounges. Better yet, this lounge has self-service beer taps. I've been in one like that before, the AAdmirals Club in Tokyo Narita. That was better, in that I was allowed a beer when I was there. But I'm on antibiotics now and being a good boy. Bah.

Cold food. The little potatoes of varying colours in the potato salad are olives. And we have to eat with plastic fucking cutlery! At least there are cheeses. Diet Coke from a tap, not mixer-size cans, is an improvement over many lounges. My laptop still works (for now?). Despite epic extra emergency expense of last few weeks (sparky, health treatment, € exchange rate at Hellfest) a tiny part of me was hoping it was broken, as an excuse to buy a VAT-less new Macbook Pro in Dixons Tax Free. But that would have been financial suicide: I don't have a job, nor the means with which to live without one for longer than a couple of months. Less, if I'd bought one. This thing'll have to do until I get a job offer.

Yesterday the doc said "not ideally" when I asked if I can have a drink while on these thrush pills. That's not an outright refusal, right? And she at least said I could have one or two on my birthday. Would it be really bad if I had one or two between now and then? Possibly. It is, frankly, stupid to chance it. I have shit skin and a skin issue for which I am being medicated. Best carry on being the good boy.

Best go. Laptop says 19 minutes of battery life left, and history tells me it means I WILL DIE ANY SECOND AND YOU WILL LOSE EVERYTHING YOU'VE WRITTEN. Forgot the plane-socket-adapter too, so this is it 'til Bangkok probably. Oh well. Maybe I'll go have a dri...FUCK IT.

Friday, June 12, 2009

Doing shit offline

I was just thinking it was cool that I'm already the 3rd hit, at the time of writing, for "do shit offline" when searching on Google. But then I snapped out of it. Yes, my generation game post yesterday was about websites, but not all software engineering is about the web. The stuff I bang on about needn't spit out HTML or PHP or anything of the sort. I have an mp3-fixer-upper (mentioned below) which spits out a shell script. That's because these are just software engineering techniques (patterns, if you will) for generating lots of similarly structured output from minimal input: lots of unique data, but comparatively few templates.

I work as a software engineer whose career has mostly led him to working with websites; I do not work as a web developer. And despite currently being on the dole, I figured I might as well pimp some software that helps with doing shit offline, huh. These are 2 projects I've been intimately involved with as both developer and user.


Yahoo!'s r3 is ostensibly an internationalisation/localisation tool, but to my mind its real power comes from the fairly complex, at first glance, inheritance path concept. This brings object-oriented techniques to file generation, and there's the key word: r3 is first and foremost a file generation tool. In go templates, out come files.

I was one of the core engineers on the team which developed and maintained r3's predecessors, which were internal CMS tools at Yahoo!. I had fairly heavy involvement in some of the architectural and design discussions and decisions made during r3's genesis, and was the sole internal customer representative at the team's first "next steps" planning etc session 18 months later. I'm quite a fan, even if the public docs aren't quite up to scratch.


This is something I knocked up in Python in the last couple of months. I even blogged about it before. So much for "don't repeat yourself", huh? It's a simple script which marries YAML to a template, and creates some output. The output can be STDOUT or a file, and 4 template engines (of sorts) are supported. It's meant to be standalone, but deliberately usable as the central pivot of a get-some-data, produce-some-output, put-it-somewhere pipeline. In fact, when used this way you don't even need YAML - just a couple of python dictionaries. See my mp3-fixer-upper for an example of how.

Thursday, June 11, 2009

The Generation Game

Let me tell you a story (or "lie", if you prefer). In 3 acts.

Act 1

I live on a roundabout. Like that bloke who lived on a roundabout, or the fella from Parliament Square. And I'm famous. People come up to the roundabout from one of the 5 roads, and before they make their way round it they ask me my name. But I'm mute, so I have to write it down on a sign for them and hold it up. They read it, and go on their way, so I throw the sign away. But then someone else turns up on another road, and I have to get round to them and do the same thing.

It's really very tiring, writing my name on signs over and over again all day. The worst thing about it is the traffic around this roundabout flows very slowly, and people get annoyed at how long it takes to drive round me. All they want is to know my name, but they have to wait 'til I've told loads of other people before they even get to ask. I've even heard that a lot of people just aren't even bothering to come my way any more.

Act 2

I still live on a roundabout. People still drive up to ask my name. But y'know what? I've got a couple of mates now. No-one's interested in them, which is good, 'cos it means I can just get them to write the signs for me. They write about 25 and then have a rest. Now, when people drive up to ask me my name I just take one of the signs out and show it to them, then throw it away.

It's much better. I get to tell so many people my name now, way more than before. It's still not perfect though -- when one or both of me mates is ill I have to scramble around as before. And once 25 drivers have come and gone, the 26th one has to wait ages while a sign gets written for them. But still. I'm loads more popular!

Too popular.

The council gave me a second roundabout. And a third. I'm a tourist attraction. So now there are people driving up to three roundabouts, and I've had to draft in a lot of introvert mates. And every time 25 people have gone past one of the roundabouts my mates have to draw another 25 signs. They're getting burnt out. I'm going to have to start paying them (more).

Act 3

I haven't got many mates any more. Just one, in fact. Got 10 roundabouts though, and well prepared for any more. I had a bit of a brainwave, see.

Me and my mate made 50 signs. And we attached them to posts, facing the roads at each roundabout. So now, when people come up, they can ask my name but it's already there. Right in front of them. Sometimes there's an accident and I have to replace one, but in general it works a treat.

People don't even need to ask me the question any more, and if I change my name, well, I only need to tell my mate. He can make some new signs. And he doesn't take much looking after.

The analogy explained (in case it wasn't obvious)

I used to be a fully dynamic website. Database queries on every request. I had a bit of traffic. Not much though.

Caches were my friends. They're databases, and I still had to do queries, but smaller and faster ones. But I had to maintain the databases which just duplicated the data I already had. And they kept emptying and coming back to ask the main database the same query as they asked half hour ago. They needed a bit of looking after.

I'm now a damn fast website. I get through a lot of traffic. My one companion is a generator/publisher. It prepares stuff in advance which doesn't change, and just places it there, right in front of all the traffic. And if I get twice the traffic? He can probably cope. Five times the traffic? Maybe then I'll need another one.

The moral

Seriously, just do shit offline. The Q in SQL is for "query". Like question. Why would you want to ask the same question multiple times if you know the answer doesn't change, or changes rarely -- and, crucially, if you know when it changes? Why even use a cache if it's only going to expire, and you need to maintain both the databases and the code which populates them? Moreover, the code and database are there to do nothing but store exactly the same information as you already have. What happened to "don't repeat yourself"? Is that only for code?

The master/controlling source of a website's data (eg a CMS for a media site), knows when data changes, so just push it out. Not to some intermediary - again, why bother? Just push it out all the way to the front. Generate it. Build it. Publish it.

I'm not arguing for no dynamism in websites. I'm just saying look, make the dynamism appropriate. Base it on the user, their behaviour, their request, or whatever -- but not on the things you already control. Changed your name? Don't wait for someone to ask you, get it out there before they even ask.

Want to know a query whose answer rarely changes? "What's the main body of the content at URL /2009/06/fail/?" One which changes regularly? "What's the most recent bit of content on the site?" Just think. about which parts of your site, and which parts of each page, actually change based on some kind of external input, be it the time and date, some facet of the current user, or some other unique facet of the individual request. You can do more of those, and provide more functionality, if you generate/build/publish the stuff that you control.

Do shit offline. Capiche?