Skip to content

Instantly share code, notes, and snippets.

View rocky's full-sized avatar

R. Bernstein rocky

View GitHub Profile
# How to use.
# $ irb
# >> load 'irb-hack-no-tf.rb' # Substitute file path. NOTE: 'load', not 'require'
# >> # work, work, work... look at CLASSES, METHODS and MODULES
require 'irb'
$IRBHACK_DEBUG = true
# irb-hack.rb without threadframe and trace modules. However since
# there is still a bug in the way Ruby handles c-call events (it calls the
# hook before pushing the the frame), this doesn't catch "define-method"
@rocky
rocky / gist:825393
Created February 14, 2011 02:16
Save text of methods defined inside IRB with the same line numbers as would be reported in a traceback. ThreadFrame version
require 'irb'
require 'trace'
include Trace
CLASSES = {}
METHODS = {}
MODULES = {}
CHECK_METHODS = %w(define_method method_added singleton_method_added CLASS)
def capture_hook(event, frame, arg=nil)
@rocky
rocky / find_main_script.asm
Created April 24, 2011 00:49
Rubinius then/else goto tagged as part of else
========== :find_main_script ===========
Arguments: 1 required, 1 total
Locals: 2: i, loc
Stack size: 7
Lines to IP: 19: 0..3, 20: 4..14, 21: 15..28, 22: 29..39, 23: 40..72, 24: 73..87, 26: 88..94, 28: 95..107, 22: 108..109
0000: cast_for_single_block_arg
0001: set_local 0
0003: pop
0004: push_local_depth 1, 0
============= :__script__ ==============
Arguments: 0 required, 0 total
Locals: 0
Stack size: 5
Lines to IP: 1: 0..9, 1073741823: 10..17, 1: 18..41, 1073741823: 42..47
0000: push_exception_state
0001: set_stack_local 0
0003: pop
0004: setup_unwind 13, 0
@rocky
rocky / after-patch.log
Created May 15, 2011 23:35
Changes to Kate Ward's shunit2 to handle multiple files and aggregated tests
/usr/bin/zsh /src/external-vcs/zshdb/test/unit/shunit2 test-action.sh test-break.sh test-cmd-complete.sh test-columns.sh test-dbg-opts.sh test-eval.sh test-examine.sh test-file.sh test-filecache.sh test-fns.sh test-get-sourceline.sh test-journal.sh test-lib-shell.sh test-msg.sh test-pre.sh test-run.sh test-tty.sh
test_action
test_breakpoint
test_cmd_complete
test_columnized
test_dbg_opts
test_eval_subst
test_examine
test_file_glob_filename
test_file_adjust_filename
@rocky
rocky / gist:1151261
Created August 17, 2011 10:14
rubinius 2.0-pre issue with rbx-trepanning
    def debugger(settings = {:immediate => false})
    @settings = @settings.merge(settings)
    skip_loader if @settings[:skip_loader]
    spinup_thread
    puts "1"
    @debugee_thread = @thread
    # if @settings[:hide_level]
    #   @processor.hidelevels[@thread] = @settings[:hide_level]
    # end
@rocky
rocky / enbugger-bug1.pl
Created March 13, 2012 02:36
Enbugger bug1
#!/usr/bin/env perl
eval <<'EOE';
use Enbugger;
Enbugger->load_debugger('perl5db');
Enbugger->stop;
$x = 1;
$y = 2;
EOE
#!/usr/bin/env perl
use Enbugger;
eval <<'EOE';
sub five()
{
Enbugger->stop; # Does not stop
my $x = 1;
return 5;
}
EOE
package main
import (
"bufio"
"fmt"
"os"
"sort"
)
// A PathCount object contains the data that we want to sort on.
@rocky
rocky / pidof
Created November 13, 2014 14:40
Unix pidof for OSX
#!/usr/bin/env ruby
# pidof for OSX. Basically a small modification of doitian's gist
target = ARGV[0] || ""
ids = []
`/bin/ps -ax -o pid,comm`.split("\n").each do |line|
pid, command = line.chomp.split(' ', 2)
short_command = File.basename(command)
if target == command or target == short_command or
target =~ /^[-]?#{short_command}/
ids << pid