View test.rb
ruby_code = <<-eorby
def foo bar, baz
p bar
p baz
end
foo
eorby
puts RubyVM::InstructionSequence.new(ruby_code).disasm
puts RubyVM::InstructionSequence.new(ruby_code, nil, nil, 0, :operands_unification => false).disasm
View singleton_patch.diff
diff --git a/class.c b/class.c
index 0261838..65428be 100644
--- a/class.c
+++ b/class.c
@@ -1591,7 +1591,9 @@ singleton_class_of(VALUE obj)
klass = RBASIC(obj)->klass;
if (!(FL_TEST(klass, FL_SINGLETON) &&
rb_ivar_get(klass, id_attached) == obj)) {
+ rb_serial_t serial = RCLASS_SERIAL(klass);
klass = rb_make_metaclass(obj, klass);
View singleton_speed.rb
require 'benchmark'
class Foo
def bar; end
end
singleton = (100_000 * 20).times.map do |i|
foo = Foo.new
foo.singleton_class
foo
View singleton_speed.rb
require 'benchmark/ips'
class Foo
def bar; end
end
def ic_hit obj
obj.bar
end
View rspec_cache.txt
[aaron@TC Bath (master)]$ rspec rspec_test.rb
{:global_method_state=>142, :global_constant_state=>1332, :class_serial=>14849}
.{:global_method_state=>142, :global_constant_state=>1332, :class_serial=>14850}
.{:global_method_state=>142, :global_constant_state=>1332, :class_serial=>14851}
.
Finished in 0.00076 seconds (files took 0.13633 seconds to load)
3 examples, 0 failures
[aaron@TC Bath (master)]$ lldb `rbenv which ruby` -- -S `rbenv which rspec` rspec_test.rb
View ruby_23_stat.txt
$ sudo dtrace -q -n 'syscall::stat*:entry { printf("%s\n", copyinstr(arg0)); }' -c`rbenv which ruby`" -e'\ '"
/Users/aaron/.rbenv/versions/2.3.0/lib/ruby/2.3.0/x86_64-darwin15/enc/encdb.bundle
dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24
/Users/aaron/.rbenv/versions/2.3.0/lib/ruby/2.3.0/x86_64-darwin15/enc/trans/transdb.bundle
dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24
/Users/aaron/.rbenv/versions/2.3.0/lib/ruby/2.3.0/x86_64-darwin15/stringio.bundle
dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24
/Users/aaron/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/specifications/default/bigdecimal-1.2.8.gemspec
/Users/aaron/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/specifications/default/io-console-0.4.5.gemspec
View hash_speed.rb
require 'benchmark/ips'
class Foo
alias :object_hash :hash
attr_reader :hash
def initialize
@hash = object_hash
end
end
View changing_logo.md

Install pillow

$ pip3 install pillow

Generate code from bmp

$ python3 Scan/STLcd/bitmap2Struct.py ~/Desktop/dz.bmp
View a_terrible_thing.txt
[aaron@TC omglolwut (master)]$ cat lib/tasks/disable_autoload_during_migrations.rake
task :disable_autoload do
ActiveSupport::Dependencies.class_eval do
extend Module.new {
def load_file(path, const_paths = loadable_constants_for_path(path))
return if path.starts_with? File.join(Rails.application.root, 'app', 'models')
super
end
}
end
View ruby.patch
diff --git a/compile.c b/compile.c
index 995ff89..f0528af 100644
--- a/compile.c
+++ b/compile.c
@@ -1697,6 +1697,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
case TS_CALLCACHE:
{
struct rb_call_cache *cc = &iseq->body->cc_entries[ISEQ_COMPILE_DATA(iseq)->ci_index + ISEQ_COMPILE_DATA(iseq)->ci_kw_index - 1];
+ cc->serial = rb_next_ic_serial();
generated_iseq[code_index + 1 + j] = (VALUE)cc;