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
# This pattern avoids serializing a large object (the Task) to Redis, whilst | |
# avoiding passing a low-level data type (the id) into the constructor. | |
# You might choose to call TaskJob.new(task) directly elsewhere (e.g. tests) | |
class TaskJob | |
def self.perform(id) | |
new(Task.find(id)).perform | |
end | |
def initialize(task) |
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
# This hack is designed to prevent a thread from implicitly checking out an AR connection by | |
# just accessing ActiveRecord::Base.connection. The point of doing this is to ensure that threads | |
# don't tie up connections that they are not using, by making sure we're explicit about where we | |
# need to use an AR connection. | |
# | |
# See also http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord.html | |
ActiveSupport.on_load(:active_record) do | |
ActiveRecord::ConnectionAdapters::ConnectionPool # ensure loaded |
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
(function() { | |
function m() { | |
n = location.protocol + "//" + location.host + "/"; | |
r = t.ExtGuid; | |
i = t.Version; | |
s = t.PartnerId; | |
o = t.NameShort4; | |
c = t.AdServer; | |
u = t.AdCacheBuster; | |
f = t.cacheVersion || f; |
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
_ | |
/(| | |
( : | |
__\ \ _____ | |
(____) `| | |
(____)| | | |
(____).__| | |
(___)__.|_____ | |
SSt |
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 MyTestController < ApplicationController | |
def test_stuff | |
# bla | |
end | |
end | |
# Add to config/routes.rb... | |
# | |
# if Rails.env.test? | |
# map.connect '/:controller/:action/: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
$ ruby rack_proxy.rb | |
Loaded suite rack_proxy | |
Started | |
E | |
Finished in 0.004785 seconds. | |
1) Error: | |
test_foo(AppTest): | |
NoMethodError: undefined method `closed?' for nil:NilClass | |
/home/turnip/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:1069:in `begin_transport' |
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
From 42a20533837e925030b07132eaf0a2a6534ad235 Mon Sep 17 00:00:00 2001 | |
From: Jon Leighton <j@jonathanleighton.com> | |
Date: Fri, 13 May 2011 20:03:57 +0100 | |
Subject: [PATCH] Unfailing test case | |
--- | |
.../has_many_through_associations_test.rb | 21 ++++++++++++++++++++ | |
activerecord/test/schema/schema.rb | 11 ++++++++++ | |
2 files changed, 32 insertions(+), 0 deletions(-) |
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 'benchmark' | |
class Object | |
def public_send_public_method_defined(method, *args, &block) | |
singleton_class = (class << self; self; end) | |
if singleton_class.public_method_defined?(method) | |
send(method, *args, &block) | |
else | |
raise # this doesn't matter, as it's not the path we're benchmarking |
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
# 1.9.2 | |
Rehearsal ------------------------------------------------------- | |
no-send 1.950000 0.000000 1.950000 ( 1.961587) | |
symbol-send 2.190000 0.000000 2.190000 ( 2.192600) | |
string-send 4.790000 0.000000 4.790000 ( 4.812341) | |
---------------------------------------------- total: 8.930000sec | |
user system total real | |
no-send 2.330000 0.000000 2.330000 ( 2.332294) |
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 'active_record' | |
require 'logger' | |
puts "Active Record #{ActiveRecord::VERSION::STRING}" | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'mysql', | |
:user => 'root', | |
:database => 'test' | |
) |
OlderNewer