Author Archive for Wyatt

Twitter Updates for 2008-10-03

  • had hella fun at ‘cross practice this evening. #

Photo Meme

Note: I would have posted this way back on the 19th, but iPhone 3G won’t mount on Ubuntu any more. Then there were permissions problems with my WordPress installation on WebFaction.

“”"Instructions: Take a picture of yourself right now. Don’t change your clothes, don’t fix your hair - just take a picture. Post that picture with NO editing. Post these instructions with the picture.”"”

Via

Twitter Updates for 2008-09-30

  • Pearl Izumi Cyclone full-fingered gloves get two thumbs up (from me, as of yesterday). #
  • It’s a mystery to me why more cyclists don’t ride with a rear view mirror. Maybe they don’t know about them? #
  • I can barely ride without a rear view mirror any more. I feel that it’s more a necessity than a helmet. #
  • Don’t get me wrong, though–helmets, while not a magical shield, are, IMO, essential. #
  • It’s just that a mirror is used very often and is an effective tool of prevention. Hopefully, that helmet never gets used. #
  • I can recommend the “Take a Look” mirror for eyeglasses. Don’t get the plastic one that’s similar. It WILL break. #

Twitter Updates for 2008-09-18

Twitter Updates for 2008-09-17

  • Have you seen my black New Balance sneakers? #

Twitter Updates for 2008-09-16

  • Washington Mutual isn’t exactly wowing me these days… #
  • First, they returned a $4,000 deposited check w/o explanation. I redeposited the exact same check and it cleared fine. Still no word on why. #
  • 2nd, customer service/competence at 39th & Hawthorne has a tendency to suck. #
  • Waaah! #

Twitter Updates for 2008-09-15

  • Hello, TriMet! #
  • “…value for value…” [unrelated to previous] #
  • Sidi Dominators: for play AND work. #
  • did 1st cyclocross race on Sat–Pain on the Peak. 7th out of 18 (?). 6 laps. #
  • Time to report for duty. #

Twitter Updates for 2008-09-05

  • Paradox Cafe has expanded; got rid of old booths; replaced w/ tables. #

Twitter Updates for 2008-08-21

  • “Rational self-interest.” Talk amongst yourselves. #

Implementation of Dijkstra’s Single-Source Shortest-Paths in JavaScript

I’m working on a project where the client wants a cool sliding navigation effect. We’re implementing this with JavaScript/AJAX/DHTML.

One of the constraints is that pages can only be reached via certain other pages. For example, if you’re on the /portland/contact page and want to go to the /seattle/contact page, you’ll first slide up to /portland, then over to /seattle, then finally down to /seattle/contact.

After a while, it occurred to me that there were some similarities with another project I’ve been working on off and on for the last few years, byCycle.org, which is a bicycle trip planner ala Google Maps.

I had written a Python version of Dijkstra’s Single-Source Shortest-Paths (SSSP) for byCycle.org. That’s available on PyPi as Dijkstar (so named because it also does has the potential to do A*). I figured it wouldn’t be too hard to port the Python version to JavaScript, and it wasn’t.

There were a few snags, though. Most of it was just syntactic and semantic differences between the two languages. The biggest issue was that I use “heapq“ in the Python version to maintain the costs to previously visited nodes in sorted order. JavaScript has no priority queue implementation that I could find, so I came up with a different solution that involves updating an Object (AKA “dict“) with costs to newly visited nodes and sorting the keys to pick the next node to visit. I’m assuming/hoping the underlying sort implementation is highly optimized.

Interestingly, I think I found at least one bug in the Python version, although I’ve been using that version for a couple years now with no known problems, so it must only be applicable in certain edge (no pun intended) cases (or maybe it’s due to some difference in the languages–need to take a closer look). I think the JS version came out cleaner, too.

If anyone’s interested, I’m releasing this under an MIT license. For now, you can get it from here. Note that it depends on the util module that you can get from here. The util module contains some other Python-inspired JavaScript, in particular a couple of functions for generating namespaces and classes. I might write another post about that at some point.