Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
[1] pry(main)> class Hello
| def hello
| [__method__, __callee__]
| end
|
| alias_method :new_hello, :hello
| end
=> Hello
[2] pry(main)> Hello.new.hello
=> [:hello, :hello]
Program received signal SIGSEGV, Segmentation fault.
0x0000555555696a89 in VM_EP_LEP (ep=0xc) at vm.c:28
28 if (VM_EP_LEP_P(ep)) {
(gdb) bt
#0 0x0000555555696a89 in VM_EP_LEP (ep=0xc) at vm.c:28
#1 0x0000555555696ae1 in VM_CF_LEP (cfp=0x7ffff7fdeda8) at vm.c:44
#2 0x00005555556abeaa in rb_vm_make_env_object (th=0x5555559ec550, cfp=0x7ffff7fdeda8) at vm.c:490
#3 0x0000555555579644 in rb_binding_new_with_cfp (th=0x5555559ec550, src_cfp=0x7ffff7fdeda8) at proc.c:324
#4 0x00005555556b3063 in collect_caller_bindings_iseq (arg=0x7fffffff7e50, cfp=0x7ffff7fdeda8) at vm_backtrace.c:880
#5 0x00005555556b2222 in backtrace_each (th=0x5555559ec550, init=0x5555556b2ff6 <collect_caller_bindings_init>,
@banister
banister / o.rb
Created November 1, 2012 17:23
Run last line when enter is pressed in pry
[12] pry(main)> Pry.commands.block_command /^$/, "blah" do
| run "history --replay -1"
| end
=> #<class(Pry::Command /^$/)>
[13] pry(main)> 3
=> 3
[14] pry(main)>
=> 3
[16] pry(main)> ls
self.methods: include private public to_s
[28] (pry) main: 0> class Peter
[28] (pry) main: 0* extend FakeOverloader
[28] (pry) main: 0* def ui
[28] (pry) main: 0* puts "hi"
[28] (pry) main: 0* end
[28] (pry) main: 0* def ui(v)
[28] (pry) main: 0* puts "trick"
[28] (pry) main: 0* end
[28] (pry) main: 0* end
=> nil
[7] (pry) main: 0> require 'sqlite3'
=> true
[8] (pry) main: 0> cd SQLite3
[9] (pry) main / SQLite3: 1> ls -M
[10] (pry) main / SQLite3: 1> ls -m
SQLite3.methods: const_missing libversion
[11] (pry) main / SQLite3: 1> ls -c
constants: AbortException AuthorizationException Backup Blob BusyException CantOpenException Constants ConstraintException CorruptException Database EmptyException Exception FormatException FullException InternalException InterruptException IOException LockedException MemoryException MismatchException MisuseException NotADatabaseException NotFoundException PermissionException Pragmas ProtocolException RangeException ReadOnlyException ResultSet SchemaChangedException SQLException SQLITE_VERSION SQLITE_VERSION_NUMBER Statement TooBigException Translator UnsupportedException Value VERSION VersionProxy
[12] (pry) main / SQLite3: 1> ls -M Backup
SQLite3::Backup#methods: finish pagecount remaining step
require 'Qt4'
require 'set'
require 'pry'
# Fight fire with fire
class << Qt::Internal
alias _pride_find_pclassid find_pclassid
private :_pride_find_pclassid
def find_pclassid(val)
require 'pry'
require 'pry-exception_explorer'
require 'pry-exception_explorer/shim_builder'
binary_name = "lib_overrides.#{PryExceptionExplorer::ShimBuilder::Dyname}"
if !File.exists? File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
puts "First run, building shim"
PryExceptionExplorer::ShimBuilder.compile
puts "Hopefully built...!"
@banister
banister / gist:1680784
Created January 26, 2012 03:30
binding of caller in JRuby
whitequark
headius: I just opened javadoc of jruby and tried to poke some classes through require 'java'
headius
ok
headius
whitequark: require 'jruby'; runtime = JRuby.runtime; context = runtime.current_context
headius
maybe you can poke at it from there
whitequark
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
class Match
attr_accessor :matcher, :action
def initialize(matcher, action)
@matcher, @action = matcher, action
end
end
class SwitchBitch
def initialize(value, &block)