Permalink
Browse files

playing around

  • Loading branch information...
1 parent 50b9d8c commit da369258f4e2757d3218a7d52175e2b3aa69cb19 @alto committed Jul 28, 2012
Showing with 64 additions and 0 deletions.
  1. +15 −0 HOWTO
  2. +49 −0 play.rb
View
15 HOWTO
@@ -0,0 +1,15 @@
+hash = {}
+i = 0; Yajl::Parser.parse(js) { |thing| hash[i] = thing'; i += 1}; hash.keys.size
+
+
+
+require 'open-uri'
+require 'zlib'
+require 'yajl'
+
+gz = open('http://data.githubarchive.org/2012-03-11-12.json.gz')
+js = Zlib::GzipReader.new(gz).read
+
+Yajl::Parser.parse(js) do |event|
+ print event
+end
View
49 play.rb
@@ -0,0 +1,49 @@
+require 'open-uri'
+require 'zlib'
+require 'yajl'
+
+gz = open("http://data.githubarchive.org/2012-07-26-1.json.gz")
+js = Zlib::GzipReader.new(gz).read
+
+i = 0; stop_at = 10000
+
+types = {}
+repos = {}
+watches = {}
+
+Yajl::Parser.parse(js) do |event|
+ break if i > stop_at
+
+ # puts event.inspect
+
+ # count types
+ types[event['type']] ||= 0
+ types[event['type']] += 1
+ # puts event['type']
+
+ # analyse PushEvents
+ if event['type'] == 'PushEvent'
+ key = "#{event['repository']['owner']}/#{event['repository']['name']}"
+ repos[key] ||= 0
+ repos[key] += 1
+ end
+
+ # analyse WatchEvents
+ if event['type'] == 'WatchEvent'
+ key = "#{event['repository']['owner']}/#{event['repository']['name']}"
+ watches[key] ||= 0
+ watches[key] += 1
+ end
+
+ i += 1
+end
+
+# types.keys.each do |key|
+# puts "#{types[key]} x #{key}"
+# end
+# repos.keys.each do |key|
+# puts "#{repos[key]} x #{key}"
+# end
+watches.keys.each do |key|
+ puts "#{watches[key]} x #{key}"
+end

0 comments on commit da36925

Please sign in to comment.