Random hack: mirror and explore http://xkcd.com/1110/ "click and drag"

1,612 views
Skip to first unread message

Kyle Lemons

unread,
Sep 19, 2012, 6:54:51 AM9/19/12
to golang-nuts
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

gta

unread,
Sep 19, 2012, 8:55:17 AM9/19/12
to golan...@googlegroups.com

Nice example, thanks fo sharing.

Chris Hines

unread,
Sep 19, 2012, 12:45:06 PM9/19/12
to golan...@googlegroups.com
I'm glad someone took the time to do this.  :)

Kyle Lemons

unread,
Sep 19, 2012, 2:16:46 PM9/19/12
to Ken, golan...@googlegroups.com
If you followed the install guide and set up a GOPATH, you can simply "go get github.com/kylelemons/clickdrag" and then run the binary in $GOPATH/bin/clickdrag

On Wed, Sep 19, 2012 at 9:22 AM, Ken <kir...@wittenberg.edu> wrote:
I would love to try out your script, but am unfamiliar with Go. I just installed it (32-bit Win 7). Can you tell me how I tell the go.exe program to execute your script? I'm not sure how to make it... go.

thanks!
Ken

--
 
 

Chris Hines

unread,
Sep 19, 2012, 3:06:05 PM9/19/12
to golan...@googlegroups.com
Perhaps OT, but here is a similar effort:  http://xkcd-map.rent-a-geek.de/#10/0.9997/0.0000 
Reply all
Reply to author
Forward
0 new messages