Car

July 27, 2009, 12:01 pm

Sam liked to imagine how things might be different. He was a pedestrian man, tetering on middle age, moderately succesful and in his solitary existance, lavish with his own obsessions. Unable to commit to the occasional and passing infatuations with women, cars or any other fragments of the real world, Sam cultivated the less demanding and infinitely more rewarding imaginary worlds that crowded his existance. He poured his substantial salary into comics, toys, movies and games and his own wide screen, surround sound and leather bound heaven to enjoy it all.

He found like minded individuals to share his obsessions, but he struggled to build relationships that weren't based on some fantastic premise. So on this particular friday evening Sam sat comfortably at his computer, completely imersed in a digital, virtual world and in particular the welfare of a particlarly pretty woodland elf who had sought his aid.

The reality of the situation, that Sam was being seduced by a balding and, at the same time, unusually hairy, middle aged Russian man, had not escaped him but was entirely unimportant. Indeed this was Sam's power, his ability to effortlessly suspend disbelief was unmatched.

He had left the mundane world behind and given substance to his digitally fuelled imaginings.

... something something something ...

Sam rushed to cross as the lights changed. The car flying silently into the turn barely clipped his body, but generated a frantic twisting motion that was punctuated with terrible finality when Sam's body lay, completely still, in the gutter.

Permalink - Comments - Tags: Stories

Timeline Project Trilogy

July 24, 2009, 9:42 pm

I have set up the third and final (for a while at least) of the sites devoted to geographical and chronological mapping of historical conflicts. Not that I need an additional time sink but the compulsion to add an American Civil War Project was irresistible.

That fact that I now have a Trilogy of sites is purely coincidental. My nauseatingly sycophantic obsession with StackOverflow can only go so far ... hmmm

Anyway, I have three projects ready for user contribution. Although I quite enjoy doing the research and populating data points myself, I do occasionally, quietly hope that some generous denizen of the Internetz will log in and contribute their valuable time to one of my three digital offspring:

Permalink - Comments - Tags: Development,World War Two,Napoleonic Wars,American Civil War

Tail Wagging Googlebot

July 17, 2009, 10:46 pm

I discovered an interesting and somewhat elusive bug in my user validation stuff last night. With a little more sleep and some forethought I might have arrived at the solution a little earlier that I did, but I got there eventually.

I noticed, of the handfall of users that have signed up for my Timeline Project, not all had validated their accounts. I wondered about the reason why and decided to do a bit of testing. I follow a pretty standard model for account validation:

  • User enters their new details.
  • I add the details to the database and generate a random key.
  • I send an email to the specified address with a URL back passing the key as a param.
  • User clicks on the URL in the email and I match it to the database key I stored earlier. Then I erase the key in the user's database entry. I only need to do this once and I use the key for other stuff (password resets).
  • If everything matches up, I set a valid flag on the user account.

So pretty straightforward? When I originally wrote the code, I tested with a couple of accounts, assumed everything was fine and moved on. I assumed wrong.

Re-testing this stuff, I created a whole pile of accounts and checked that they could be successfully validated. To my chagrin, I found that when I clicked on the validation URL, for a handful of them, I generated an error message saying that the key didn't match. This was something of a gumption trap, a random intermittent fail with a system that should be trivial.

I fell back on that mainstay of programming, debug writes. I already have a decent logging system, so I added a few more log messages when the validation URL gets fired. The results I found were puzzling to say the least:

For this log example, the validation succeeded (validate_pass), but the message immediately after it was extremely suspicious. An attempt to validate that user id from some obscure IP address that I hadn't seen in my logs before. My "it is always your fault" programmer instincts failed me and I jumped from one irrational and outlandish conclusion to the next. Eventually I came to my senses and decided to do a traceroute on the IP address:

When my activation email arrived in my Gmail inbox, that enthusiastic, tongue lolling, tail wagging Labrador of a GoogleBot immediately jumped on my validation URL and bounded off to get it. So if the GoogleBot hit the URL first, then the key would get reset and the subsequent real user request would fail. It is pretty satisfying when a classic intermittent and quite random race condition has a very simple solution. "It is ALWAYS your fault". I gotta remember that one.

Adding a few lines to my robots.txt file, which up until that point had been empty, ensured that the GoogleBot would refrain from hitting those fragile URLs. Bug Fixed.

Permalink - Comments - Tags: Development,Google

Dreamsongs - George R R Martin

July 16, 2009, 2:09 pm
The best fantasy is written in the language of dreams. It is alive as dreams are alive, more real than real ... for a moment at least ... that long magic moment before we wake.

Fantasy is silver and scarlet, indigo and azure, obsidian veined with gold and lapis lazuli. Reality is plywood and plastic, done up in mud brown and olive drab. Fantasy tastes of habaneros and honey, cinnamon and cloves, rare red meat and wines as sweet as summer. Reality is beans and tofu, and ashes at the end. Reality is the strip malls of Burbank, the smokestacks of Cleveland, a parking garage in Newark. Fantasy is the towers of Minas Tirith, the ancient stones of Gormenghast, the halls of Camelot. Fantasy flies on the wings of Icarus, reality on Southwest Airlines. Why do our dreams become so much smaller when they finally come true?

We read fantasy to find the colors again, I think. To taste strong spices and hear the songs the sirens sang. There is something old and true in fantasy that speaks to something deep within us, to the child who dreamt that one day he would hunt the forests of the night, and feast beneath the hollow hills, and find a love to last forever somewhere south of Oz and north of Shangri-La.

They can keep their heaven. When I die, I'd sooner go to middle Earth.

Permalink - Comments - Tags: Books,Review,GRRM

Juno, Sitemaps, Allison Janney, Crumpet Toast

July 12, 2009, 1:31 am

Finally got around to watching Juno tonight. I loved the trailer when it was on TV and really wanted to see it at the time (I would never barf in your urn). My life tends to lag by about 18 months or so when it comes to stuff like that.

Jeff Atwood on the StackOverflow podcast made me realize I need to generate a sitemap XML based on my content, rather than knocking something together from the entry pages and hoping that the Google crawler will find it's way. Pretty happy with the results, my PHP produced 1,249 URLs ready for Google indexing. Who knew I had so much content?

Mmm, eating crumpet toast with honey. Ok, this is just a gratuitous, inane, food reference.

So I sat in bed writing some pretty simple PHP, while watching Juno. I liked it, but I get the feeling that I am so changed by my West Wing obsession that I would probably like anything with Allison Janney in it:

Permalink - Comments - Tags: Development