Skip to content

Instantly share code, notes, and snippets.

View headius's full-sized avatar

Charles Oliver Nutter headius

View GitHub Profile
require 'tmpdir'
describe "A file required from a load path entry with an embedded symlink" do
it "leaves __FILE__ unexpanded" do
Dir.mktmpdir do |path|
Dir.mkdir "#{path}/real"
File.symlink "#{path}/real", "#{path}/link"
File.write("#{path}/real/GH1940_test.rb", "class GH1940; def self.__file__; __FILE__; end; end")
$LOAD_PATH << "#{path}/link"
# format.rb: Written by Tadayoshi Funaba 1999-2009
# $Id: format.rb,v 2.43 2008-01-17 20:16:31+09 tadf Exp $
class Date
ZONES = {
'ut' => 0*3600, 'gmt' => 0*3600, 'est' => -5*3600, 'edt' => -4*3600,
'cst' => -6*3600, 'cdt' => -5*3600, 'mst' => -7*3600, 'mdt' => -6*3600,
'pst' => -8*3600, 'pdt' => -7*3600,
'a' => 1*3600, 'b' => 2*3600, 'c' => 3*3600, 'd' => 4*3600,
'e' => 5*3600, 'f' => 6*3600, 'g' => 7*3600, 'h' => 8*3600,
diff --git a/core/src/main/java/org/jruby/RubyEncoding.java b/core/src/main/java/org/jruby/RubyEncoding.java
index f872076..5e2c025 100755
--- a/core/src/main/java/org/jruby/RubyEncoding.java
+++ b/core/src/main/java/org/jruby/RubyEncoding.java
@@ -81,7 +81,7 @@ public class RubyEncoding extends RubyObject implements Constantizable {
private final Object constant;
private RubyEncoding(Ruby runtime, byte[] name, int p, int end, boolean isDummy) {
- this(runtime, new ByteList(name, p, end), null, false);
+ this(runtime, new ByteList(name, p, end), null, isDummy);
@headius
headius / 1.blah.rb
Created October 22, 2014 13:04
stackmap problem at athrow in new jit
def start_thread
1.times {
begin
p
rescue
p
ensure
p
end
}
@headius
headius / gist:cef36c9cb9f51de588eb
Created October 24, 2014 20:56
pr-zlib versus zlib on JRuby, Rubinius, and MRI
JRuby zlib
user system total real
write 0.054059 0.007411 0.061470 ( 0.047307)
read 0.019310 0.002438 0.021748 ( 0.011610)
JRuby pr-zlib
user system total real
write 9.660000 0.070000 9.730000 ( 8.077000)
@headius
headius / changelog output
Created October 31, 2014 20:57
bash function to generate a ruby-core changelog entry from most recent git commit
~/projects/ruby $ changelog
Fri Oct 31 15:56:46 2014 Charles Oliver Nutter <headius@headius.com>
* object.c: Make a meaningless change to test changelog script.
@headius
headius / gist:84731230ede769fdce5d
Last active August 29, 2015 14:09
JRuby's tweaks to MRI's test/lib
diff -ru ../ruby/test/lib/leakchecker.rb test/mri/lib/leakchecker.rb
--- ../ruby/test/lib/leakchecker.rb 2014-11-04 23:26:38.000000000 -0600
+++ test/mri/lib/leakchecker.rb 2014-11-08 11:46:12.000000000 -0600
@@ -66,7 +66,6 @@
end
puts "Leaked file descriptor: #{test_name}: #{fd}#{str}"
}
- #system("lsof -p #$$") if !fd_leaked.empty?
h.each {|fd, list|
next if list.length <= 1
@headius
headius / gist:e87a4723d643cfd38769
Created December 29, 2014 18:10
Attempt at fixing JRUBY-7129
diff --git a/core/src/main/java/org/jruby/RubyThread.java b/core/src/main/java/org/jruby/RubyThread.java
index cf325de..cbc0c82 100644
--- a/core/src/main/java/org/jruby/RubyThread.java
+++ b/core/src/main/java/org/jruby/RubyThread.java
@@ -55,6 +55,7 @@ import org.jruby.internal.runtime.NativeThread;
import org.jruby.internal.runtime.RubyRunnable;
import org.jruby.internal.runtime.ThreadLike;
import org.jruby.internal.runtime.ThreadService;
+import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.Block;
@headius
headius / super_bench.rb
Created December 29, 2014 20:37
Bench nested super and constant logic
# Test the performance of testing for equality in a class that includes
# a module and calls super on it. See if there is any difference between
# arg == Const and Const == arg for the runtimes.
#
require 'rubygems'
require 'benchmark'
A = 1
B = 2
require "singleton"
require "socket"
ACCEPT_EVENT = 0x01
RECEIVE_EVENT = 0x02
WRITE_EVENT = 0x04
# Y_EVENT = 0x08
# Z_EVENT = 0x10
# Etc.