Skip to content

Instantly share code, notes, and snippets.

View pnathan's full-sized avatar
⚒️
worker

Paul Nathan pnathan

⚒️
worker
View GitHub Profile
@pnathan
pnathan / cyberpunk-theme.el
Created September 20, 2012 05:55 — forked from bo0ts/cyberpunk-theme.el
Fork so I can find it again. :-)
;; Cyberpunk Colour Theme
;;
;; "and he'd still see the matrix in his sleep, bright lattices of logic
;; unfolding across that colorless void..."
;; William Gibson, Neuromancer.
(deftheme cyberpunk
"")
(custom-theme-set-faces
@pnathan
pnathan / map-constructor.lisp
Last active December 12, 2015 03:48
map constructor idea, mooched from rdtsc
(defun make-map (pairs
&key
(test #'eql)
(default nil))
"Creates a hash table with the list pairs; the CAR of each element
in the pairs is the key, the CDR is the value.
Hash table tests are :test
The default value of elements is `default`"
@pnathan
pnathan / clj-hash.lisp
Last active December 16, 2015 11:38
clj-hash: clojure's hashes kind of brought to common lisp
(defmacro clj-hash (&rest kvs)
"Destructures `kvs`: assums keys and values are paired together:
kvs ::= k1 v1 ... kn vn
Defines a sequence of functions ki that will obtain the value of ki
from a hash table.
Raises simple-error on ki not being a keyword.
@pnathan
pnathan / caveman-defroute.lisp
Created August 14, 2013 06:08
caveman deannotation
(defmacro defroute (method url-rule form)
`(progn
(caveman.route:add-route ,(intern "*APP*" caveman.route:*package*)
(caveman.route:url->routing-rule ,method ,url-rule ,form))
,form))
;; Shannon Entropy
;; Can be used against strings
;; Requires Alexandria and a rewrite. :-)
(defun entropy (vector)
(let ((pmf (make-hash-table))
(counter 0))
;; Count up the values O(n)
(loop for e across vector
@pnathan
pnathan / keyspace.lisp
Created November 23, 2013 09:51
Calculate the keyspace of a password.
(defun keyspace (string)
"Calculates the keyspace of an ASCII string; this can be used to
deny certain passwords from being used."
;; Hopefully the implementation is a smart string and knows how long
;; it is automatically.
(let ((length (length string))
(capabilities (make-hash-table :test #'eq)))
;; O(n)
(loop for ele across string
@pnathan
pnathan / scheduler.pro
Created November 25, 2013 08:35
Schedule suggester
% given constraints on a schedule with multiple people, find out what slots work.
available(monday, morning, jim).
available(tuesday, afternoon, jim).
available(wednesday, morning, jim).
available(wednesday, morning, julia).
available(tuesday, afternoon, james).
available(friday, afternoon, james).
@pnathan
pnathan / gist:7649433
Created November 25, 2013 21:44
cl-postgres integration with local-time
(defmethod cl-postgres:to-sql-string ((arg local-time:timestamp))
(values
(format nil "~a" arg)
"timestamp"))
(require 'sb-introspect)
(defun curry-helper (paramlist args function-name)
(if (= (length paramlist) (length args))
(apply function-name args)
(lambda (&rest more-args)
(let ((args (append args more-args)))
(assert (>= (length paramlist) (length args)))
(curry-helper paramlist args function-name)))))

Howto build a rust compiler for the Raspberry Pi on Debian 7.1 (wheezy)

# additional information: http://stackoverflow.com/questions/19162072/installing-raspberry-pi-cross-compiler/19269715#19269715
sudo apt-get install git build-essential
test `uname -m` = x86_64 && sudo apt-get install ia32-libs
git clone https://github.com/raspberrypi/tools.git
export PATH=$PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH
git clone http://github.com/mozilla/rust.git
cd rust

./configure --target=arm-unknown-linux-gnueabihf