View 127fib.rb
require 'thread'
require "benchmark"
module FibSolver
def self.fib(scheduler_queue, my_queue)
loop do
scheduler_queue << [:ready, my_queue]
message, *args = my_queue.pop
case message
when :fib
View gist:6159864
Saving wrappers to '/Users/khutson/.rvm/wrappers/ruby-2.0.0-p247'........
ruby-2.0.0-p247 - #importing default gemsets, this may take time...............................
/Users/khutson/.rvm/scripts/functions/support: line 291: 89701 Segmentation fault: 11 "$ruby_path" -rrbconfig -e '\
File.open("'"$config_path"'","w") { |file|
RbConfig::CONFIG.sort.each{|key,value|
file.write("#{key.gsub(/\.|-/,"_")}=\"#{value.gsub("$","\\$")}\"\n")
}
}
' > /dev/null 2>&1
View caller.txt
Kernel has a great method you can call. "caller".
Returns an array of the stack that called you.
So if you want to just see your immediate caller,
you can do puts "who called me caller=#{caller.first}"
and it will print the immediate caller.
If your method is being called from multiple clients this seems useful in debugging..
View scan_jars.bash
NOTE how to to look for stuff inside a directory of jar files from the command line
for i in *.jar; do jar -tvf "$i" | grep com.foo; done
View jruby_speed_tests.md

Under jruby 1.6.7:

want_spring=1 rspec spec/models/ums_user_spec.rb

  • 20 seconds until we start doing maven
  • 45 seconds until we start running tests
  • Time 8.11 seconds. Total time 53 seconds

rspec spec (skips spring test above)

  • 23 seconds until we start doing maven
  • 31 seconds until we start running tests
  • Time 15.4 seconds. Total time 51 seconds
View Sweet n Spicy pulled pork.md

Sweet n Spicy pulled pork

We had some extra pork loin, cooked in a crock pot, then pulled.

I created this sauce that I let some of it simmer in. Delicious.

  • 1 stick celery, sliced
  • 1 carrot, sliced
  • one half scallion, sliced
  • one quarter white onion, sliced
View amqp_tester.rb
def do_it
#simplest possible thing..works..pub and sub together..
puts "do it.."
EventMachine.run do
connection = AMQP.connect('amqp://guest:guest@localhost:5672')
puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..."
opts = {:durable => true, :ack => true}
ex_name = "my.exchange.name"
q_name = "myqueue"
View consumer.rb
class BaseMessageHandler
def initialize(opts = {})
@connection_string = opts[:rabbit_mq_host]
raise ConfigurationError.new('rabbit_mq_host is not specified') unless @connection_string
end
def fetch_channel
AMQP.start(@connection_string) do |connection, open_ok|
AMQP::Channel.new(connection) do |channel|
yield channel
View newScheduledThreadPool_jruby.rb
require 'java'
java_import 'java.util.concurrent.Executors'
java_import 'java.util.concurrent.TimeUnit'
class SomeClass
include java.lang.Runnable
def run
puts "imma lil jruby runner"
end
end
View rack_simple.rb
my_rack_proc = lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello. The time is #{Time.now}"]] }
puts my_rack_proc.call({})
require 'rack'
Rack::Handler::WEBrick.run(my_rack_proc, :Port => 3000)