This file contains hidden or 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 Monty | |
STAY = true | |
SWITCH = false | |
def initialize(strat = STAY) | |
@strategy = strat | |
@times_won = 0 | |
end | |
def play(n) |
This file contains hidden or 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
task "resque:setup" => :environment do | |
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } | |
end |
This file contains hidden or 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
`mongoimport --host #{host} --db #{db} --collection #{collection} --type #{type} --file #{file} --upsert --upsertFields #{upsertFields}` |
This file contains hidden or 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
db.$cmd.findOne({group : { | |
ns : "listings", | |
cond : { state: "TX"}, | |
key : {state : 1, city_slug: 1}, | |
initial : {count : 0}, | |
$reduce : function(obj,prev){prev.count++;}}}) |
This file contains hidden or 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
# working on testing loops like the one below | |
# describe Foo do | |
# it "should write hi" do | |
# Bar.stubs(:create) | |
# Delayed::Job.stubs(:enqueue) | |
# Bar.stubs(:first).returns(Bar.new, nil) | |
# Foo.any_instance.stubs(:sleep) | |
# foo = Foo.new | |
# foo.should_receive(:puts).with("hi") | |
# foo.should_receive(:sleep).with(1) |
This file contains hidden or 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
default = { | |
"key1" => "val1", | |
"key2" => "val2", | |
"key3" => { | |
"1" => "one", | |
"2" => "two" | |
}, | |
"key4" => "four" | |
} | |
custom = { |
This file contains hidden or 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
$(document).ready(function() { | |
setTimeout(function() { | |
$('#april_fools').css('-moz-transform', 'rotate(0deg)'); | |
}, 5000) | |
)}; |
This file contains hidden or 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
agent = WWW::Mechanize.new | |
agent.user_agent_alias = 'Mac FireFox' | |
page = agent.get('https://www.linkedin.com/secure/login') | |
page = page.form_with(:name => 'login') do |f| | |
f.session_key = "[email protected]" | |
f.session_password = "notreal" | |
end.submit | |
page = agent.get('http://www.linkedin.com/home') |
This file contains hidden or 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
jQuery(function() { | |
$.cookie('tz', (new Date()).getTimezoneOffset()); | |
}); |
This file contains hidden or 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 ActiveRecord | |
module Associations | |
module ClassMethods | |
private | |
@@valid_keys_for_belongs_to_association = [ | |
:class_name, :primary_key, :foreign_key, :foreign_type, :remote, :select, :conditions, | |
:include, :dependent, :counter_cache, :extend, :polymorphic, :readonly, :joins, # added :joins key | |
:validate, :touch | |
] | |
@@valid_keys_for_has_many_association = [ |
NewerOlder