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
(defn distinct-identical
"Like distinct, but only skips elements which are identical to those already
seen."
([xs] (distinct-identical xs {}))
([xs seen]
(when (seq xs)
(lazy-seq
(let [x (first xs)
h (hash x)
seen-xs (get seen h)]
@aphyr
aphyr / core.clj
Created February 13, 2017 21:36
Randomly assign hue lights from interweb color schemes
(ns lights.core
(:require [me.raynes.clhue [config :as conf]
[lights :as lights]]
[clj-http.client :as http]
[clojure.pprint :refer [pprint]]
[clojure.java.io :as io]
[hickory [core :as h]
[select :as hs]]
[cheshire.core :as json]
[clojure.core.reducers :as r]))
@aphyr
aphyr / build.sh
Created January 27, 2017 07:25
Jepsen pandoc templates
#!/usr/bin/fish
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 article.md $OPTIONS -o article.tex --template ../template.latex; and xelatex article.tex; # and evince article.pdf &
@aphyr
aphyr / rivers.edn
Created August 23, 2016 18:39
rivers
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
aphyr / history.txt
Created August 17, 2016 17:17
Elasticsearch 5.0.0-alpha5 divergence and partial data loss
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
22 :invoke :read 0
@aphyr
aphyr / retry.clj
Last active August 15, 2016 23:02
with-retry
(defrecord Retry [bindings])
(defmacro with-retry
"It's really 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 / a.txt
Last active August 11, 2016 18:00
Product Hunt
Hey —
I'm writing to let you know that I’ve left my full-time role at Product Hunt.
After a few amazing years of helping founders build products and find early
adopters, I’ve made the decision to move on (more on that here). This journey
has been, by far, the most fulfilling work of my life. I can't imagine a better
team of folks to have worked towards this goal alongside.
It's been a pleasure to partner—and become friends—with so many of you. I'll
import java.io.File;
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
/**
* Boggle.
*
* @author Kyle Kingsbury
*
import java.util.*;
/**
* Array-based stack implementation.
*
* Kyle Kingsbury CS127 (Carleton College, Winter 2006)
*/
public class MyStack<E> implements RealStack<E> {
// Data
Dear Alderman,
I know you have a lot on your plate, but I would like to take a moment of your time to express my urgent support for the Police Accountability Task Force's recommendations for the Chicago Police Department.
Policing is difficult work, and pervasive distrust between police and their communities can only make it harder. We should improve officer training for youth and people in mental crisis, and focus on de-escalation techniques. Community Empowerment and Engagement Districts, and a commitment to beat-based policing, could help officers get to know the concerns of the neighborhoods they protect.
Hiring and promoting more officers of color is necessary, but we should go further: the statistics on CPD's use of guns and tasers suggest endemic racism. We should implement universal bias training, and implement an early intervention system to identify officers with problems.
As with the OPS, the IPRA appears neither motivated nor equipped to ensure the safety and just treatment of Chicago residen