Created
April 4, 2011 20:21
-
-
Save jamster/902339 to your computer and use it in GitHub Desktop.
How many fucking people have gitub hired?
This file contains hidden or 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 'rubygems' | |
require 'activesupport' | |
require 'bad_ass_extensions' | |
require 'nokogiri' | |
require 'open-uri' | |
class GitHubber | |
attr_accessor :header, :name, :date, :date_string, :links, :post | |
def initialize(hash, post) | |
@header = hash[:header] | |
@name = hash[:name] | |
@date_string = hash[:date].to_s | |
@date = DateTime.parse(@date_string) | |
@links = hash[:links] | |
@post = post | |
end | |
def to_s | |
output = <<-OUTPUT | |
Name: #{@name} | |
Hire Date: #{@date} | |
Links: | |
\t#{@links.join("\n\t")} | |
OUTPUT | |
end | |
end | |
BASE_URL = 'https://github.com/blog?page=' | |
hires = [] | |
# Scrape the past 30 Github Blog Pages | |
30.times.each do |page| | |
doc = Nokogiri::HTML(open(BASE_URL+page.to_s)) | |
posts = doc.css('li.hentry') | |
posts.each do |post| | |
hires << post if post.css('h2').text.downcase =~ /is a githubber/ | |
end | |
end | |
# Get the name, hire date, and some links | |
hires = hires.map do |hire| | |
header = hire.css('h2').text | |
name = header.split(" is a GitHubber").first | |
date = hire.css('span.published').attribute('title') | |
github_links = hire.css('div.entry-content a').select{|a| a.attribute('href').to_s =~ /^https:\/\/github\.com\/([^blog])/} | |
githubber = { | |
:header => header, | |
:name => name, | |
:date => date, | |
:links => github_links | |
} | |
# Build that githubber, biotch | |
GitHubber.new(githubber, hire) | |
end | |
# HOW MANY UNICORNY GITHUBBERS WERE UNICORNY HIRED!?!?!?! | |
hires.each{|h| puts h} | |
dates = hires.map{|h| h.date}.sort | |
start = dates.first | |
finish = dates.last | |
# HOW LONG HAVE THEY BEEN SUCKING UP ALL THE UNICORNY TALENT?!?!?!?! | |
time_between = Date.days_between(start.to_date, finish.to_date) | |
puts "Github has hired #{hires.length} talented UNICORNY people in the past #{time_between} UNICORNY days" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment