« Archives in March, 2008

Two nights and Beijing Bicycle

I find it strange that I can sit in front of a computer for the better part of 24 hours without experiencing too much discomfort, but that any length of time greater than one hour in front of a television distresses me terribly. As a result, I tend to scoff at films of all genres and calibers, simply because I am a bad filmgoer.

A lemma to this is that I also gravitate towards watching some really stupid junk when I do sit down in front of a tube. After all, if I’m going to be doing something stupifying, there’s no sense in being a pansy about it. Witness: The bulk of my television time last year was spent watching the entire run of the X-Men and Conan the Adventurer animated series. (In my defense, I was usually cooking at the same time.)

I do understand, though, that there are scads of films out there that are absolutely exquisite. I feel like I may even have seen a handful of them. I made a resolution sometime last year that I was going to work at experiencing more of these sorts of films. For instance, I recently watched Amélie (more experienced filmgoers than I would probably do some scoffing themselves at this point), and was strongly affected. It was fantastic. I saw some films in Italy that I rather liked, but they may have seemed more profound than they actually were because of my ineptitude with the langauge. (Non capisco tutto, allora devo immaginare quello chè rimanghe.)

So, what has this got to do with anything? Well, a couple of weeks ago, my sister had to go to the bank on the way home, so I stopped in at BlockBuster while she did her thing. I am quite comfortable with admitting that the first ‘film’ I searched for was the Powerpuff Girls Movie. Laugh all you want, those lil girls kick ass. Buttercup is one of my biggest role models. (Blossom is a pretty stand-up gal, too.) Plus, the movie is only an hour long, which fits neatly into my attention span. Although it’s sort of frustrating that 20 minutes of that one hour is filled by the girls playing tag.

Anyhow, I picked up another flick called “Beijing Bicycle”, simply because it was the only film in the international section that didn’t promote itself through copious amounts of sex. I’m not a prude, but I was looking for something that might be a little farther outside of the box. (No, that was not an intentionally crude pun.) It was sufficiently challenging that I had to watch it in two installments, but I really liked it.

The gist of the film is that a country boy moves to Beijing with some other dude to find his fortune. He’s only eighteen or so. He gets a job as a bicycle courier, and the company sets him up with a shiny mountain bike that he has to pay off by making his deliveries. He’s a silent boy, and doesn’t speak out when people treat him like dirt, but he is intensely stubborn and digs in his heels when challenged. He just sits there, says nothing, and refuses to budge.

Somewhat predictably, the bike is stolen just as he manages to pay off the bike and thus has a higher percentage of his delivery pay going into his own pocket. It is then bought second-hand by some little pissant kid who is in a situation that is at least as dismal as the main characters’ predicament, but for some reason I felt little empathy for. His family is poor, and all his friends have bicycles. He wants one to call his own, but his father keeps finding reasons not to buy one for him, despite repeated promises to the boy that he will do so.

Our hero goes on a quest to find the bike, and thus begins an incredible frustrating back-and-forth between the two boys, as each struggles with all his might to retain sole ownership of the bike. This struggle takes the viewer through all sorts of scenery and quotidian situations in modern Beijing, which is quite an incredible experience. Some parts of the city are shockingly primitive, while others look surprisingly like North America. I say this in contrast to what I’ve seen of other Asian cities, such as the metropolises in Japan, which often look to me like something out of a tripped-out science-fiction comic book. I am but an ignorant westerner.

The film is about two hours long, and for the first hour and twenty minutes, the story sort of plods along. I watched it in two sessions of roughly equal length. After my first sitting, I figured that the entire film would probably be sort of boring, but that it would be worth watching the rest of it just for the snapshots of ‘Beijing life’. Things really pick up in the last forty minutes, though. The final few scenes are incredibly well done.

Oh, and even if the film doesn’t do much for you, check out that soundtrack! The music is somehow energetic and pensive at the same time — like the hum of a caffeinated brain. (Gotta lay off the espresso — it’s obviously breached the PR section of my head.)

I’m not the most seasoned film critic, but I’d recommend this one. I’m glad I stumbled across it, amidst the peach collage of European legs and breasts.

I’m looking forward to getting out of suburbia in the near future so that I can find myself a good, snooty little video rental place that I can frequent regularly. What with my startup team being located in the GTA, Toronto is looking like the most probably landing place for me, so venue suggestions in that area would be most welcome.

The silly things that inspire

Recently, my average day looks something like this. 

6am: Wake up, shotgun an espresso from a thermos and chase it with one teaspoon of glutamine in a glass of water. Walk on treadmill at 4 to 4.5 miles per hour for thirty-five minutes. While I walk, I read about something non-fictional. Usually software. 

6:50am: Eat breakfast. Drop sister off at work. If Monday, Tuesday, or Thursday, go to the gym.

Somewhere between 8:30am – 11:00am: Arrive at the office. (The range depends on how long I end up spending at the gym).

