Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
Pry::Commands.create_command "find-method" do
description "find-method"
def options(opti)
opti.on :n, :name, "Search for a method by name"
opti.on :c, :content, "Search for a method based on content in Regex form"
end
def process
@banister
banister / output
Created January 26, 2012 03:52 — forked from headius/output
system ~/projects/jruby $ jirb
>> require 'java'
=> true
>> binding = Thread.current.to_java.getContext.nth_binding(4)
=> #<Java::OrgJrubyRuntime::Binding:0x304648>
>> binding = org.jruby.RubyBinding.new(JRuby.runtime, JRuby.runtime.binding, binding)
=> #<Binding:0x8b3bb3>
>> binding = JRuby.dereference(binding)
=> #<Binding:0x8b3bb3>
>> eval "__FILE__", binding
@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
@banister
banister / gist:1393982
Created November 25, 2011 17:05 — forked from chad/gist:560003
typedef struct {
VALUE *pc; /* cfp[0] */
VALUE *sp; /* cfp[1] */
VALUE *bp; /* cfp[2] */
rb_iseq_t *iseq; /* cfp[3] */
VALUE flag; /* cfp[4] */
VALUE self; /* cfp[5] / block[0] */
VALUE klass; /* cfp[6] / block[1] */
VALUE *lfp; /* cfp[7] / block[2] */
VALUE *dfp; /* cfp[8] / block[3] */
@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?("'")
require "file2s3/version"
require 'fileutils'
require 'pathname'
class File2s3
S3_DIRS = %w(30days_of_uploads_to_s3 to_upload_to_s3)
def initialize(opts)
@access_key = opts[:access_key]
@secret_key = opts[:secret_key]
@banister
banister / script.txt
Created July 11, 2011 01:15 — forked from JoshCheek/script.txt
script for Pry session
Notation:
"This will be spoken"
`this will be entered at the terminal`
"`This will be spoken as it is entered`"
# this is a comment
* This indicates screen control, such as slide introduciton/transition switches to terminal, etc
------------------------------
# Don't forget simple prompt
@banister
banister / development.rb
Created April 27, 2011 14:21 — forked from MyArtChannel/development.rb
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
module Helper
def helper_method
puts "I'm helping"
end
end
class Main
include Helper
def show
module MyMod
# store the variable on the module itself
var = "initial value"
# first method that accesses the var
define_method :get_var do
var
end