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
races = Race.where(runs_at: (Date.today - 12.months)..Date.today) | |
variants_queue = # big queue! | |
workers = [] | |
results = [] | |
best_strike_rate = [0, nil] | |
best_avg = [100, nil] | |
mutex = Mutex.new |
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 GenericLicence < ActiveRecord::Base | |
self.abstract_class = true | |
# blah blah blah | |
end | |
class FooLicence < GenericLicence | |
end | |
class BarLicence < GenericLicence |
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
# # # | |
# If you pass: | |
# - String, then it highlight for that controller name | |
# - Array, then it will highlight for those actions | |
# - Hash, then it will highlight for only those controller and action combinations | |
# | |
def is_active?(controller_action_hash_or_array_or_string) | |
controller = params[:controller] | |
action = params[:action] |
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
validate :ensure_past_expiration_date | |
def ensure_past_expiration_date | |
unless expiration_date > Date.today || expiration_date_was < Date.today | |
errors.add(:expiration_date, "can't be in the past") | |
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
<%= render "#{@step}_form" %> |
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 run(scope, dbs) | |
results = {} | |
threads = [] | |
dbs.each do |db| | |
threads = Thread.new do | |
while_connected_to(db) do |conn| | |
query_model = scope.model | |
puts "USING CONN: #{conn.object_id} as opposed to #{Student.connection.object_id}" | |
result_set = conn.select_all(scope.to_sql, "My Super Special Fab Load") |
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
irb(main):045:0> ERB.new("<% if true -%>\nhi\n<% else %>\nbye\n<% end %>", nil, "-").result # old rails with '-' | |
=> "hi\n" | |
irb(main):047:0> ERB.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>", nil, "-").result # old rails without '-' | |
=> "\nhi\n" | |
irb(main):048:0> Erubis::Eruby.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>").result # new rails with Erubis default trim | |
=> "hi\n" | |
irb(main):049:0> Erubis::Eruby.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>", trim: false).result # Erubis with trimming turned off | |
=> "\nhi\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
module ScopeValidators | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def validates(*args) | |
options = args.extract_options! | |
if options.key?(:uniqueness) | |
case options[:uniqueness] | |
when Hash | |
options[:uniqueness].merge!(scope: :entity_id) |
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
description "DELAYED JOB" | |
start on (local-filesystems | |
and net-device-up | |
and runlevel [2345]) | |
stop on runlevel [!2345] | |
chdir /home/apps/app_name/current | |
exec /usr/bin/env RAILS_ENV=production HOME=/home/apps /home/apps/.rvm/wrappers/ruby-2.0.0-p353/rake jobs:work >> /tmp/upstart.log 2>&1 |
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 Test2 | |
class << self | |
@var = "foo" | |
def test_method | |
@var | |
end | |
end | |
end |