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 /
Created Mar 28, 2018
Video to gif script
# Args: input video file, start time in HH:MM:SS, duration in seconds, output
# gif file.
# Tmpdir
rm -rf /tmp/video2gif
mkdir /tmp/video2gif
mplayer -nosub -ao null -ss "$2" -endpos "$3" "$1" -vo jpeg:outdir=/tmp/video2gif:quality=100
aphyr / gist:0ad3458a1478db97517e7ac2faf2da00
Created Oct 5, 2017
Advice on benchmarking databases
View gist:0ad3458a1478db97517e7ac2faf2da00
Hi S-------. I'm not an expert in performance benchmarking--I focus on
correctness and safety--but I have a few pieces of advice here.
0. Pick multiple workloads that cover the gamut of behaviors in each DB.
*Don't* choose a completely sharded workload for VoltDB. Don't choose a
purely commutative workload for Cassandra. Cassandra's Paxos
implementation is slow and a good benchmark will demonstrate
that--however, it *doesn't* (I think?) require a global coordinator,
which means it might *scale* better than a single-coordinator system
like, say, VoltDB. Talk about those differences!
View specificity.clj
(def conf {:people [{:lang :clojure}, {:lang :ruby}, {:lang :m4}]})
(defn clojurists
"Returns all clojurists at a conference."
(filter #(= :clojure (:lang %)) (:people conf)))
(defn final-person
"Returns the last attendee to the conference."
View spec.clj
(def example-history
{:txns [{:ops [{:f :read, :k :x, :v 1}]}]})
(defn index-txns
"Takes a raw history, and adds a sequential integer index :i to each txn in the history."
(update example-history :txns
(partial map-indexed (fn [i txn] (assoc txn :i i)))))
; So in core.typed I'd type this as (ignoring type functions and just writing things out literally)
aphyr / structure.clj
Created Apr 16, 2017
Extract a schema from a clojure object
View structure.clj
(require '[clojure.walk :as w])
(defmacro both [a b pred] `(and (~pred ~a) (~pred ~b)))
(defn union-structure [a b]
(cond (= a b) a
(both a b vector?) [(reduce union-structure (concat a b))]
(both a b map?) (merge-with union-structure a b)
; Dunno, said the ghoul
View distinct-identical.clj
(defn distinct-identical
"Like distinct, but only skips elements which are identical to those already
([xs] (distinct-identical xs {}))
([xs seen]
(when (seq xs)
(let [x (first xs)
h (hash x)
seen-xs (get seen h)]
aphyr / core.clj
Created Feb 13, 2017
Randomly assign hue lights from interweb color schemes
View core.clj
(ns lights.core
(:require [me.raynes.clhue [config :as conf]
[lights :as lights]]
[clj-http.client :as http]
[clojure.pprint :refer [pprint]]
[ :as io]
[hickory [core :as h]
[select :as hs]]
[cheshire.core :as json]
[clojure.core.reducers :as r]))
aphyr /
Created Jan 27, 2017
Jepsen pandoc templates
set FORMAT markdown+yaml_metadata_block+raw_tex+fenced_code_blocks+backtick_code_blocks+autolink_bare_uris+intraword_underscores+footnotes+auto_identifiers+ascii_identifiers
set OPTIONS -s --smart --number-sections
for dir in $argv
cd $dir
cp ../template.latex ./
pandoc -f $FORMAT $OPTIONS -o article.tex --template ../template.latex; and xelatex article.tex; # and evince article.pdf &
View rivers.edn
INFO jepsen.util - 635 :ok :read [{:val -1, :sts 0N, :node -1, :process -1, :tb -1} {:val 0, :sts 14719766284873261820000000000N, :node 2, :process 12, :tb 0} {:val 1, :sts 14719766285512842950000000000N, :node 4, :process 19, :tb 0} {:val 2, :sts 14719766286362323440000000000N, :node 2, :process 7, :tb 0} {:val 3, :sts 14719766286703404550000000000N, :node 4, :process 9, :tb 0} {:val 4, :sts 14719766286915349320000000000N, :node 2, :process 27, :tb 0} {:val 5, :sts 14719766287378762320000000000N, :node 0, :process 10, :tb 0} {:val 6, :sts 14719766287988746000000000000N, :node 2, :process 12, :tb 0} {:val 7, :sts 14719766288492589830000000000N, :node 3, :process 8, :tb 0} {:val 8, :sts 14719766290198946260000000000N, :node 1, :process 21, :tb 0} {:val 9, :sts 14719766291533233220000000000N, :node 3, :process 18, :tb 0} {:val 10, :sts 14719766291994797100000000000N, :node 3, :process 28, :tb 0} {:val 11, :sts 14719766293022430150000000000N, :node 2, :process 7, :tb 0} {:val 12, :sts 14719766293773838770000000
aphyr / history.txt
Created Aug 17, 2016
Elasticsearch 5.0.0-alpha5 divergence and partial data loss
View history.txt
This file has been truncated, but you can view the full file.
27 :invoke :read 0
7 :invoke :write 0
23 :invoke :read 0
23 :fail :read 0
27 :fail :read 0
3 :invoke :write 1
10 :invoke :read 0
16 :invoke :read 0
4 :invoke :write 2
You can’t perform that action at this time.