-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish big data github challenge, still some documentation to finish
- Loading branch information
Showing
9 changed files
with
201 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
output.jpg | ||
*.jpg | ||
data-2012-05-19.json data-2012-05-20.json data-2012.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"DownloadEvent":[{"count":22,"name":"canjs","owner":"jupiterjs","language":"JavaScript"},{"count":16,"name":"dbGlossary","owner":"phpManufaktur","language":null},{"count":13,"name":"serverStreamLog","owner":"josedesoto","language":"Python"},{"count":9,"name":"mdframed","owner":"marcodaniel","language":"Shell"},{"count":8,"name":"srvdir","owner":"fsouza","language":"Go"}],"CommitCommentEvent":[{"count":34,"name":"easybuild","owner":"JensTimmerman","language":"Python"},{"count":26,"name":"TrinityCore","owner":"TrinityCore","language":"C++"},{"count":18,"name":"playpen","owner":"Spuds","language":"PHP"},{"count":18,"name":"akka-protostuff-serialization","owner":"romix","language":"Java"},{"count":17,"name":"xbmc","owner":"opdenkamp","language":"C"}],"ForkEvent":[{"count":31,"name":"Spoon-Knife","owner":"octocat","language":null},{"count":13,"name":"bootstrap","owner":"twitter","language":"JavaScript"},{"count":13,"name":"react","owner":"react-php","language":"PHP"},{"count":13,"name":"AK-BK-10-MVC","owner":"bendo01","language":"PHP"},{"count":10,"name":"dotfiles","owner":"michaeljsmalley","language":"VimL"}],"PullRequestReviewCommentEvent":[{"count":65,"name":"symfony","owner":"symfony","language":"PHP"},{"count":21,"name":"sqlparse","owner":"andialbrecht","language":"Python"},{"count":20,"name":"redaxo","owner":"redaxo","language":"PHP"},{"count":18,"name":"PiplMesh","owner":"wlanslovenija","language":"Python"},{"count":13,"name":"sympy","owner":"Krastanov","language":"Python"}],"PullRequestEvent":[{"count":39,"name":"test-repository","owner":"JMSBot","language":null},{"count":33,"name":"jquery-mobile","owner":"jquery","language":"JavaScript"},{"count":20,"name":"rails","owner":"rails","language":"Ruby"},{"count":17,"name":"homebrew","owner":"mxcl","language":"Ruby"},{"count":16,"name":"scala","owner":"scala","language":"Scala"}],"IssueCommentEvent":[{"count":64,"name":"TrinityCore","owner":"TrinityCore","language":"C++"},{"count":57,"name":"4chan-x","owner":"MayhemYDG","language":"JavaScript"},{"count":50,"name":"projetBomberman","owner":"siwon","language":"C++"},{"count":46,"name":"rails","owner":"rails","language":"Ruby"},{"count":45,"name":"homebrew","owner":"mxcl","language":"Ruby"}],"IssuesEvent":[{"count":45,"name":"mmx","owner":"mmteam","language":null},{"count":44,"name":"Dragon","owner":"DragonFire","language":"C++"},{"count":40,"name":"khan-exercises","owner":"Khan","language":"JavaScript"},{"count":27,"name":"AtlantissCore","owner":"Atlantiss","language":null},{"count":22,"name":"SuperDerpy","owner":"dos1","language":"C"}],"PushEvent":[{"count":381,"name":"dotfiles","owner":"yuu-ito","language":"VimL"},{"count":177,"name":"sandbox","owner":"illusionoflife","language":"Python"},{"count":159,"name":"sample_app","owner":"davidparracatalan","language":"Ruby"},{"count":113,"name":"test-repository","owner":"ide-an","language":"Java"},{"count":96,"name":"bcom-homepage-archive","owner":"bcomdlc","language":null}],"WatchEvent":[{"count":216,"name":"react","owner":"react-php","language":"PHP"},{"count":49,"name":"bootstrap","owner":"twitter","language":"JavaScript"},{"count":38,"name":"teacup","owner":"rubymotion","language":"Ruby"},{"count":25,"name":"activerecord-reputation-system","owner":"twitter","language":"Ruby"},{"count":24,"name":"sspulltorefresh","owner":"samsoffes","language":"Objective-C"}]} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"DownloadEvent":[{"count":1,"name":"Open-Transactions","owner":"da2ce7","language":"C++"},{"count":1,"name":"hawkthorne-journey","owner":"kyleconroy","language":"Lua"},{"count":1,"name":"Tangerine","owner":"Tangerine-Community","language":"JavaScript"}],"CommitCommentEvent":[{"count":4,"name":"netty","owner":"netty","language":"Java"},{"count":3,"name":"sadface","owner":"benlk","language":"Python"},{"count":2,"name":"TrinityCore","owner":"gc","language":"C++"},{"count":1,"name":"ECM","owner":"Iaccidentally","language":null},{"count":1,"name":"brickhu.github.com","owner":"brickhu","language":null}],"ForkEvent":[{"count":2,"name":"Spoon-Knife","owner":"octocat","language":null},{"count":2,"name":"django-watermark","owner":"codekoala","language":"Python"},{"count":1,"name":"backbone.layoutmanager","owner":"tbranyen","language":"JavaScript"},{"count":1,"name":"jshint","owner":"jshint","language":"JavaScript"},{"count":1,"name":"net-ssh","owner":"net-ssh","language":"Ruby"}],"PullRequestReviewCommentEvent":[{"count":1,"name":"usergroup","owner":"rubytij","language":"JavaScript"},{"count":1,"name":"bitcoin","owner":"bitcoin","language":"C++"},{"count":1,"name":"picard","owner":"musicbrainz","language":"Python"}],"PullRequestEvent":[{"count":4,"name":"Vanilla","owner":"SpoutDev","language":"Java"},{"count":4,"name":"loomio","owner":"enspiral","language":"Ruby"},{"count":2,"name":"evolution","owner":"sjstoelting","language":"PHP"},{"count":2,"name":"community","owner":"neo4j","language":"Java"},{"count":2,"name":"Salesmania","owner":"B2OJustin","language":"Java"}],"IssueCommentEvent":[{"count":5,"name":"carmen","owner":"jim","language":"Ruby"},{"count":4,"name":"hagfish","owner":"mfiers","language":"Python"},{"count":4,"name":"rails","owner":"rails","language":"Ruby"},{"count":4,"name":"team-5","owner":"aaltowebapps","language":"JavaScript"},{"count":3,"name":"core","owner":"kohana","language":"PHP"}],"IssuesEvent":[{"count":8,"name":"test-repo","owner":"Axbit","language":null},{"count":4,"name":"team-5","owner":"aaltowebapps","language":"JavaScript"},{"count":4,"name":"pixieengine.com","owner":"PixieEngine","language":"ActionScript"},{"count":3,"name":"Ushahidi_Android","owner":"ushahidi","language":"Java"},{"count":3,"name":"cukebins","owner":"paoloambrosio","language":"C++"}],"PushEvent":[{"count":19,"name":"PixieDust","owner":"PixieEngine","language":"JavaScript"},{"count":15,"name":"joomla-cms","owner":"mbabker","language":"PHP"},{"count":12,"name":"sengopal.github.com","owner":"sengopal","language":"Ruby"},{"count":12,"name":"notebook","owner":"rishabhsrao","language":"JavaScript"},{"count":11,"name":"min","owner":"wreviews","language":"PHP"}],"WatchEvent":[{"count":4,"name":"async","owner":"caolan","language":"JavaScript"},{"count":3,"name":"meteor","owner":"meteor","language":"JavaScript"},{"count":3,"name":"bootstrap","owner":"twitter","language":"JavaScript"},{"count":3,"name":"webwriter","owner":"icebeat","language":"JavaScript"},{"count":2,"name":"sspulltorefresh","owner":"samsoffes","language":"Objective-C"}]} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"DownloadEvent":[{"count":1,"name":"Open-Transactions","owner":"da2ce7","language":"C++"},{"count":1,"name":"hawkthorne-journey","owner":"kyleconroy","language":"Lua"},{"count":1,"name":"Tangerine","owner":"Tangerine-Community","language":"JavaScript"}],"CommitCommentEvent":[{"count":4,"name":"netty","owner":"netty","language":"Java"},{"count":3,"name":"sadface","owner":"benlk","language":"Python"},{"count":2,"name":"TrinityCore","owner":"gc","language":"C++"},{"count":1,"name":"ECM","owner":"Iaccidentally","language":null},{"count":1,"name":"brickhu.github.com","owner":"brickhu","language":null}],"ForkEvent":[{"count":2,"name":"Spoon-Knife","owner":"octocat","language":null},{"count":2,"name":"django-watermark","owner":"codekoala","language":"Python"},{"count":1,"name":"backbone.layoutmanager","owner":"tbranyen","language":"JavaScript"},{"count":1,"name":"jshint","owner":"jshint","language":"JavaScript"},{"count":1,"name":"net-ssh","owner":"net-ssh","language":"Ruby"}],"PullRequestReviewCommentEvent":[{"count":1,"name":"usergroup","owner":"rubytij","language":"JavaScript"},{"count":1,"name":"bitcoin","owner":"bitcoin","language":"C++"},{"count":1,"name":"picard","owner":"musicbrainz","language":"Python"}],"PullRequestEvent":[{"count":4,"name":"Vanilla","owner":"SpoutDev","language":"Java"},{"count":4,"name":"loomio","owner":"enspiral","language":"Ruby"},{"count":2,"name":"evolution","owner":"sjstoelting","language":"PHP"},{"count":2,"name":"community","owner":"neo4j","language":"Java"},{"count":2,"name":"Salesmania","owner":"B2OJustin","language":"Java"}],"IssueCommentEvent":[{"count":5,"name":"carmen","owner":"jim","language":"Ruby"},{"count":4,"name":"hagfish","owner":"mfiers","language":"Python"},{"count":4,"name":"rails","owner":"rails","language":"Ruby"},{"count":4,"name":"team-5","owner":"aaltowebapps","language":"JavaScript"},{"count":3,"name":"core","owner":"kohana","language":"PHP"}],"IssuesEvent":[{"count":8,"name":"test-repo","owner":"Axbit","language":null},{"count":4,"name":"team-5","owner":"aaltowebapps","language":"JavaScript"},{"count":4,"name":"pixieengine.com","owner":"PixieEngine","language":"ActionScript"},{"count":3,"name":"Ushahidi_Android","owner":"ushahidi","language":"Java"},{"count":3,"name":"cukebins","owner":"paoloambrosio","language":"C++"}],"PushEvent":[{"count":19,"name":"PixieDust","owner":"PixieEngine","language":"JavaScript"},{"count":15,"name":"joomla-cms","owner":"mbabker","language":"PHP"},{"count":12,"name":"sengopal.github.com","owner":"sengopal","language":"Ruby"},{"count":12,"name":"notebook","owner":"rishabhsrao","language":"JavaScript"},{"count":11,"name":"min","owner":"wreviews","language":"PHP"}],"WatchEvent":[{"count":4,"name":"async","owner":"caolan","language":"JavaScript"},{"count":3,"name":"meteor","owner":"meteor","language":"JavaScript"},{"count":3,"name":"bootstrap","owner":"twitter","language":"JavaScript"},{"count":3,"name":"webwriter","owner":"icebeat","language":"JavaScript"},{"count":2,"name":"sspulltorefresh","owner":"samsoffes","language":"Objective-C"}]} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,93 @@ | ||
require 'rubygems' | ||
require 'a2_printer' | ||
require 'RMagick' | ||
require 'date' | ||
require 'open-uri' | ||
require 'zlib' | ||
require 'yajl' | ||
require 'json' | ||
|
||
serial = SerialConnection.new | ||
printer = A2Printer.new serial | ||
|
||
printer.begin | ||
printer.set_default | ||
def json_counter(data, json, key) | ||
data.select{|event| event["type"] == key}.each do |event| | ||
repo_name = event["repository"]["name"] | ||
if existing_event = json[key].select{|repo| repo["repository"]["name"] == repo_name}.first | ||
existing_event["count"] += 1 | ||
else | ||
json[key] << event.merge({"count" => 1}) | ||
end | ||
end | ||
end | ||
|
||
source = "/Users/alx/code/le_github/output.jpg" | ||
image = Magick::Image::read(source).first | ||
def import_bigdata | ||
date = (DateTime.now - 2).strftime("%Y-%m-%d") | ||
data = [] | ||
24.times do |index| | ||
url = "http://data.githubarchive.org/#{date}-#{index}.json.gz" | ||
p "parsing #{url}" | ||
gz = open(url) | ||
js = Zlib::GzipReader.new(gz).read | ||
data.concat(Yajl::Parser.parse("[" + js.gsub("}{", "},{") + "]")) | ||
end | ||
|
||
if(image.rows < 384) | ||
printer.print_image(source) | ||
else | ||
p "large_image" | ||
images = [] | ||
# cut images in 384px height images | ||
((image.rows / 384) + 1).times do |index| | ||
image_source = source.gsub(".jpg", "_#{index}.jpg") | ||
json_data = { | ||
"DownloadEvent" => [], | ||
"CommitCommentEvent" => [], | ||
"ForkEvent" => [], | ||
"PullRequestReviewCommentEvent" => [], | ||
"PullRequestEvent" => [], | ||
"IssueCommentEvent" => [], | ||
"IssuesEvent" => [], | ||
"PushEvent" => [], | ||
"WatchEvent" => [] | ||
} | ||
json_data.each_key{|key| json_counter(data, json_data, key)} | ||
|
||
cut_image = image.crop(0,index*384,384,384) | ||
cut_image.write image_source | ||
json_data.each do |key, repos| | ||
repos.sort!{|a, b| b["count"] <=> a["count"]}.slice!(5, repos.length) | ||
repos.map! do |repo| | ||
{ | ||
"count" => repo["count"], | ||
"name" => repo["repository"]["name"], | ||
"owner" => repo["repository"]["owner"], | ||
"language" => repo["repository"]["language"] | ||
} | ||
end | ||
end | ||
|
||
images << image_source | ||
File.open("data-#{date}.json", "w") do |file| | ||
file.write json_data.to_json | ||
end | ||
images.each do |image_source| | ||
p image_source | ||
printer.print_image(image_source) | ||
end | ||
|
||
def print | ||
serial = SerialConnection.new | ||
printer = A2Printer.new serial | ||
|
||
printer.begin | ||
printer.set_default | ||
|
||
source = "/Users/alx/code/le_github/output.jpg" | ||
image = Magick::Image::read(source).first | ||
|
||
if(image.rows < 384) | ||
printer.print_image(source) | ||
else | ||
p "large_image" | ||
images = [] | ||
# cut images in 384px height images | ||
((image.rows / 384) + 1).times do |index| | ||
image_source = source.gsub(".jpg", "_#{index}.jpg") | ||
|
||
cut_image = image.crop(0,index*384,384,384) | ||
cut_image.write image_source | ||
|
||
images << image_source | ||
end | ||
images.each do |image_source| | ||
p image_source | ||
printer.print_image(image_source) | ||
end | ||
end | ||
end | ||
|
||
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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