Skip to content

Instantly share code, notes, and snippets.

@geoffrasb
geoffrasb / gist:2159403
Created March 22, 2012 16:32
self-lambda
#|
usage:
(funcall (self-lambda (n) (if (> n 0)
(self (- n 1))
n))
5)
|#
(defmacro self-lambda (param-lst &rest body)
(let ((fn (gensym)))
@geoffrasb
geoffrasb / gist:2157538
Created March 22, 2012 10:09
Hardware lab in lisp
(defun pin (atm)
(cond
((eql atm 'CA) 'P6);seg14 display
((eql atm 'CB) 'N4) ((eql atm 'CC) 'V5) ((eql atm 'CD) 'T5) ((eql atm 'CE) 'U7)
((eql atm 'CF) 'R3) ((eql atm 'CG1) 'N5) ((eql atm 'CG2) 'R5) ((eql atm 'CH) 'T3) ((eql atm 'CJ) 'T3)
((eql atm 'CK) 'V4) ((eql atm 'CL) 'V7) ((eql atm 'CM) 'R7) ((eql atm 'CN) 'T7) ((eql atm 'DP) 'U5)
((eql atm 'S1) 'N3);push button
((eql atm 'S2) 'P4) ((eql atm 'S3) 'P3) ((eql atm 'S4) 'L6) ((eql atm 'S5) 'M5)
((eql atm 'S6) 'U2) ((eql atm 'S7) 'U1) ((eql atm 'S8) 'T2)
((eql atm 'D1) 'K4);LED
@geoffrasb
geoffrasb / gist:1951882
Created March 1, 2012 18:19
simple route
//114.34.230.1
//192.168.1.100
var http = require('http');
var fs = require('fs');
var url = require('url');
http.createServer(function (req, res) {
var pathname = url.parse(req.url).pathname;
console.log(pathname);
if(pathname=='/')
@geoffrasb
geoffrasb / gist:1791529
Created February 10, 2012 18:37
A graph expression grammar spec

A graph expression grammar spec

Tokens:

\s+			#ignore whitespace
{		"{"
}		"}"
[		"["
]		"]"
, ","
genpair = (num)->
return [] if num<=1
result = []
for i in [0..num-2]
result = result.concat ([i,n] for n in [i+1..num-1])
return result
@geoffrasb
geoffrasb / Object_toString_equal_expansion
Created December 20, 2011 13:30
Object::toString() and Object::equal(obj)
Object.prototype.toString = function() {
var key, result, val;
result = ["{"];
for (key in this) {
val = this[key];
result = result.concat(key, ":", val, ",");
}
result.pop();
return (result.concat("}")).join("");
};