Skip to content

Instantly share code, notes, and snippets.

View kognate's full-sized avatar

Joshua Smith kognate

  • Pittsburgh, PA
View GitHub Profile
/**
* 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];
Broken Function:
function bob(a) {
var str = a;
return a.map(function() { a + 1 })
}
Tables:
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());
}
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
(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
@kognate
kognate / gist:126315
Created June 9, 2009 06:21
clojure code
; 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
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