This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'benchmark' | |
def foo | |
Benchmark.measure { | |
sc = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD, org.jruby.embed.LocalVariableBehavior::TRANSIENT) | |
sc.runScriptlet("require 'ffi'") | |
sc.runScriptlet <<-RUBY | |
Fork = Object.new | |
lib = FFI::DynamicLibrary.open('/usr/lib/libc.dylib', FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
**** BEGIN LICENSE BLOCK ***** | |
* Version: CPL 1.0/GPL 2.0/LGPL 2.1 | |
* | |
* The contents of this file are subject to the Common Public | |
* License Version 1.0 (the "License"); you may not use this file | |
* except in compliance with the License. You may obtain a copy of | |
* the License at http://www.eclipse.org/legal/cpl-v10.html | |
* | |
* Software distributed under the License is distributed on an "AS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you're building a gem with JRuby extension support, you need to compile | |
# some .java files using a classpath which includes jruby.jar. How to do this? | |
# | |
# Some well-known Ruby gems have different approaches: | |
#### https://github.com/flori/json/blob/master/Rakefile: | |
JRUBY_JAR = File.join(Config::CONFIG["libdir"], "jruby.jar") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'twitter' | |
require 'cgi' | |
require 'csv' | |
QUERIES = ['toothache', 'tooth ache', 'dental pain', 'tooth pain'] | |
FIELDS = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git svn clone -Tlinecache/trunk -tlinecache/tags -blinecache/branches svn://rubyforge.org/var/svn/rocky-hacks linecache | |
Initialized empty Git repository in /Users/jfire/Development/linecache/.git/ | |
A test/test-linecache.rb | |
A Rakefile | |
A AUTHORS | |
A VERSION | |
A lib/linecache.rb | |
A ChangeLog | |
A COPYING | |
A NEWS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Development ☯ gem list -d rails | |
*** LOCAL GEMS *** | |
rails (3.0.10) | |
Author: David Heinemeier Hansson | |
Rubyforge: http://rubyforge.org/projects/rails | |
Homepage: http://www.rubyonrails.org | |
Installed at: /Users/jfire/.rvm/gems/jruby-1.6.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0] | |
/ 0 0.0 0+0i 0/1 | |
1 ZeroDivisionError Infinity ZeroDivisionError ZeroDivisionError | |
1.0 Infinity Infinity ZeroDivisionError Infinity | |
9223372036854775808 ZeroDivisionError Infinity ZeroDivisionError ZeroDivisionError | |
0 ZeroDivisionError NaN ZeroDivisionError ZeroDivisionError | |
0.0 NaN NaN ZeroDivisionError NaN | |
0+0i ZeroDivisionError (NaN+NaN*i) ZeroDivisionError ZeroDivisionError | |
0/1 ZeroDivisionError NaN ZeroDivisionError ZeroDivisionError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pry(main)> c = Class.new(Numeric) do | |
pry(main)* def to_r | |
pry(main)* Rational(1) | |
pry(main)* end | |
pry(main)* end | |
=> #<Class:0x00000102097dd0> | |
pry(main)> c.new.quo(1) | |
ArgumentError: comparison of #<Class:0x00000102097dd0> with 0 failed | |
from (pry):13:in `<' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby-1.9.2-p290 | |
pry(main)> c1 = Complex(2, 0) | |
=> (2+0i) | |
pry(main)> c2 = Complex(2, 0.0) | |
=> (2+0.0i) | |
pry(main)> Complex(c1).equal?(c1) | |
=> false | |
pry(main)> Complex(c2).equal?(c2) | |
=> true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LOAD_PATH << "lib" | |
require 'benchmark' | |
require 'sequel' | |
require 'sequel/adapters/jdbc' | |
ds = Sequel::JDBC::Dataset.new(Sequel::JDBC::Database.new({})) | |
Benchmark.bm(10) do |x| | |
x.report("timestamp") { 100000.times { ds.send(:convert_type, Java::JavaSQL::Timestamp.new(0)) } } | |
x.report("nil") { 100000.times { ds.send(:convert_type, nil) } } |