Skip to content

Instantly share code, notes, and snippets.

@kingcons
kingcons / toy.js
Created November 12, 2014 03:22
JS Cons Trick
(function () {
var exports = {};
exports.makeArray = function (a, b) {
return function(chooser) {
return chooser(a, b);
};
};
exports.first = function (array) {
@kingcons
kingcons / oo.lisp
Last active December 25, 2015 01:09
tweaks
(defpackage :lisp-oo
(:use :cl))
(in-package :lisp-oo)
(defclass content ()
((tags :initform nil :initarg :tags :accessor content-tags)
(slug :initform nil :initarg :slug :accessor content-slug)
(date :initform nil :initarg :date :accessor content-date)
(text :initform nil :initarg :text :accessor content-text)))
@kingcons
kingcons / basics.lisp
Last active December 25, 2015 00:59
Now with more stuff!
(defpackage :cl-basics
;; Clauses we're not using: import-from, export, shadow
(:use :cl))
(in-package :cl-basics)
(defvar *foo* "bar"
"A simple variable with docstring.")
(defun foo (bar)
;; Stolen from Read-Eval-Print-Love by the inimitable Michael Fogus
(defmacro schemish (functions &body body)
`(macrolet ,(mapcar (lambda (function)
`(,function (&rest args)
`(funcall ,',function ,@args)))
functions)
,@body))
(defmacro count-macro-expansions (&body body)
"Count the number of macro expansions required to execute
BODY. Return two values: the result of executing BODY and the
number of expansions."
(let ((closures (gensym "CLOSURES-")))
`(let* ((,closures
(funcall
(compile nil
`(lambda ()
(let ((count 0))
@kingcons
kingcons / wheezy_fixup.sh
Last active December 23, 2015 00:38
Use sed on Fez settings to make it run Windowed.
#!/bin/sh
wget http://libsdl.org/release/SDL2-2.0.0.tar.gz
tar zxvf SDL2-2*tar.gz
cd SDL2-2.0.0
./configure && make -j 4
# You may need to change the path to fez for this to work
rm ~/fez/lib64/libSDL2-2.0.so.0
cp builds/.libs/libSDL2-2.0.so.0 ~/fez/lib64/
sed -i s/Fullscreen/Windowed/g ~/.config/FEZ/Settings
import smokesignal
from helga.client import helga
from helga.extensions.base import CommandExtension, ContextualExtension
class MemoExtension(CommandExtension, ContextualExtension):
"""
Memos are very useful in IRC to leave a note for someone presently offline.
"""
NAME = 'memo'
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload '(yason closer-mop alexandria)))
;; Turns out cl-json does this just as fast without all the fuss.
;; Just (cl-json:encode-json (romreader:load-rom "foo.nes") stream).
(defpackage #:json-export
(:use :cl)
(:import-from #:closer-mop #:class-slots
#:slot-definition-name)
(ql:quickload '(cl-fad cl-ppcre))
(defpackage :sloc
(:use :cl)
(:import-from :cl-fad #:walk-directory))
(in-package :sloc)
(defvar *ext->syntax*
'(("factor" "^!.*"))
git log master | grep -C 1 'Brit Butler' | grep 'commit ' | cut -d ' ' -f 2 | xargs git show > commits.txt
# I almost did this in lisp. Then I thought better of it. Update that resume!