Skip to content

Instantly share code, notes, and snippets.

View n2westman's full-sized avatar

Nickolas Westman n2westman

  • Los Angeles, CA
View GitHub Profile
@n2westman
n2westman / gist:5fe467c954654cce876b
Created May 28, 2015 23:01
Local Notification Example
UILocalNotification *notif = [[UILocalNotification alloc] init];
notif.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
@n2westman
n2westman / tests-part2.js
Created March 14, 2015 17:37
Unification Tests // CS137A HW6
tests(
JS,
{
name: 'unify(Var, Clause)',
code: 'new Subst().unify(new Var("X"),\n' +
' new Clause("foo"));',
expected: new Subst().bind("X", new Clause("foo"))
},
{
name: 'unify(Clause, Var)',
@n2westman
n2westman / tests.js
Created February 2, 2015 22:09
hw3-tests.js
// This function is used by the test harness to pretty-print values.
// Right now it doesn't handle undefined, functions, NaN, Number.POSITIVE_INFINITY, etc.
// Feel free to modify / extend it as you see fit.
// (FYI, pretty-printing is not used by our grading scripts.)
function prettyPrintValue(value) {
return JSON.stringify(value);
}
// Helper functions used in the tests
@n2westman
n2westman / hw1-tests.js
Last active August 29, 2015 14:13
hw1-tests.js
tests(
F,
{
name: 'primitive number',
code: '6',
expected: 6
},
{
name: 'primitive boolean',
code: 'true',
@n2westman
n2westman / isSearch.ml
Created January 1, 2015 02:12
Binary Tree Check OCaml
(* Tail Recusrive Check on if a Binary Tree is a search binary tree *)
type Node = Internal of Node * int * Node | Leaf of int
type Wrapper = W of Node * int * int
let isSearch tree =
let rec isSearchHelper ret wlist =
match wlist with
[] -> ret
| [W(n, minn, maxx)::rest] -> match n with
@n2westman
n2westman / isSearch.cpp
Last active August 29, 2015 14:12
Tail Recursive Binary Tree Check
#include <climits>
#include <queue>
typedef struct Holder {
Node* node;
int min;
int max;
Holder(Node* n, int min, int max): node(n), min(min), max(max) {}
} *Holder_p;