I assume some number of you also read XKCD, and were probably just as delighted as I was to explore the "
click and drag" comic from this week. Of course, if you're like most people on the internet, you have much better things to do than scroll around the entire thing to explore it. Since I was impatient, I decided to have a peek at the javascript and piece the whole thing together with Go.
The result can be installed via
If you run it, it will generate an "out" folder in your working directory containing the ~200 images as well as an HTML file that glues them together for your viewing pleasure.
Some methodology... it starts off at some cleverly chosen tiles in the image, and walks out from that in a similar fashion to the "web crawler" from the go tour. It searches a radius of 2 around any image it finds for other images. It checks the harddrive first, in case you had to restart the binary, so it won't re-fetch images it already has. It also only tries to download 10 images at a time, to hopefully be a kind citizen to whatever CDN is hosting these images.
Oh, and the code is pretty hacky and not really a shining example of well-thought-out code, it's all one file and uses globals and stuff, since it's just a "script". Anyway, thought I'd share, in case anyone was wondering how suitable Go was for doing these sort of one-shot coding exercises that are commonly left to Python and friends :).
~K