Created
January 1, 2010 06:15
-
-
Save toluju/267061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
languages = ["java", "c++", "c", "perl", "ruby", "python", "javascript", "html", "css", | |
"scala", "xml", "xslt", "xquery", "php", "actionscript", "flash", "flex", | |
"vbscript", "applescript", "erlang", "objective-c", "smalltalk", "haskell", | |
"c#", "boo", "f#", "go", "processing", "arduino", "pd", "qc", "vimscript", | |
"as3", "assembly", "sh", "obj-c", "sql", "coldfusion", "lex", "yacc", | |
"scheme", "lisp", "bourne", "awk", "tcl", "d", "ocaml", "elisp", "clojure", | |
"bash", "noop", "wix", "rdl", "javafx", "groovy", "abap", "sml", "asp.net", | |
"asp", "visualbasic", "basic", "shell", "matlab", "hql", "rhino", "rebol", | |
"forth", "cocoa", "awk", "sed", "vb.net", "vb", "lua", "delphi", "fortran"] | |
counts = {} | |
languages.each { |w| counts[w] = 0 } | |
(1..15).each { |i| | |
response = Net::HTTP.get(URI.parse("http://search.twitter.com/search.json?q=%23code2009&rpp=100&page=#{i}")) | |
json = JSON.parse response | |
json['results'].each { |r| | |
text = r['text'].gsub(/\(.*?\)/, '') | |
text.downcase.split(%r{,?\s+}).each { |w| | |
if w[0] == ?# | |
w = w[1, w.length] | |
end | |
if w[-1] == ?. or w[-1] == ?, | |
w = w[0, w.length - 1] | |
end | |
if languages.include?(w) | |
counts[w] = counts[w] + 1 | |
end | |
} | |
} | |
} | |
counts.sort {|a,b| b[1] <=> a[1]}.each { |key, value| puts "#{key}: #{value}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment