Skip to content

Instantly share code, notes, and snippets.

View osheroff's full-sized avatar

Ben Osheroff osheroff

View GitHub Profile
@osheroff
osheroff / git-start-pull-request
Created October 5, 2012 20:32
git start-pull-request
#!/bin/bash
open "https://github.com/zendesk/zendesk/pull/new/`git rev-parse --abbrev-ref HEAD`"
@osheroff
osheroff / gist:3543195
Created August 30, 2012 22:29
faster git auto-complete
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@osheroff
osheroff / gist:3165067
Created July 23, 2012 18:06
cleanup tags
git tag -d 1.4.0
git tag -d 2.2.5
git tag -d rm
git tag -d v.1.8.23
git tag -d v0.1.0
git tag -d v0.2.0
git tag -d v1.0.0
git tag -d v1.1.0
git tag -d v1.1.1
git tag -d v1.1.2
@osheroff
osheroff / gist:3005968
Created June 27, 2012 18:48
syck utf-8 compat
# force UTF-8 on all strings back from YAML.
class << YAML::DefaultResolver
def node_import_with_utf8(node)
val = node_import_without_utf8(node)
val.force_encoding("UTF-8") if val.respond_to?(:force_encoding)
val
end
alias_method_chain :node_import, :utf8
@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
@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: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: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 / 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 / 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"
}