Skip to content

Instantly share code, notes, and snippets.

View tjbladez's full-sized avatar

Nickolay Schwarz tjbladez

View GitHub Profile
# to deal with array of hashes
module ArrayExtensions
def where(criteria ={})
result = self
criteria.each do |cr_key, cr_value|
result = result.select do |hash|
hash[cr_key].to_s.match(/#{cr_value}/i)
end
end
result
@tjbladez
tjbladez / pathname.rb
Created December 29, 2010 20:30
pathname
require 'pathname'
path = Pathname.new('.') # current directory
path += 'tests' # ./tests
path += 'functional' # ./tests/functional
path = path.parent # ./tests
path += 'config.yaml' # ./tests/config.yaml
path.read # contents of ./tests/config.yaml
path.open('w'){|io| io << "env: test"}
path.read # "env: test"
path.children{|p| puts p.inspect} # prints all the files/directories in ./tests
@tjbladez
tjbladez / gist:1355995
Created November 10, 2011 20:01
release_notes
-----Original Message-----
From: Nickolay Schwarz
Sent: Friday, November 14, 2008 4:06 PM
To: All Employees
Subject: Transis Release A.7.1 Tonight
Centrons are greeted.
Releasing more code tonight.
A shine into the dawn
@tjbladez
tjbladez / computed.coffee
Created May 8, 2012 17:16
basic computed properties in backbone
Namespace.models.Base = Backbone.Model.extend
initialize: ()->
Backbone.Model::initialize @, arguments
return if _.isUndefined(@computed)
@_computed = {}
for attr, dependencies of @computed
@on "change:#{attr}", ()=>

Keybase proof

I hereby claim:

  • I am tjbladez on github.
  • I am tjbladez (https://keybase.io/tjbladez) on keybase.
  • I have a public key whose fingerprint is 3FD2 C8A7 EBCC C45C 2BB0 3B85 CF85 A886 82EA F54C

To claim this, I am signing this object:

## retry set
rs = Sidekiq::RetrySet.new
jobs = rs.select do |job|
job.klass == 'Activity::SupportReportingCacheWorker'
end
#jobs.count
jobs.each(&:delete)
## dead set
ds = Sidekiq::DeadSet.new