Skip to content

Instantly share code, notes, and snippets.

_
/(|
( :
__\ \ _____
(____) `|
(____)| |
(____).__|
(___)__.|_____
SSt
(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 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 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)
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
else
ARGV.unshift "rails"
load Gem.bin_path("spring", "spring")
end
@jonleighton
jonleighton / output.txt
Created November 18, 2013 23:22
A demonstration that "unscoped" just clobbers everything in the scope chain
-- create_table(:posts)
-> 0.0189s
-- create_table(:comments)
-> 0.0005s
4.0.1
SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? ORDER BY comments.id desc
SELECT "comments".* FROM "comments"
SELECT "comments".* FROM "comments"
# Rails 4.0
-- create_table(:posts)
-> 0.0217s
-- create_table(:comments)
-> 0.0005s
4.0.1
SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? ORDER BY comments.id desc
SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? ORDER BY comments.id desc
SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? ORDER BY comments.id desc
$ openssl s_client -connect rubygems.org:443 -debug -msg
CONNECTED(00000003)
write to 0xb92060 [0xbb2f30] (309 bytes => 309 (0x135))
0000 - 16 03 01 01 30 01 00 01-2c 03 03 52 68 4c 7f bb ....0...,..RhL..
0010 - 25 c9 a9 52 57 c5 34 f2-c3 b9 94 a7 ce a9 8b 8d %..RW.4.........
0020 - a8 5e fc b5 6f e4 87 5f-98 22 3a 00 00 94 c0 30 .^..o.._.":....0
0030 - c0 2c c0 28 c0 24 c0 14-c0 0a 00 a3 00 9f 00 6b .,.(.$.........k
0040 - 00 6a 00 39 00 38 00 88-00 87 c0 32 c0 2e c0 2a .j.9.8.....2...*
0050 - c0 26 c0 0f c0 05 00 9d-00 3d 00 35 00 84 c0 12 .&.......=.5....
0060 - c0 08 00 16 00 13 c0 0d-c0 03 00 0a c0 2f c0 2b ............./.+
$ openssl s_client -connect rubygems.org:443 -debug -msg
CONNECTED(00000003)
write to 0xcb8060 [0xcd8f30] (309 bytes => 309 (0x135))
0000 - 16 03 01 01 30 01 00 01-2c 03 03 52 68 47 d9 e4 ....0...,..RhG..
0010 - 39 d3 25 3a a8 e5 36 90-4b 63 9a f1 bf 55 57 a0 9.%:..6.Kc...UW.
0020 - a8 28 66 f2 b1 42 92 5f-2e 5b f2 00 00 94 c0 30 .(f..B._.[.....0
0030 - c0 2c c0 28 c0 24 c0 14-c0 0a 00 a3 00 9f 00 6b .,.(.$.........k
0040 - 00 6a 00 39 00 38 00 88-00 87 c0 32 c0 2e c0 2a .j.9.8.....2...*
0050 - c0 26 c0 0f c0 05 00 9d-00 3d 00 35 00 84 c0 12 .&.......=.5....
0060 - c0 08 00 16 00 13 c0 0d-c0 03 00 0a c0 2f c0 2b ............./.+