Skip to content

Instantly share code, notes, and snippets.

View phiggins's full-sized avatar

pete higgins phiggins

View GitHub Profile
diff --git a/lib/debride.rb b/lib/debride.rb
index 54e2f4f..7730457 100755
--- a/lib/debride.rb
+++ b/lib/debride.rb
@@ -35,31 +35,36 @@ class Debride < MethodBasedSexpProcessor
end
def self.load_plugins proj = PROJECT
- unless defined? @@plugins then
- @@plugins = []
require 'spec_helper'
describe User do
it "should blow up" do
expect(User).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique)
end
end
=begin
Fails with:
Failure/Error: expect(View).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique)
ArgumentError:
wrong number of arguments (0 for 2)
module Kernel
def method_a
:foo
end
end
def method_b
:bar
end
@phiggins
phiggins / gist:6691237
Created September 24, 2013 21:07
Kernel require monkeypatch
module Kernel
def required(arg=nil)
method = caller_locations(1,1)[0].label
raise ArgumentError.new("required parameter #{arg.to_sym.inspect + ' ' if arg}not passed to method #{method}")
end
end
require 'net/http'
require 'json'
require 'uri'
require 'pp'
uri = URI(ARGV[0])
pp JSON.parse(Net::HTTP.get_response(uri).body)
@phiggins
phiggins / ar_inverse_of_test.rb
Last active December 16, 2015 18:29
AR inverse_of doesn't work after creation of associated things.
require 'active_record'
require 'sqlite3'
require 'minitest/autorun'
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
@phiggins
phiggins / gist:5357237
Created April 10, 2013 18:34
rdoc's rake newb without kpeg
[11:30:26 rdoc (master u=)]$ gem list
*** LOCAL GEMS ***
bundler (1.3.5, 1.1.5, 1.1.3)
hoe (3.5.3)
rake (10.0.4, 0.9.2.2)
rubygems-bundler (1.1.1, 1.0.7, 1.0.1, 1.0.0)
rvm (1.11.3.5)
[11:30:29 rdoc (master u=)]$ rake newb
@phiggins
phiggins / benchmark output
Last active December 15, 2015 20:19
Patch to allow Ruby's Array#map to take a symbol.
$ ./ruby -I. -Ilib/ -w map_symbol_bench.rb
Rehearsal --------------------------------------------
nil 0.050000 0.000000 0.050000 ( 0.046891)
identity 0.880000 0.000000 0.880000 ( 0.887874)
block 1.080000 0.000000 1.080000 ( 1.078556)
to_proc 0.990000 0.000000 0.990000 ( 0.996956)
----------------------------------- total: 3.000000sec
user system total real
nil 0.040000 0.000000 0.040000 ( 0.045237)
@phiggins
phiggins / gist:5251001
Last active December 15, 2015 11:09
seattlerb omg
Hello ruby friends,
Next Tuesday night is Seattle.rb's monthly talkie meetup! Things will be going as planned with one big exception:
Ryan, Aja and I will all be travelling to Mountain West Ruby Conf that night. Don't worry though, two of my Substantial
coworkers have offered to host in my stead. Cassie Schmitz and Shawn Dempsey will be the ones who will let you in the door,
tell you the wifi password, direct you towards the restrooms and urge you to leave at the end. Everything else will be the
same, although I cannot promise you'll hear another of Aaron's thrilling tales of candy purchasing.
Let me know if you have questions or concerns!