Skip to content

Instantly share code, notes, and snippets.

View woodie's full-sized avatar

John Woodell woodie

View GitHub Profile
class SomeStatsModel < ActiveRecord::Base
establish_connection "that_other_stats_db_#{Rails.env}".to_sym
TABLE_NAME = 'some_oddly_named_stats_table'
self.table_name = "some_default_schema.#{TABLE_NAME}"
def self.sum_select(*args)
self.select(*args.map {|s| "SUM(#{s}) AS #{s}"}.join(', '))
end
def self.for(account_specific_schema)
// A Queue of fixed size, using an array for storage
package cis;
public class FixedQueue {
private int added = 0;
private int removed = 0;
private int capacity;
private Object[] data;
# jruby -S rspec -fs spec/g_stack_spec.rb
require 'java'
import 'cis.GStack'
import 'cis.StackException'
describe GStack, 'once created' do
# create a GStack
before(:each) do
@woodie
woodie / set_spec.rb
Last active December 12, 2015 07:29
# jruby -S rspec -fs spec/set_spec.rb
describe Set, 'once created' do
before(:each) do
@capacity = 6
@set = Java::cis::Set.new(@capacity)
end
it 'should print an empty set' do
require 'java'
import 'cis.SeatChart'
import 'cis.ArrayOutOfBoundsException'
describe SeatChart, "once created" do
before(:each) do
@chart = SeatChart.new
end
// Generated from my_math.mirah
public class MyMath extends java.lang.Object {
public static void main(java.lang.String[] argv) {
MyMath mm = null;
mm = new MyMath();
java.io.PrintStream temp$1 = java.lang.System.out;
temp$1.println("");
java.io.PrintStream temp$2 = java.lang.System.out;
temp$2.println("factoral of 5 if " + mm.factoral(5));
java.io.PrintStream temp$3 = java.lang.System.out;
#!/usr/bin/ruby
def factoral(n)
begin
if n == 0
return 1
elsif n > 0
return factoral(n - 1) * n
else n < 0
abort("Sorry, no negative numbers please")
#!/usr/bin/ruby
class Node
attr_accessor :name, :parent
def initialize(name, parent=nil)
@name = name;
@parent = parent;
end
@woodie
woodie / Message.java
Created March 30, 2011 19:03
Pagination in mirah/dubious
// Generated from message.mirah
// Also See: https://github.com/mirah/mirah_model/blob/master/src/model.mirah
package models;
public class Message extends com.google.appengine.ext.mirah.db.Model {
private java.lang.String title;
private java.util.Date published;
private java.lang.String link;
private java.lang.String summary;
private boolean is_reply;
private boolean is_featured;
$ mirah -e '
class Foo
def self.bar() void
puts "baz"
end
end
Foo.bar
'
Inference Error: