Skip to content

Instantly share code, notes, and snippets.

@joannecheng
joannecheng / Ackermann.java
Created August 8, 2012 21:06
Some more Jruby notes: compiled java classes vs ruby classes
public class Ackermann {
public static int ack(int m, int n){
if (m == 0){
return n + 1;
}
if (n == 0){
return ack(m - 1, 1);
}
@joannecheng
joannecheng / mongo-ruby.rb
Created August 7, 2012 06:16
Search for nested objects using mongo-ruby
require 'rubygems'
require 'mongo'
@conn = Mongo::Connection.new
@db = @conn['trails']
@collection = @db['bikeways']
puts @collection.find('properties.FCODE' => 203001).to_a
# BOOM
# I have no idea what I'm doing.
require 'java'
Dir["sigar/*.jar"].each { |jar| require jar }
# import sigar class
# Must be java 1.7
import_sigar = org.hyperic.sigar
sigar = import_sigar.Sigar.new
shell = import_sigar.cmd.Shell.new
@joannecheng
joannecheng / example.coffee
Last active September 27, 2015 23:47
why I use coffeescript.
# For one, it's just nicer to look at.
# No more excessive brackets and semi colons
## js
function foo(bar){
if (bar == 0){
return "zero!";
} else {
return "Not zero!";
}