Skip to content

Instantly share code, notes, and snippets.

View matthewd's full-sized avatar

Matthew Draper matthewd

View GitHub Profile

Keybase proof

I hereby claim:

  • I am matthewd on github.
  • I am matthewd (https://keybase.io/matthewd) on keybase.
  • I have a public key whose fingerprint is 4BBC 6089 979B 399C AD3C 246D 9C0D 2BE6 590D 2B86

To claim this, I am signing this object:

@matthewd
matthewd / gist:b74b0de5244b2a95952b
Last active August 29, 2015 14:00
gsub forwarding with $1
class X < String
def evil_call(meth, args, block, &wrap_block)
block.binding.eval(<<-END, __FILE__, __LINE__+1).call(to_str, meth, args, wrap_block)
lambda do |str, meth, args, block|
str.send(meth, *args, &block)
end
END
end
def gsub(*args, &block)
@matthewd
matthewd / post-checkout.sh
Created June 14, 2014 07:16
Per-branch Gemfile.lock
#!/bin/bash
if [ "$3" = 1 ]; then
old_branch="`git name-rev --name-only --no-undefined "$1" | cut -d'~' -f1`"
new_branch="`git name-rev --name-only --no-undefined "$2" | cut -d'~' -f1`"
if [ "$old_branch" != "$new_branch" ]; then
mv -f "Gemfile.lock" ".Gemfile/lock.$old_branch"
if [ -f ".Gemfile/lock.$new_branch" ]; then
mv -f ".Gemfile/lock.$new_branch" "Gemfile.lock"
diff --git a/vmdb/lib/acts_as_ar_model.rb b/vmdb/lib/acts_as_ar_model.rb
index e23a20f..d6838a8 100644
--- a/vmdb/lib/acts_as_ar_model.rb
+++ b/vmdb/lib/acts_as_ar_model.rb
@@ -1,16 +1,3 @@
-class ActsAsArModelColumn < ActiveRecord::ConnectionAdapters::Column
- attr_reader :options
-
- def initialize(name, options)
- type = options.kind_of?(Symbol) ? options : options[:type]
diff --git a/spec/helpers/application_helper/toolbar_builder_spec.rb b/spec/helpers/application_helper/toolbar_builder_spec.rb
index 546ce2b..81ce5f3 100644
--- a/spec/helpers/application_helper/toolbar_builder_spec.rb
+++ b/spec/helpers/application_helper/toolbar_builder_spec.rb
@@ -3,11 +3,14 @@
describe ApplicationHelper do
before do
controller.send(:extend, ApplicationHelper)
- self.class.send(:include, ApplicationHelper)
end
From ad920f9466238692614d510e165f94c8bcdec838 Mon Sep 17 00:00:00 2001
From: Matthew Draper <matthew@trebex.net>
Date: Fri, 26 Feb 2010 00:16:35 +1030
Subject: [PATCH] Remove duplicate module_function call in kernel.rb
Cleans up a copy & paste error I introduced two years ago.
---
kernel/common/kernel.rb | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
From e31a244f78dfcdeef1381a24a657a6779792767c Mon Sep 17 00:00:00 2001
From: Matthew Draper <matthew@trebex.net>
Date: Sat, 13 Mar 2010 19:26:58 +1030
Subject: [PATCH 1/3] Correctly handle large numeric Config values.
Previously, values > Fixnum::MAX would behave incorrectly.
In passing, also fix handling of negative values: don't strip their
sign(!), but still treat them as numeric.
---
From 7b4f0646096edb78b4ca48ba028576fded3369d0 Mon Sep 17 00:00:00 2001
From: Matthew Draper <matthew@trebex.net>
Date: Sun, 14 Mar 2010 15:28:39 +1030
Subject: [PATCH] Improve & extend Kernel.{rand,srand} specs.
---
spec/ruby/core/kernel/rand_spec.rb | 101 +++++++++++++++++++++++++++++++----
spec/ruby/core/kernel/srand_spec.rb | 35 +++++++++++--
2 files changed, 121 insertions(+), 15 deletions(-)
From 695d27766eeff690dd530e9bc1933365367ed85d Mon Sep 17 00:00:00 2001
From: Matthew Draper <matthew@trebex.net>
Date: Sat, 10 Apr 2010 02:51:26 +0930
Subject: [PATCH] Improved Kernel.{rand,srand} implementation.
Doesn't yet produce extra randomness to properly fill a bignum range.
---
benchmark/rubinius/bm_random.rb | 50 ++++++++++++++++++
kernel/common/kernel.rb | 64 +++++++----------------
kernel/common/load_order.txt | 1 +
require 'benchmark'
total = (ENV['TOTAL'] || 10_000).to_i
unless defined?(Rubinius)
module Rubinius
Tuple = Array
WORDSIZE = 32
end
class Fixnum