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 'rubygems' | |
require 'spec' | |
class RDingus | |
def initialize(parent = nil, invocation = nil) | |
@parent = parent | |
@invocation = invocation | |
@invocation_exceptions = InvocationList.new | |
@invocation_expectations = InvocationList.new | |
@invocation_expectation_set = InvocationList.new |
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
; now with multimethods. | |
(ns properties) | |
(defn from_string_file | |
[fname] | |
{:propfile :text :filename fname}) | |
(defn from_xml_file | |
[fname] | |
{:propfile :xml :filename fname}) | |
(defn to_string_file |
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
(use 'clojure.contrib.datalog) | |
(use 'clojure.contrib.datalog.rules) | |
(use 'clojure.contrib.datalog.database) | |
(use 'clojure.contrib.datalog.util) | |
(def d (make-database | |
(relation :person [:name :room-id :seat-number]) | |
(index :person :name))) | |
(def db (add-tuples d |
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
module Temporal | |
def to_human_minutes(minutes) | |
_h = minutes % 60 | |
if _h > 0 | |
sprintf("%d hours and %s",_h,ActionView::Helpers::TextHelper.pluralize((minutes / 60).to_i,"minute")) | |
else | |
ActionView::Helpers::TextHelper.pluralize((minutes / 60).to_i,"minute") | |
end | |
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
public funciton testLogin() { | |
/* in this case $this->f is a User object */ | |
$r = new ReflectionObject($this->f); | |
$m = $r->getMethod('login'); | |
$this->assertEquals(2,$m->getNumberOfParameters()); | |
} |
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
Broken Function: | |
function bob(a) { | |
var str = a; | |
return a.map(function() { a + 1 }) | |
} | |
Tables: |
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
/** | |
* winCount | |
* returns the count of all games that the human player won. | |
* | |
* @returns int | |
*/ | |
+(int) winCount { | |
NSError *error; | |
NSManagedObjectContext *context = [(BFHeartsAppDelegate *)[UIApplication sharedApplication].delegate managedObjectContext]; | |
NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"GameFinalScore" inManagedObjectContext:context]; |
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
enum PhoneType { | |
MOBILE, | |
HOME, | |
OFFICE | |
} | |
struct PhoneNumber { | |
1: PhoneType ptype, | |
2: string name, | |
3: string number |
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 Conway | |
attr_reader :displayrange | |
attr_accessor :board | |
# Any live cell with fewer than two live neighbours dies, as if caused by under-population. | |
# Any live cell with two or three live neighbours lives on to the next generation. | |
# Any live cell with more than three live neighbours dies, as if by overcrowding. | |
# Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. | |
def initialize disprange = nil | |
@board = { 1 => { 2 => 1}, 2 => { 2 => 1}, 3 => { 2 => 1} } | |
@displayrange = disprange.nil? ? (0..10) : disprange |
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 'yaml' | |
class Tumbledry | |
attr_accessor :patterns | |
def initialize | |
File.open('repetative.txt', 'r') do |f| | |
@data = f.read() | |
end | |
self.patterns = {} | |
@numpat = 1 | |
end |
OlderNewer