Skip to content

Instantly share code, notes, and snippets.

View headius's full-sized avatar

Charles Oliver Nutter headius

View GitHub Profile
require 'stringio'
require 'base64'
def read_varint(io)
value = index = 0
begin
byte = io.readchar
value |= (byte & 0x7f) << (7 * index)
index += 1
end while (byte & 0x80).nonzero?
~/projects/jrubies ➔ ls
jruby-0.5.2 jruby-0.8.1 jruby-0.9.1 jruby-0_3_0 jruby-1.0 jruby-1.1 jruby-1.1.4 jruby-1.3.0 jruby-1.5.0 jruby-1.5.4 jruby-1.6.0.RC2
jruby-0.5.3 jruby-0.8.2 jruby-0.9.8 jruby-0_3_1 jruby-1.0.1 jruby-1.1.1 jruby-1.1.5 jruby-1.3.1 jruby-1.5.1 jruby-1.5.5 jruby_0_2_0
jruby-0.7.0 jruby-0.8.3 jruby-0.9.9 jruby-0_5_0 jruby-1.0.2 jruby-1.1.2 jruby-1.1.6 jruby-1.4.0 jruby-1.5.2 jruby-1.5.6 jruby_0_2_1
jruby-0.8.0 jruby-0.9.0 jruby-0_2_4 jruby-0_5_1 jruby-1.0.3 jruby-1.1.3 jruby-1.2.0 jruby-1.4.1 jruby-1.5.3 jruby-1.6.0.RC1 jruby_0_2_2
~/projects/jrubies ➔ time java -jar jruby_0_2_0/jruby.jar -e "def fib(a); a < 2 ? a : fib(a - 1) + fib(a - 2); end; 10.times { fib(30) }"
real 0m52.106s
user 0m49.630s
~/projects/jcd ➔ ab -n 1000 -d -S http://localhost:3000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
~/projects/jruby ➔ jruby memory_mapped.rb
Reading and writing memory-mapped
2.355000 0.000000 2.355000 ( 2.299000)
1.943000 0.000000 1.943000 ( 1.942000)
2.014000 0.000000 2.014000 ( 2.014000)
1.899000 0.000000 1.899000 ( 1.899000)
1.870000 0.000000 1.870000 ( 1.870000)
Reading from disk
2.982000 0.000000 2.982000 ( 2.982000)
3.031000 0.000000 3.031000 ( 3.031000)
@headius
headius / RubyGems plugin deferral and impact on startup
Created November 24, 2010 07:53
Patches to move plugin loading to gem_runner, to speed startup.
~/projects/jruby ➔ ls lib/ruby/gems/1.8/gems/ | wc -l
471
~/projects/jruby ➔ time jruby -rubygems -e 1
real 0m5.079s
user 0m7.375s
sys 0m0.393s
~/projects/jruby ➔ git stash pop --quiet
@headius
headius / gist:707061
Created November 19, 2010 20:02 — forked from evanphx/gist:663404
#!/usr/bin/env ruby
=begin
INSTALL:
curl http://github.com/defunkt/gist/raw/master/gist.rb > gist &&
chmod 755 gist &&
sudo mv gist /usr/local/bin/gist
@headius
headius / pickjdk.sh
Last active August 30, 2015 13:15 — forked from nicksieger/pickjdk.sh
JDK picker for OS X.
#!/bin/bash
#
# Provides a function that allows you to choose a JDK. Just set the environment
# variable JDKS_ROOT to the directory containing multiple versions of the JDK
# and the function will prompt you to select one. JAVA_HOME and PATH will be cleaned
# up and set appropriately.
# Usage:
# Include in .profile or .bashrc or source at login to get 'pickjdk' command.
# 'pickjdk' alone to bring up a menu of installed JDKs on OS X. Select one.