Skip to content

Instantly share code, notes, and snippets.

View osheroff's full-sized avatar

Ben Osheroff osheroff

View GitHub Profile
diff --git a/test/test_arhp.rb b/test/test_arhp.rb
index afdd783..fcea9da 100644
--- a/test/test_arhp.rb
+++ b/test/test_arhp.rb
@@ -97,7 +97,7 @@ class ActiveRecordHostPoolTest < Test::Unit::TestCase
# now, disable our auto-switching and trigger a mysql reconnect
switch_to_klass.connection.unproxied.stubs(:_switch_connection).returns(true)
- switch_to_klass.connection.execute("KILL #{thread_id}")
+ Test3.connection.execute("KILL #{thread_id}")
[maxscale]
threads=4
log_debug=1
[top service]
type=service
router=readconnroute
servers=master,slave
user=admin
passwd=123456
def verification_link(account, user)
token = user.identities.first.verification_tokens.first || user.identities.first.verification_tokens.create
link = "#{account.url(:mapped => false)}/verification/email/#{token.value}"
end
account = nil
ActiveRecord::Base.on_shard(2) do
account = Account.new(:name => "Number Four", :size => 1, :time_zone => "Copenhagen") { |a|
a.subdomain = "shardly#{rand(150)}"
a.help_desk_size = "5-20"
@osheroff
osheroff / git-prodtag
Created May 11, 2011 19:01
git-prodtag
#!/bin/bash
if [[ `git branch | grep '*' | awk '{print $2}'` != 'production' ]] ; then
echo "Only on checked out production branch, plz"
exit
fi
git fetch --tags origin
RUBY=$(cat <<endruby
require 'pp'
tags = []
@osheroff
osheroff / zd_proxy_post.js
Created June 29, 2011 18:21
zendesk proxy -- post
$j.ajax(
{
type: 'POST',
url: '/proxy/direct',
data:
{
url: "http://www.outbound.com",
body: $j.param({a: "bar", b: "buz"}),
contenttype: "application/x-www-form-urlencoded"
}
@osheroff
osheroff / code_with_scope_compile.diff
Created July 13, 2011 16:32
Don't crash when compile of CodeWScope fails
diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp
index 88f48e3..0f36817 100644
--- a/scripting/engine_spidermonkey.cpp
+++ b/scripting/engine_spidermonkey.cpp
@@ -662,6 +662,9 @@ namespace mongo {
case CodeWScope: {
JSFunction * func = compileFunction( e.codeWScopeCode() );
+ if ( !func )
+ return JSVAL_NULL;
@osheroff
osheroff / gist:1789180
Created February 10, 2012 12:12
wrap up multiple metapatches
class Module
def wrap_methods(*args)
methods = args
feature = args.pop
wrapper = "_#{feature}_wrapper"
methods.each do |method|
alias_method_chain(method, feature) do |aliased_target, punctuation|
original_method = "#{aliased_target}_without_#{feature}#{punctuation}"
class_eval <<-EOL
def #{aliased_target}_with_#{feature}#{punctuation}(*args, &block)
@osheroff
osheroff / gist:3005515
Created June 27, 2012 17:21
1.9 incompatibilities patch
class ActiveSupport::TestCase
def self.mark_19_incompat
@marked_19_incompat = true
end
def self.ruby_19_compatible?
!@marked_19_incompat
end
def run_with_19(*args, &block)
@osheroff
osheroff / gist:3005667
Created June 27, 2012 17:50
array to_s
1.8.7 :001 > ["asdf"].to_s
=> "asdf"
1.9.3p125 :001 > ["asdf"].to_s
=> "[\"asdf\"]"
@osheroff
osheroff / gist:3005917
Created June 27, 2012 18:35
marshal utf-8 enforcement
module Marshal
class << self
def load_with_utf8_enforcement(object, other_proc=nil)
@utf8_proc ||= Proc.new do |o|
o.force_encoding("UTF-8") if o.is_a?(String)
other_proc.call(o) if other_proc
o
end
load_without_utf8_enforcement(object, @utf8_proc)
end