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
doppleganger = Class.new(ActiveRecord::Base) | |
doppleganger.set_table_name "latest_#{self.class.table_name}" | |
Object.const_set "Latest#{self.class.name}", doppleganger | |
doppleganger.find(:first, :conditions => ...) |
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
What's documented: | |
StreetAddress.find(1, :params => { :person_id => 1 }) | |
# => GET /people/1/street_addresses/1.xml | |
What actually happens: | |
StreetAddress.find(1, :params => { :person_id => 1 }) | |
# => GET /street_addresses/1.xml?person_id=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 Enumerable | |
def most?(&block) | |
trues = 0 | |
falses = 0 | |
each do |item| | |
if yield(item) | |
trues += 1 | |
else | |
falses += 1 | |
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
def last_wednesday | |
today = Date.today | |
backup = ((4 + today.wday) % 7) | |
today - backup | |
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
def remote_file_exists?(full_path) | |
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip | |
end | |
namespace :remote do | |
namespace :file do | |
desc "test existence of missing file" | |
task :missing do | |
if remote_file_exists?('/dev/mull') | |
raise "It's there!?" |
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
ted@ceylon ~/Sites/asm/config/cloud-crowd »crowd load_schema | |
-- create_table("jobs", {:force=>true}) | |
-> 0.1031s | |
-- create_table("node_records", {:force=>true}) | |
-> 0.1444s | |
-- create_table("work_units", {:force=>true}) | |
-> 0.1000s | |
-- initialize_schema_migrations_table() | |
-> 0.0009s | |
-- assume_migrated_upto_version(3) |
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
ted@ceylon ~/Sites/asm/config/cloud-crowd »gem list | grep -i rails | |
autotest-rails (4.1.0) | |
rails (2.3.4, 2.3.2, 2.2.2, 1.2.6) | |
ted@ceylon ~/Sites/asm/config/cloud-crowd »crowd node | |
Starting CloudCrowd Node on port 9063... | |
Missing the Rails 2.3.2 gem. Please `gem install -v=2.3.2 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. |
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
RAILS_GEM_VERSION = nil | |
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) | |
RAILS_ENV = ENV['RAILS_ENV'] || 'development' | |
if CloudCrowd.node? | |
require 'rubygems' | |
require 'activerecord' | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'environment')) | |
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
some_variable = begin | |
if some_condition? | |
some_value | |
else | |
another_value | |
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
class Array | |
def indifferent_intersection(other) | |
self.collect{|i| i.to_sym} & other.collect{|i| i.to_sym} | |
end | |
end | |
class Hash | |
def keyqual?(other) | |
return true if other.nil? | |
intersecting_keys = self.keys.indifferent_intersection(other.keys) |