Tuesday, November 13, 2007

Six Degrees of Wikipedia Game Generator

(Edit: Blogspot is lame, if I set nowrap on an element it cuts off the text at the preconfigured length.)

(Edit: I seem to have made up the codeblock tag, so I'm replacing it with the code tag, which actually exists.)

My friend Mike made a blog posting last month and I thought I'd write some code to generate games. I was originally going to write it in lisp, but since I've been studying bash lately I wrote a one-line command.

This generates links to two wikipedia articles, it's not the prettiest script, but it gets the job done. There are still a few bugs so if anybody has an improvement they should let me know. (I'd say post it in the comments, but I believe code tags aren't accepted, so just email it to me)

echo -e "$(wget -nv http://en.wikipedia.org/wiki/Special:Random 2>&1 | sed "s/^.* URL:\([^ ]*\) .* \"\([^\"]*\)\".*$/<a href='\\1'>\\2<\\/a>/")\n$(wget -nv http://en.wikipedia.org/wiki/Special:Random 2>&1 | sed "s/^.* URL:\([^ ]*\) .* \"\([^\"]*\)\".*$/<a href='\\1'>\\2<\\/a>/")"

3 comments:

Mike Machenry said...

That's great. Now we just need to write a little script to upload this to some short of blog or website that allows user submissions so we can have a daily competition... and never get any work done :)

I like the new blog name.

lackita said...

Actually, since blogspot allows posts by email, I could create a "Six Degrees of Wikipedia" blog and set up a cron on my home computer to email the new entries every day.

kod_mako said...

Some guy has already created something similar called 5 clicks to Jesus (www.5clickstojesus.com).

But you could go one step further and do 6 steps to jesus!