Skip to content

Instantly share code, notes, and snippets.

View pnathan's full-sized avatar
⚒️
worker

Paul Nathan pnathan

⚒️
worker
View GitHub Profile
;; 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 / 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))
@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 / 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 / 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