Skip to content

Instantly share code, notes, and snippets.

View bleonard's full-sized avatar

Brian Leonard bleonard

View GitHub Profile
@bleonard
bleonard / Example.rb
Last active August 29, 2015 13:57
Resque Bus
bus = ResqueBusSpec.watch
# do stuff
events = bus.all_queued("my_event")
events.size.should == 2
event = events.first.attributes
event["action"].should == "whatever"
### Keybase proof
I hereby claim:
* I am bleonard on github.
* I am bleonard (https://keybase.io/bleonard) on keybase.
* I have a public key whose fingerprint is 7D99 EFAB 312F A0CD A182 CFA1 6D2C 6D1D 1FC9 D682
To claim this, I am signing this object:
@bleonard
bleonard / .ruby-version
Last active August 29, 2015 14:22
Big Decimal
2.1.5
class MyPlugin
def self.calculates(name)
self.calculations << name
end
def self.calculations
@calculations ||= []
end
def initialize(debug=false)
@debug = debug
def commits(&block)
mutex = Mutex.new
queue = self.repositories(username)
self.thread_count.times.map {
Thread.new do
while repo_name = mutex.synchronize { queue.pop }
# get windows and then each sha
repo_commits(repo_name, username, start_time, end_time) do |commit|
mutex.synchronize { block.call commit }
def commits(&block)
queue = self.sha_list
self.thread_count.times.map {
Thread.new do
while sha = mutex.synchronize { queue.shift }
hash = fetch_sha(sha)
commit = Commit.new(hash, repo_name, username)
mutex.synchronize { block.call commit }
end
end
program :version, '0.0.1'
program :description, 'See activity on Github.'
command :impact do |c|
c.syntax = 'hubtime impact'
c.summary = ''
c.description = 'Graph your additions and deletions'
c.option '--months INTEGER', 'How many months of history'
c.option '--user USERNAME', 'Which Github user'
c.action do |args, options|
---
- 0de33921da7ae678f09e782017eee33df69771e7
- 85030b36651be800165eea871af63b87fe31bf84
- 57fe8140f5f55e3b13172029ad15facbb970a44b
- 12027a2dc7a6ea68bd79ae20365d94320b3664e8
- 62f22aea6c96916f469f5b889999e945eb78d12f
- 938b299a81af0e821dafd179da87ac562f9039f5
- f0e8d7e364b79899d306bdd6237b55778ebfb362
- 9409b573d2135b7adda3560ebe6e15fa89b81e3f
- 285f269086ebaecd3d18023d4887c9e1f2eb6e8f
def fetch_sha(repo_name, sha)
VCR.use_cassette("#{repo_name}/shas/#{sha}", :record => :new_episodes) do
return client.commit(repo_name, sha)
end
end
def commits_window(repo_name, username, since_time, until_time)
options = { :author => username, :since =>since_time.iso8601, :until = until_time.iso8601 }
VCR.use_cassette("#{repo_name}/#{username}/commits/#{since_time.to_i}-#{until_time.to_i}", :record => :new_episodes) do
total_stats:
additions: 163007
deletions: 88260
impact: 251267
count: 1753
repo_stats:
bleonard/daily:
additions: 2172
deletions: 1257
impact: 3429