Skip to content

Instantly share code, notes, and snippets.

@hc5duke
Forked from visnup/homework.rb
Created June 30, 2009 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hc5duke/138044 to your computer and use it in GitHub Desktop.
Save hc5duke/138044 to your computer and use it in GitHub Desktop.
I copied visnup!
require 'rubygems'
require 'open-uri'
require 'json'
url = 'http://twitter.com/statuses/user_timeline.json?id=hc5duke&count=3200'
dates = open(url) { |f| JSON.parse f.read }.map { |e| Time.parse e['created_at'] }
sum = dates.inject(Hash.new(0)) { |s, t| s[t.strftime('%Y-%m-%d')] += 1; s }
total = 0
sum.keys.sort.each { |k| puts "#{k}\t#{sum[k]}\t#{total += sum[k]}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment