Skip to content

Instantly share code, notes, and snippets.

@codatory
Created November 20, 2012 20:39
Show Gist options
  • Save codatory/4120923 to your computer and use it in GitHub Desktop.
Save codatory/4120923 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'json'
tweeter = 'JasonFalls'
keep_going = true
page = 1
yes = 0
no = 0
while keep_going do
puts "Fetching page #{page}"
feed = JSON.parse(open(URI.encode("http://search.twitter.com/search.json?q=from:#{tweeter}&rpp=100&page=#{page}")).read)
feed['results'].each do |result|
if result['text'].match(/heh.?$/i)
yes += 1
else
no += 1
end
end
puts "Yes: #{yes}"
puts "No : #{no}"
puts ("%.2f" % ((yes.to_f/(yes.to_f+no.to_f))*100)) + "%"
keep_going = feed['results'].count == 100
page += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment