Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
@banister
banister / test intercept.rb
Created January 17, 2012 03:59
intercepting test errors in bacon
crow:play john$ bacon bacon_intercept.rb
/Users/john/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.8pre4/lib/pry/pry_class.rb:207:
alpha
- should be empty
Frame number: 0/16
Frame type: method
From: /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/bacon-1.1.0/lib/bacon.rb @ line 331 in Should#satisfy:
@banister
banister / gist:1492939
Created December 18, 2011 10:12
Rails in gdb
rails in gdb c/o ryanf:
gdb --args ruby `which rails` server
@banister
banister / gist:1492606
Created December 18, 2011 07:03
pry segfault
/usr/local/lib/ruby/gems/1.9.1/gems/pry-stack_explorer-0.2.6pre2/lib/pry-stack_explorer.rb:62: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30) [x86_64-darwin11.2.0]
-- Control frame information -----------------------------------------------
c:0078 p:---- s:0439 b:0439 l:000438 d:000438 CFUNC :callers
c:0077 p:0076 s:0436 b:0436 l:0021e8 d:002190 BLOCK /usr/local/lib/ruby/gems/1.9.1/gems/pry-stack_explorer-0.2.6pre2/lib/pry-stack_explorer.rb:62
c:0076 p:---- s:0429 b:0429 l:000428 d:000428 FINISH
c:0075 p:---- s:0427 b:0427 l:000426 d:000426 CFUNC :call
c:0074 p:0017 s:0422 b:0422 l:000406 d:000421 BLOCK /Users/leepfrog/.bundler/ruby/1.9.1/pry-36d685f71fd6/lib/pry/hooks.rb:40
c:0073 p:---- s:0418 b:0418 l:000417 d:000417 FINISH
Pry.commands.command "alias" do |name, action|
Pry.commands.command name do |*args|
run action, *args
end
end
# => #<struct Pry::CommandSet::Command
# name="alias",
# description="No description.",
# options=
# {:requires_gem=>[],
# Original Benchmark used to consider whether to keep define_method or switch
# to instance_exec for Sinatra 1.3.0.
#
# == Ruby 1.8.7
# instan_exec 0.650000 0.000000 0.650000 ( 0.650820)
# instan_eval 0.620000 0.000000 0.620000 ( 0.621846)
# bind.call 0.140000 0.010000 0.150000 ( 0.141961)
#
# == Ruby 1.9.2
# user system total real
begin
require 'coolline'
Pry.config.input = Coolline.new do |cool|
cool.word_boundaries = [" ", "\t", ",", ";", ".", '"', "'", "`", "<", ">",
"=", ";", "|", "{", "}", "(", ")", "-"]
cool.history_file = Coolline::NullFile
cool.transform_proc = proc do
SmallInt => # self becomes SmallInt
define multiply_by: n and_add: stuff
self * n + stuff
Foo := Object subclass => # (=> has a very low precedence)
define love # love is an odd, little thing.
3
Block =>
define call
SmallInt =>
define multiply_by: n and_add: stuff
self * n + stuff
Foo := Object subclass =>
define love
3
Block =>
define call
@banister
banister / valid_ruby.rb
Created November 17, 2011 15:20 — forked from judofyr/valid_ruby.rb
Checks if a string is valid Ruby
def valid_ruby?(str)
catch(:valid) {
eval("BEGIN{throw :valid,true};#{str}")
}
rescue SyntaxError
false
end
p valid_ruby?("123")
p valid_ruby?("'")
Changes in HEAD
Modified lib/pry/pry_instance.rb
diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb
index 7510525..7f42f9c 100644
--- a/lib/pry/pry_instance.rb
+++ b/lib/pry/pry_instance.rb
@@ -208,9 +208,16 @@ class Pry
def re(target=TOPLEVEL_BINDING)
target = Pry.binding_for(target)