Skip to content

Instantly share code, notes, and snippets.

mrjabba / 127fib.rb
Created Nov 30, 2013
127 Parallel Fib from Ruby Tapas
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
mrjabba / gist:6159864
Created Aug 5, 2013
rvm install of ruby 2.0.0
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 '\"'"$config_path"'","w") { |file|
' > /dev/null 2>&1
mrjabba / caller.txt
Created Jan 24, 2013
Ruby kernel#caller
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; done

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

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
mrjabba / amqp_tester.rb
Created Jul 27, 2012
simplest possible and sub together
View amqp_tester.rb
def do_it
#simplest possible and sub together..
puts "do it.." 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 = ""
q_name = "myqueue"
mrjabba / consumer.rb
Created Jul 20, 2012
rabbit consumer testing
View consumer.rb
class BaseMessageHandler
def initialize(opts = {})
@connection_string = opts[:rabbit_mq_host]
raise'rabbit_mq_host is not specified') unless @connection_string
def fetch_channel
AMQP.start(@connection_string) do |connection, open_ok| do |channel|
yield channel
mrjabba / newScheduledThreadPool_jruby.rb
Created Jul 11, 2012
how to schedule a newScheduledThreadPool in jruby
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"
mrjabba / rack_simple.rb
Created May 12, 2012
Creating the simplest possible server in ruby using rack
View rack_simple.rb
my_rack_proc = lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello. The time is #{}"]] }
require 'rack', :Port => 3000)
You can’t perform that action at this time.