This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
import 'cis.SeatChart' | |
import 'cis.ArrayOutOfBoundsException' | |
describe SeatChart, "once created" do | |
before(:each) do | |
@chart = SeatChart.new | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
class Node | |
attr_accessor :name, :parent | |
def initialize(name, parent=nil) | |
@name = name; | |
@parent = parent; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mirah -e ' | |
class Foo | |
def self.bar() void | |
puts "baz" | |
end | |
end | |
Foo.bar | |
' | |
Inference Error: |