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
| # Illustrates the overhead of the JRuby <--> Java bridge | |
| # parameter and return value type conversions, and the | |
| # dramatic performance improvement that can be had by | |
| # specifying the Java overload using java_method. | |
| require 'java' | |
| require 'benchmark' | |
| ITERATION_COUNT = ARGV.empty? ? 100_000 : ARGV.first.to_i | |
| JMath = java.lang.Math |
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
| package com.affy; | |
| public class Bug { | |
| private int[] id; | |
| public Bug(int n) { | |
| id = new int[n]; | |
| for (int i = 0; i < n; i++) { | |
| id[i] = i; |
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
| user@linuxmint-14-32bit ~ $ uname -a | |
| Linux linuxmint-14-32bit 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:32:08 UTC 2012 i686 i686 i686 GNU/Linux | |
| user@linuxmint-14-32bit ~ $ curl -L https://www.opscode.com/chef/install.sh | sudo bash | |
| % Total % Received % Xferd Average Speed Time Time Time Current | |
| Dload Upload Total Spent Left Speed | |
| 100 6471 100 6471 0 0 17436 0 --:--:-- --:--:-- --:--:-- 36150 | |
| Downloading Chef for linuxmint... | |
| Unable to retrieve a valid package! |
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
| # Simple Ruby/JRuby program to illustrate that MRI Ruby uses only one CPU, | |
| # while JRuby will use all available CPU's. (Inspection tool not included; | |
| # you can use Activity Monitor on a Mac, or htop on many Unix distros. | |
| # | |
| # Keith R. Bennett, @keithrbennett | |
| NUM_THREADS = 5 | |
| SLEEP_DURATION_IN_SEC = 2 |
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
| # Example JRuby program to display the JVM's available locales | |
| # and their number, currency, and date formats. | |
| # | |
| # Keith R. Bennett, @keithrbennett | |
| require 'java' | |
| java_import 'java.util.Locale' | |
| java_import 'java.text.DateFormat' | |
| java_import 'java.text.NumberFormat' |
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-validator git:(master) ✗ rspec x_spec.rb | |
| /Users/kbennett/work/small-projects/ruby-validator/x_spec.rb:2:in `require': cannot load such file -- logging (LoadError) | |
| from /Users/kbennett/work/small-projects/ruby-validator/x_spec.rb:2:in `<top (required)>' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' | |
| from /Users/kbennett/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' | |
| from /Users/kbennett/.rvm/gems/ruby-1. |
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
| Exception in thread "RubyThread-14: /Users/kbennett/.rvm/gems/jruby-1.7.3/gems/logging-1.8.1/lib/logging/diagnostic_context.rb:320" java.nio.channels.CancelledKeyException | |
| at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55) | |
| at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:69) | |
| at sun.nio.ch.KQueueSelectorImpl.updateSelectedKeys(KQueueSelectorImpl.java:105) | |
| at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:74) | |
| at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69) | |
| at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80) | |
| at org.jruby.util.io.SelectBlob.doSelect(SelectBlob.java:257) | |
| at org.jruby.util.io.SelectBlob.goForIt(SelectBlob.java:89) | |
| at org.jruby.RubyIO.select_static(RubyIO.java:3507) |
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 'facter' | |
| require 'logging' | |
| require 'pry' | |
| require 'yaml' | |
| GLOBAL_LOGGING = 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
| # Builds the gem for the current rvm ruby/platform. | |
| # Run this once for MRI and once for JRuby, as in: | |
| # | |
| # rvm 1.9 | |
| # ./build_gem.sh | |
| # rvm jruby | |
| # ./build_gem.sh | |
| GEM_NAME=my_gem |
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
| class Name | |
| attr_accessor :first_name, :last_name | |
| def initialize(first_name, last_name) | |
| @first_name = first_name | |
| @last_name = last_name | |
| end | |
| def name |