Skip to content

Instantly share code, notes, and snippets.

@tncbbthositg
Created May 1, 2009 19:35
Show Gist options
  • Save tncbbthositg/105207 to your computer and use it in GitHub Desktop.
Save tncbbthositg/105207 to your computer and use it in GitHub Desktop.
require 'net/http'
def vote()
result = Net::HTTP.get("www.someplace.com", "/voteCounter.php?voteFor=2", 80);
# the results look like this:
# total=6091&votesOption1=2791&votesOption2=2920&votesOption3=380
matches = /votesOption1=(\d*)&votesOption2=(\d*)/i.match(result);
o1 = matches[1].to_i();
o2 = matches[2].to_i();
return "#{result}&difference=#{o2-o1}";
end
(ARGV[0] || 1).to_i.abs.times{puts vote();};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment