This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid_ruby?(str) | |
catch(:valid) { | |
eval("BEGIN{throw :valid,true};#{str}") | |
} | |
rescue SyntaxError | |
false | |
end | |
p valid_ruby?("123") | |
p valid_ruby?("'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helper | |
def helper_method | |
puts "I'm helping" | |
end | |
end | |
class Main | |
include Helper | |
def show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |