Transforming ATOM 1.0 into HTML using XSLT
Posted by Nick Johnson | Filed under tech, coding
In response to Myke's request for a way to generate an HTML page containing the newest items from a bunch of RSS feeds, I made a suggestion: Use Google Reader to aggregate the feeds for you, export them using the 'sharing' functionality, and then simply transform the resulting ATOM feed into an HTML page using some XSLT on serverside.I thought there'd be a ready-made XSLT stylesheet for transforming ATOM out there, but I had absolutely no luck finding one. So, I hacked together a basic one for the purpose. Here it is:
[code]
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom">
-
Published:
Updated:
[/code]
I've only tested it with google's atom, but it ought to work with any valid atom feed. I also haven't attempted to format the dates into something more user-friendly - I'm sure XSLT has the facility, but I'll be damned if I can find it right now. Finally, only the title, url, dates and summary are exposed, but it's pretty trivial to add more.
Optimum phone keypad layouts, or, what to do with a boring weekend.
Posted by Nick Johnson | Filed under tech, coding
So, I was a little bored, and had an idea. The commonly used (alphabetic) phone keypad layout is not particularly efficient when it comes to T9 (one digit per letter) style entry - there are a lot of collisions. What would an ideal keypad layout look like?So I hunted up a computer-readable english dictionary with frequency scores (a 0-16 scale), and devised a way to score the efficiency of a layout: group words by the digits they translate into with that layout, and multiply together their frequency scores. So, for example, two colliding words with frequency 8 would score 64 points, while a collision between a word with frequency 1 and one with frequency 15 would score only 15 points. The idea is that collisions between words with greatly different frequencies are much easier to resolve - it'll almost always be the more common word - whilst collisions between similar words are generally bad. Then, sum up all the products to get the final score.
I then seeded a Genetic Algorithm with the default keypad layout, and ran generations of randomly mutating layouts (by reassigning letters at random) then scoring them, then selecting the few layouts with the lowest scores, and ...
A public apology to #sporksters
Posted by Nick Johnson | Filed under personal
I've been a bit of an ass lately. Sorry.It's been brought to my attention that I've frequently been less than friendly the past few weeks, culminating with the almighty row in #sporks a day or two ago. A lot of it stems from what's been going on in my life recently - moving, new job, visa problems etc - but that's no excuse. In the past few days, particularly, I've found myself snapping at the smallest things. Once or twice, nothing more than another spam arriving in my inbox was been enough to get me angry(er). Something that took no more than a second to review and delete.
Now that I'm aware of it, I'm actually feeling a hell of a lot better already. I ought to be more like my ordinary, sanguine self, hopefully. If I'm not, pull me up on it. Tell me I'm being an ass again.
Photos of my new apartment
Posted by Nick Johnson | Filed under personal, travel
A bunch of photos of my new apartment. Please forgive the poor compositing on the two of my work area, I didn't have a tripod, and it wasn't possible to get the whole thing with a single frame (too much dynamic range).Edit: Added a picture of how it looks at sunset:
Somewhere to stay!
Posted by Nick Johnson | Filed under personal, travel
As much as I like sleeping in Dark's lounge, eating his breakfast cereal, and working from his dinner table, I have been desperately searching for a furnished apartment I can stay in while I'm here. All at once, on Thursday, my search paid off - with two seperate apartments. I took the slightly more expensive and slightly larger one, paying $100 less than Too Much for it. It's still a studio apartment, but it has a murphy bed, placed such that I can fold it up when I have people around, but I don't _have_ to if I don't. It has a nice little enclosed balcony/conservatory area with a computer workstation. I can work whilst looking out over the city from my dizzyingly high 32nd floor perspective.Photos will be forthcoming once I'm moved in, later today.
Back in Canada
Posted by Nick Johnson | Filed under personal, travel
So, I made it back into Canada. After all the extensive, lawyer-assisted preparations so I would be able to explain myself in sufficient and excrutiating detail to the customs officers, I was simply waved through with nary a glance.Then, as I pull away, suitcase in tow, the officer goes "Hold on a moment". "Uh oh", I think, "now I get the half hour of going over all my documentation 5 times before they're satisfied". I return to the desk, and give him back my passport. The passport scanner is flashing "NZ Passport Alert!!!" on and off. The screen has a single line entry " Personal Marajuana Posession". I have no idea what it's talking about - I presume a name collision. He puts the passport back on the scanner, waits a couple of seconds, takes it off, hands it back, and tells me I can go. I do.