Skip to content

Instantly share code, notes, and snippets.

View aphyr's full-sized avatar
💭
be gay, do crimes

Kyle Kingsbury aphyr

💭
be gay, do crimes
View GitHub Profile
@aphyr
aphyr / minikanren.pl
Created October 12, 2020 22:10
Minikanren in Lisp in Prolog
:- use_module(library(pairs)).
:- use_module(library(reif)).
not_in_list(K, L) :-
if_((L = []),
true,
([X | More] = L,
dif(K, X),
not_in_list(K, More))).
@aphyr
aphyr / gist:3043505
Created July 3, 2012 21:42
A nice recruiter letter
Hi Kyle,
My name is Tammy and I am on the team at Riviera Partners. Your name surfaced
in several of my searches today and across various filters - from distributed
systems to Clojure and encompassing Ruby and JavaScript. Well-rounded
individual, are we? I also heard from a former colleague of mine that your
programming began at the tender age of 2.... impressive! I just signed up for
CodeAcademy - should be interesting!
I am not sure how things are going for you at Boundary (are you still there)?
## Clean new node
[x] Shut down Mastodon
[x] Shut down ES
[x] Shut down Redis
[x] Delete ES data
[x] Delete Redis data
[x] Delete Postgres data
## Prep new node
@aphyr
aphyr / smolisp.pl
Created October 12, 2020 22:06
Prolog implementation of McCarthy's metacircular lisp interpreter, following pg's explication
:- use_module(library(reif)).
axiom([quote, X], X).
axiom([atom, X], R) :-
axiom(X, XR),
((atomic(XR), R = t, !) ;
(compound(XR), R = [])).
axiom([eq, X, Y], R) :-
@aphyr
aphyr / with-retry.clj
Created January 20, 2016 03:14
Recur from within catch block
(defrecord Retry [bindings])
(defmacro with-retry
"It's really fucking inconvenient not being able to recur from within (catch)
expressions. This macro wraps its body in a (loop [bindings] (try ...)).
Provides a (retry & new bindings) form which is usable within (catch) blocks:
when this form is returned by the body, the body will be retried with the new
bindings."
[initial-bindings & body]
(assert (vector? initial-bindings))
@aphyr
aphyr / pdf-sign
Created June 10, 2016 15:40
Script to sign the final page of a PDF using inkscape and pdfseparate/pdfunite.
#!/bin/bash
DIR=`mktemp -dt pdf-sign.XXXXXXXX` || exit 1
cd "$DIR"
pdfseparate "$1" "$DIR/page%d.pdf"
inkscape `ls | tail -1`
pdfunite page*.pdf "$1 signed.pdf"
rm -rf "$DIR"
import java.io.File;
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
/**
* Boggle.
*
* @author Kyle Kingsbury
*
@aphyr
aphyr / multi-dimension.clj
Created December 21, 2021 20:31
loopr single-accumulator reductions
user=> (-> '(dt/loopr [sum 0] [x xs, y ys] (recur (+ sum x y))) macroexpand pprint)
(let* [sum 0
sum (clojure.core/reduce
(clojure.core/fn reduce-x-2690 [sum x]
(clojure.core/reduce (clojure.core/fn reduce-y-2692 [sum y]
(. clojure.lang.Numbers (add (. clojure.lang.Numbers (add sum x)) y)))
sum
ys))
sum
xs)]
@aphyr
aphyr / autostart.sh
Created February 5, 2015 19:57
.config/openbox/
. $GLOBALAUTOSTART
#xmodmap ~/.xmodmaprc
#imwheel -k -b "6 7" &
eval $(cat ~/.fehbg) &
gnome-settings-daemon &
/usr/lib/notification-daemon/notification-daemon &
# Mouse
@aphyr
aphyr / 1.txt
Created October 13, 2015 18:42
Spideroak
Aphyr
Oct 11, 9:12 PM
Hi there!
First time user here--I bought a 5TB plan for the year, checked my homedir in
"Backup", and hit save. It did a bunch of disk IO for a few minutes, then just
sat at 100% CPU for the last 8 hours. The "Scan Now" spinner is rotating and it
says "Scanning folders for new backup items". The Activity tab is empty and the
Actions log says "Application: save backup selection" is finalizing. I killed