Skip to content

Instantly share code, notes, and snippets.

be gay, do crimes

Kyle Kingsbury aphyr

be gay, do crimes
Block or report user

Report or block aphyr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aphyr / with-retry.clj
Created Jan 20, 2016
Recur from within catch block
View with-retry.clj
(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
[initial-bindings & body]
(assert (vector? initial-bindings))
View gist:8381740
Dear Mr. Bezos,
My sincerest apologies for cluttering your inbox, but my best friend is
an Amazon employee, and he swears that making an earnest case to you is
the surest way to shift things for the better at Amazon. Here goes.
It's Saturday evening and I feel like watching Arrow with my best
friend. Hey, it's on Amazon! How's this work? Well it says I can buy a
TV Pass for the season. What's a TV Pass? says:
aphyr / download.txt
Last active Jan 9, 2020
clj-ssh errors
View download.txt
java.lang.IllegalArgumentException: No matching clause: 
at clj_ssh.ssh$scp_sink.invokeStatic(ssh.clj:981) ~[classes/:na]
at clj_ssh.ssh$scp_sink.invoke(ssh.clj:977) ~[classes/:na]
at clj_ssh.ssh$scp_from.invokeStatic(ssh.clj:1094) ~[classes/:na]
at clj_ssh.ssh$scp_from.doInvoke(ssh.clj:1044) ~[classes/:na]
View converge.clj
(defn converger
"Generates a convergence context for n threads, where values are converged
when (converged? values) returns true."
[n converged?]
(atom {; The convergence function
:converged? converged?
; What threads are involved?
:threads []
; And what values did they most recently come to?
:values (vec (repeat n ::init))}))
View round-trip-records.clj
; We use EDN as a serialization format in Clojure
user=> (require '[clojure.string :as str] '[clojure.edn :as edn])
; Defrecords are a common way to represent data
user=> (defrecord Star [hair body face])
#<Class@28e8ba16 user.Star>
; Serializing a defrecord to EDN is easy
user=> (def s (pr-str (Star. "ga" "ga" "ooh la la")))
import java.util.Random;
import java.util.Scanner;
* Boggle.
* @author Kyle Kingsbury
View 1.txt
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
aphyr / zfs-sync
Created Feb 7, 2015
Sync ZFS filesystems, incrementally if possible.
View zfs-sync
#!/usr/bin/env ruby
# Synchronizes ZFS filesystems.
# Takes three args: source pool, destination pool, and filesystem name.
# Syncs most recent snapshot of filesystem from source to destination pool,
# using incremental transfer if possible.
# Take a snapshot line from zfs list -t snapshot and emit a struct
aphyr / banned-friends.rb
Created Jun 12, 2019
A small script to list which of the people you follow are visible in public twitter autocomplete searches.
View banned-friends.rb
# This script tells you which of your friends (people you follow) are
# auto-completable in public twitter user searches, e.g. by typing
# @username" into the search box. It takes four arguments for twitter
# API credentials: consumer_key, consumer_secret, access_token, and
# access_token_secret. You can create an twitter API app at
# Output is a tab-separated list of accounts, one per line, where the
aphyr / gist:3200862
Created Jul 29, 2012
Clojure message passing test
View gist:3200862
(ns messagepassing.core)
(import [java.util.concurrent LinkedTransferQueue])
(def m 10000000)
(defn queue-test []
(defn bounce [in out m]
(let [value (.take in)]
(if (< value m)
You can’t perform that action at this time.