?

Log in

No account? Create an account

433.rb

« previous entry | next entry »
Feb. 25th, 2009 | 10:52 pm
music: On Target - Nullsleep (Electric Heart Strike)

I have created a command line client to Petri Purho's controversial game 4 Minutes and 33 Seconds of Uniqueness. It prints a "." every two seconds while playing. Its exit status will be zero if you win, otherwise it will be one. It is written in ruby. Its permanent home is this gist. You can download the code here.
This is it:
#!/usr/bin/env ruby -wKU
require 'net/http'
require 'uri'

STDOUT.sync = true; token = rand(28000); time = 0
uri_root = "http://www.kloonigames.com/nordicjam2009/"
start = URI.parse(uri_root + "new_game.php?v=#{token}");
whois = URI.parse(uri_root + "whois.txt"); 
start = Net::HTTP.get(start)
if ! start =~ /1/ then puts ""; exit 1; end

while (true)
  if time >= 273 then puts ""; exit 0 end
  who = Net::HTTP.get(whois); me = who.split("|")
  if me[1].strip.to_i != token then puts ""; exit 1 end
  print "."; sleep 2; time += 2
end
Code licensed under the WTFPL.
Tags: ,

| Leave a comment | Share

Comments {0}