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
require 'resque' | |
require 'resque_scheduler' | |
require 'resque/scheduler' | |
module ResqueSchedulerPatches | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
alias_method_chain :delayed_timestamp_peek, :rescue | |
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
#Deploy and rollback on Heroku in staging and production | |
%w[staging production].each do |app| | |
desc "Deploy to #{app}" | |
task "deploy:#{app}" => %W[deploy:set_#{app}_app deploy:push deploy:restart deploy:tag] | |
desc "Deploy #{app} with migrations" | |
task "deploy:#{app}:migrations" => %W[deploy:set_#{app}_app deploy:push deploy:off deploy:migrate deploy:restart deploy:on deploy:tag] | |
desc "Rollback staging" |
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
nested_arrays = [[:a,:b,[:c,:d]],[:w,:x,[:y,:z]]] | |
nested_arrays.each do |(first, second, (inner_first, inner_last))| | |
puts first | |
puts inner_first | |
end | |
# => | |
# a | |
# 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
class Game | |
include Mongoid::Document | |
def aliased_attributes | |
attributes.inject({}) { |attrs, (raw_key, raw_value)| | |
attrs[Game.aliased_fields.invert.fetch(raw_key) { raw_key }] = raw_value | |
attrs | |
} | |
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
module HeroAttributes | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def abilities | |
self.class.abilities | |
end | |
module ClassMethods |
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
def base_finalizer_class | |
return GameFinalizer unless game.sport | |
case game.sport.class_name | |
when "IceHockey" | |
Sports::IceHockey::GameFinalizer | |
when "Baseball" | |
Sports::Baseball::GameFinalizer | |
when "Lacrosse" | |
Sports::Lacrosse::GameFinalizer | |
when "RugbyUnion" |
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
RSpec.configure do |config| | |
config.before do | |
Rails.cache.clear unless self.class.metadata[:cache] | |
end | |
end | |
describe "doing stupid stuff" do | |
#... | |
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
class Hash | |
def split_by(&block) | |
[select(&block), reject(&block)] | |
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
[alias] | |
recent-asc = for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short)\n%(committerdate)\t%(authorname)\n' | |
recent-desc = for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)\n%(committerdate)\t%(authorname)\n' |
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
class Foo | |
attr_accessor :bar | |
def initialize | |
self.bar = "bar" | |
end | |
def baz | |
bar = "baz" if false | |
bar |