Skip to content

Instantly share code, notes, and snippets.

% ruby -Ilib -d -rrbtree_map -e 'map = RBTreeMap.new; ("a".."e").each { |k| map.put(k, k) }; puts map.dump_tree'
Exception `LoadError' at /usr/local/lib/ruby/2.0.0/rubygems.rb:1243 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/local/lib/ruby/2.0.0/rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby
#<RBTreeMap::RBTree:0x00011bce9c BLACK "e"> => "e"
#<RBTreeMap::RBTree:0x00011bcec4 RED "d"> => "d"
#<RBTreeMap::RBTree:0x00011bcf00 BLACK "c"> => "c"
#<RBTreeMap::RBTree:0x00011bcf28 BLACK "b"> => "b"
#<RBTreeMap::RBTree:0x00011bcf50 BLACK "a"> => "a"
diff --git a/src/org/jruby/ext/zlib/RubyZlib.java b/src/org/jruby/ext/zlib/RubyZlib.java
index a056cb8..65bae2f 100644
--- a/src/org/jruby/ext/zlib/RubyZlib.java
+++ b/src/org/jruby/ext/zlib/RubyZlib.java
@@ -1348,8 +1348,12 @@ public class RubyZlib {
public IRubyObject rewind() {
Ruby rt = getRuntime();
// should invoke seek on realIo...
+ long n = io.getTotalIn();
+ if (io.getAvailIn() != null) {
% jruby -v
jruby 1.7.0.dev (ruby-1.9.3-p139) (2012-03-23 a1e5eed) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04-ea) [linux-amd64-java]
% jruby -Ilib test/test_avl_tree.rb
Run options:
# Running tests:
.................................
Finished tests in 1.032000s, 31.9767 tests/s, 138.5659 assertions/s.
@nahi
nahi / __typescript__
Created February 14, 2012 02:03
I expected :before, but foo volatility issue comes first
# on Ubuntu with 4 cores
% jruby -v
jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-14 78244f2) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04-ea) [linux-amd64-java]
% while true; do jruby method_invalidate_2.rb; done
:after
:after
:after
:after
:after
:after
% ruby187 -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
% ruby187 -e 'puts({:omg! => 1}.hash)'
437103
% ruby187 -e 'puts({:ZOMG! => 1}.hash)'
437103
% ruby187 -e 'puts({:omg! => 1}.hash == {:ZOMG! => 1}.hash)'
false #### ZOMG!!!!
def expect
begin
yield
rescue Exception => excn
o = Struct.new(:excn).new(excn)
def o.to(arg)
arg.call(excn)
end
o
end
1) Failure:
test_does_set_secure_cookies_over_https(CookieStoreTest)
[/home/nahi/git/rails/actionpack/test/dispatch/session/cookie_store_test.rb:125:in `test_does_set_secure_cookies_over_https'
/home/nahi/git/rails/actionpack/test/dispatch/session/cookie_store_test.rb:332:in `with_test_route_set'
./test/abstract_unit.rb:219:in `with_routing'
/home/nahi/git/rails/actionpack/test/dispatch/session/cookie_store_test.rb:320:in `with_test_route_set'
/home/nahi/git/rails/actionpack/test/dispatch/session/cookie_store_test.rb:122:in `test_does_set_secure_cookies_over_https'
/home/nahi/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `__send__'
/home/nahi/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `run'
/home/nahi/git/rails/activesupport/lib/active_support/callbacks.rb:436:in `_run__663523505__setup__4__callbacks'
-- /usr/share/vim/vim73/indent/ruby.vim 2011-10-06 19:22:27.000000000 +0900
+++ /home/nahi/.vim/indent/ruby.vim 2012-02-01 15:34:29.582410473 +0900
@@ -21,5 +21,5 @@
setlocal indentexpr=GetRubyIndent()
setlocal indentkeys=0{,0},0),0],!^F,o,O,e
-setlocal indentkeys+==end,=elsif,=when,=ensure,=rescue,==begin,==end
+setlocal indentkeys+==end,=elsif,=when,=ensure,=rescue,=public,=private,=protected,==begin,==end
" Only define the function once.
@@ -53,5 +53,5 @@
Free performance boost from JRuby!
Bear in mind that Rubinius is not tuned yet after hydra (GIL free branch) merge I believe.
% ruby -v -Ilib bench/bench.rb
ruby 2.0.0dev (2012-01-14 trunk 34297) [x86_64-linux]
Rehearsal ----------------------------------------------------
Hash aset 0.090000 0.000000 0.090000 ( 0.096379)
Hash aref 0.050000 0.000000 0.050000 ( 0.045496)
Hash delete 0.080000 0.000000 0.080000 ( 0.078845)
RadixTree aset 1.400000 0.020000 1.420000 ( 1.425785)
require 'nokogiri'
require 'benchmark'
HEADER = <<__EOS__
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"