Somewhere between 6:30pm and midnight: Arrive home from work, and pack my 3-4 meals for the next day’s session.

As you can see, there’s a pretty big chunk of time in there where I am working. I spend an average of ten hours a day on the computer. As such, the incentive to blog about anything when I get home is pretty low, because I want to spend some time away from this box.

And yet, here I am, blogging. Why?

Because I stumbled upon WriteRoom, that’s why.

WriteRoom is essentially a skin over the Mac’s vanilla TextPad application that allows it to run in fullscreen mode. The default setup overlays neon green text over a solid black background. It’s like something out of Neuromancer. It reminds me of the many hours I spent in ratpoison, with vim and my terminal windows filling the screen in all of their orange-and-black glory, except that WriteRoom has pretty antialiased fonts. (See?)It also has one killer feature that I’ve been looking for in the mac port of gvim (or some associated plugin): You can hit a key combo in any textbox and edit the text in that box using WriteRoom. When you’re done, you hit the save + close key combo, and your text appears back in the box. It’s fantastic. It might even make it fun to fill out web forms. (Edit: I just tested this in Safari and Camino, and, erm, it’s not working. Maybe I did something stupid. Works great in Mail though.)

It’s interesting to see how stripped-down software is starting to appeal to people more and more these days. There are the obvious examples (see the propaganda machine at 37signals); and then, there are things like WriteRoom that fly under the radar, waiting to pop up and surprise you.

This little app has made writing fun again. I find myself putting more thought into my words, and it feels like I’m crafting something instead of just spewing what I want to say into a buffer. As one person noted on a blogpost I saw somewhere: “At first, I thought WriteRoom was a joke, because it looks like someone’s first Cocoa app. But it’s a killer application.” (I may be way off there, but I don’t have internet access as I’m writing this, so I can’t even check. Chalk up another point for minimalism.)

WriteRoom is not free software. You get a free 30 day trial, and then you have to cough up 24.95USD. It’s very likely that the novelty will have worn off after 30 days, but I’m not sure. (If I could make vim look exactly like this, and operate in any textarea, I’d pay upwards of a hundred dollars for it.) There are WriteRoom clones out there — namely, JDarkRoom and pyroom. I’ve heard that the former is clunky. I tried to run the latter, but it depends on gtk, which means it’s going to run in X11, which means I am going to hate its guts. I can’t imagine that either of them will be able to tie in as nicely with the OS as WriteRoom does.

In my tickler, there is an item that says “Create an expenses app using Cocoa to learn how to develop applications for OS/X.” I might change that to “Develop your own version of WriteRoom using Cocoa to learn how to develop applications for OS/X.” Then I’ll really feel like something out of Neuromancer. Just me, my deck, and black-and-green text. Maybe an espresso, and some dnb or classical playing in the background.

Bliss.

Javascript Array literals in Internet Explorer

It hurts.

It hurts to waste 1.5 hours debugging something absolutely stupid because a browser comes with absolutely no way to introspect Javascript errors. Thank god for MochiKit and their logging/debugging bookmarklet, without which I would have been completely lost. (Tried to download an MS script editor/debugger to no avail.)

Anyhow, today’s story is about how IE defies ECMAscript standards in subtle ways that can be extremely confounding.

To begin, a simple question for you. How long is this array?

var x = [1, 2, 3, 4,];

Now, if you know python, or even if you’ve worked from javascript in some other browser, you would say “4″. The trailing comma is helpful because it lets you insert extra lines in a long declaration without worrying about forgetting a comma. For example:

var myHugeArray = [
    { complaint: "ie sucks", action: "scream in anguish" },
    { complaint: "aaargh", action: "whine and cry" },
];

If we wanted to add another complaint to that list, it’d be easy to cut-and-paste that last entry.

Back to our original question. How long is that array? I’ll tell you.

It depends.

In every browser except IE, it’s 4. In IE, it’s 5. Not a syntax error, not a runtime error; nope, it’s 5. The last element is undefined.

ARGH.

I’m never doing that again. Neither, it seems, will these people.

Google maps API error?

NOTE TO SELF.

If you’re ever getting a mysterious null object reference error from the guts of the maps API, make sure that you are setting the center of your map immediately after constructing it:

var myMap = new GMap2(...);
myMap.setCenter(...);

In fact, it’s probably just better to create a factory function to create your map so you don’t forget:

function createMap(canvasId, center) {
  var map = new GMap2(getElement(canvasId));
  map.setCenter(center, DEFAULT_ZOOM);
  return map;
}

For the life of me, I can’t understand why the heck they wouldn’t just make the map center a required parameter to the constructor if you have to do this. Method order coupling is BAD, especially when there’s no way you’re going to understand what the heck is going on in JS libraries that have been obfuscated as well as the Maps API has.

Software engineering lessons sink in better when they burn a couple of hours of your time on stupid things like this :D This behaviour is documented in the API reference, but under the setCenter method, not under the constructor docs (where it should be).