Skip to content

Instantly share code, notes, and snippets.

Max Countryman maxcountryman

Block or report user

Report or block maxcountryman

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
View vimrc
set shell=/bin/bash
if &compatible
set nocompatible
endif
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
Plug 'arcticicestudio/nord-vim'
@maxcountryman
maxcountryman / merkle.tree.clj
Last active Dec 16, 2017
A Clojure Merkle tree utilizing SHA-256.
View merkle.tree.clj
(ns merkle.tree
(:import [java.security MessageDigest]))
(defn sha-256-digest [bs]
(.digest
(doto (MessageDigest/getInstance "SHA-256")
(.update bs))))
(def double-sha-256 (comp sha-256-digest sha-256-digest))
View transducers.txt
> "To be honest, this is a somewhat advanced usage of the transducers machinery," says the Grammarly Engineering Blog, right after shoehorning a BufferedReader into the mold with "reify IReduceInit". I already felt I'd got my money's worth from reading up to this half-way point. But I was astonished at what came next.
Though it pains me to speak of it, I tell you now I have seen this "blog post", and seen too what came next. Astonishing indeed! I admire your simple description of these events, as it suggests either a man of great fortitude in the face of horror, or a man who was able to flee and forget, and I know that I am neither.
I remember the reified specimen – still alive, god have mercy – placed upon an altar to be offered up to `eduction`. Yes! Placed squarely on its unsightly variadic first argument. Why? For what purpose? We are told: "it's a recipe for the values to come." The blood drained from my face.
It was soon apparent what eldritch function would feast upon the values begotten by t
View README.md

Flask-Login Demo

Setup

$ pip install flask
$ pip install flask-login

Run

View base-62.clj
(def ^{:const true :private true}
base-62-alphabet
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
(defn encode
"Encodes v in a new base of ks."
[ks v]
(let [base (count ks)]
(apply str
(reduce
View merge-sort.clj
(defn half
[s]
(bit-shift-right (count s) 1)) ;; faster division by 2
(defn left-right
[v]
(let [v (if-not (vector? v) (vec v) v)
h (half v)]
[(subvec v 0 h) (subvec v h)]))
View loop-vars.clj
(defmacro loop-vars
"Like loop, but will automatically populate recur points where the special
var recur-> is found.
Mostly useful in mutable contexts, where some external factor causes the
recur bindings to change.
"
[bindings & body]
{:pre [(and (vector? bindings)
(even? (count bindings)))]}
View knossos-queue-model-test.clj
(ns locksmithing.queue-model-test
(:require [clojure.pprint :refer [pprint]]
[clojure.test :refer :all]
[knossos.core :refer [linearizations
linearizable-prefix
op
->Register]]
[locksmithing.queue :refer [queue]])
(:import [locksmithing.queue Node]
[java.util.concurrent.atomic AtomicReference]))
View broomy-broom.clj
;; A simple mark-and-sweep implementation over a toy VM
(ns broom.core
(:clojure-refer :exclude [pop]))
;; Maximum stack size
(def ^:const STACK-MAX 256)
;; Virtual Machine global ref
(def ^:private vm (ref {:max-objs 10
View bst.clj
(def gt? (comp pos? compare))
(def lt? (comp neg? compare))
(definterface INode
(getLeft [])
(getRight [])
(setLeft [n])
(setRight [n])
(getKey [])
You can’t perform that action at this time.