I hereby claim:
- I am spickermann on github.
- I am spickermann (https://keybase.io/spickermann) on keybase.
- I have a public key whose fingerprint is 38D8 D438 A43B D6F5 88B1 80BF D461 0A5C 9AC5 CB5D
To claim this, I am signing this object:
def deeply_sort_hash(object) | |
return object.sort if object.is_a?(Array) | |
return object unless object.is_a?(Hash) | |
hash = RUBY_VERSION >= '1.9' ? Hash.new : ActiveSupport::OrderedHash.new | |
object.each { |k, v| hash[k] = deeply_sort_hash(v) } | |
sorted = hash.sort_by { |(k, v)| [v.is_a?(String) ? 0 : 1, k.to_s.downcase] } | |
hash.class[sorted] | |
end |
# 1. Clear retry set | |
Sidekiq::RetrySet.new.clear | |
# 2. Clear scheduled jobs | |
Sidekiq::ScheduledSet.new.clear | |
# 3. Clear 'Processed' and 'Failed' jobs |
RSpec.shared_examples 'a model with an uuid' do | |
subject(:instance) { FactoryGirl.create(described_class.name.downcase) } | |
it { should have_readonly_attribute(:id) } | |
describe '.find' do | |
it 'finds by uuid' do | |
expect( | |
described_class.find(instance.id) | |
).to eq(instance) |
I hereby claim:
To claim this, I am signing this object:
# spec/support/factory_girl.rb | |
# This file is here to limit the use of factories to only integration tests and not unit tests. | |
# | |
# If you really want to use a factory you can add the tag :factories to a test | |
# | |
module FactoryGirlBlocker | |
mattr_accessor :disabled | |
def self.with_disabled | |
self.disabled = true |
# Script using [qpdf](http://qpdf.sourceforge.net/) to | |
# remove the password from all pdf files in a given | |
# directory and its subdirectories. | |
# | |
# Install qpdf with brew | |
# | |
# brew install qpdf | |
# | |
require 'fileutils' |
class Foo | |
def initialize(foo) | |
@foo = foo | |
end | |
def foo | |
@foo | |
end | |
def -@ # This is awesome | |
Foo(-foo) | |
end |
def array_unshift | |
foo = [:foo, :bar, :bar] | |
foo.unshift(:something) | |
end | |
def array_concat | |
foo = [:something] | |
foo.concat([:foo, :bar, :bar]) | |
end |
# foo = 1 | |
# 5.times do |foo| | |
# puts foo | |
# end | |
# return foo #=> returns 5 in Ruby 1.8, but 1 in Ruby 1.9 | |
def files | |
Dir.glob('**/*.rb') | |
end |
# depends on: https://github.com/masover/blankslate | |
# | |
# user = User.new(:name => 'foo') | |
# user.name #=> 'foo' | |
# Decorator.new(user).name #=> 'foo' | |
# | |
# but | |
# Decorator.new(user, :name => 'bar').name #=> 'bar' | |
class Decorator < BlankSlate |