Skip to content

Instantly share code, notes, and snippets.

@nagachika
nagachika / wait_readable_writable_exceptions.rb
Created June 13, 2011 09:07
wait_readable_writable_exceptions
class Errno::EAGAIN_WAIT_READABLE < Errno::EAGAIN
include IO::WaitReadable
end
class Errno::EAGAIN_WAIT_WRITABLE < Errno::EAGAIN
include IO::WaitWritable
end
class Errno::EWOULDBLOCK_WAIT_READABLE < Errno::EWOULDBLOCK
include IO::WaitReadable
@nagachika
nagachika / gist:1028705
Created June 16, 2011 05:10
patch for test_io.rb
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index fba0800..4521a90 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -621,9 +621,10 @@ class TestIO < Test::Unit::TestCase
nr.times do
assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1
)
end
+ sleep 0.5
@nagachika
nagachika / signal_test.rb
Created June 30, 2011 14:34
ruby signal handler test script
a = []
trap(:INT) { a.push(1) }
trap(:TERM) { a.push(2) }
pid = $$
fork do
sleep 0.5
puts "send start"
Process.kill(:INT, pid)
Process.kill(:TERM, pid)
@nagachika
nagachika / result_of_rspec.txt
Created July 23, 2011 12:00
result of reproduce sequence of Bug #5047
F
Failures:
1) ApplicationController foo adds
Failure/Error: Unable to find matching line from backtrace
NameError:
uninitialized constant ActiveRecord::Base::TinyTds
# -e:1:in `<main>'
require "dl/func"
include DL
GC.stress = true
Function.new(CFunc.new(0, TYPE_INT, 'name'),
[TYPE_VOIDP, TYPE_VOIDP]){|x,y|
x.inspect
0
}.call(0, 0)
@nagachika
nagachika / patch_bug4929.patch
Created July 28, 2011 09:31
patch to fiddle
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index 157b97c..73ad053 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -56,7 +56,7 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
VALUE rbargs = rb_iv_get(self, "@args");
VALUE ctype = rb_iv_get(self, "@ctype");
int argc = RARRAY_LENINT(rbargs);
- VALUE *params = xcalloc(argc, sizeof(VALUE *));
+ volatile VALUE params_ary = rb_ary_new2(argc);
@nagachika
nagachika / common.mk.patch
Created August 15, 2011 08:15
how to make money
diff --git a/common.mk b/common.mk
index ea244cc..1edb412 100644
--- a/common.mk
+++ b/common.mk
@@ -931,6 +931,9 @@ change: PHONY
love: sudo-precheck up all test install test-all
@echo love is all you need
+money:
+ @echo "OK. Please lend me some money at first. I'll return a 10-fold."
@nagachika
nagachika / sprintf.c.patch
Created August 22, 2011 08:46
patch to CRuby trunk sprintf.c
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 1214f39..d7d22fa 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -441,8 +441,10 @@ date_zone_to_diff(VALUE str)
char *s, *p;
VALUE sign;
VALUE hour = Qnil, min = Qnil, sec = Qnil;
+ volatile VALUE str_orig;
@nagachika
nagachika / addr2line.rb
Created September 2, 2011 04:10
Add base-address options(-B/--baseaddr) to addr2line
#!/bin/env ruby
require "optparse"
cmdline = ["addr2line"]
baseaddr = 0
OptionParser.new do |opt|
opt.on("-a", "--addresses") do
cmdline << "--addresses"
end
@nagachika
nagachika / test_5380.patch
Created September 30, 2011 16:36
test for #5380
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index de9055f..4a8451a 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -122,7 +122,13 @@ module Test
module Assertions
public
def assert_normal_exit(testsrc, message = '', opt = {})
- out, _, status = EnvUtil.invoke_ruby(%W'-W0', testsrc, true, :merge_to_stdout, opt)
+ if opt.include?(:child_env)