Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar

Max Countryman maxcountryman

View GitHub Profile
maxcountryman /
Created October 4, 2023 15:15
A sketch of generalized user authentication based on tower-sessions.
use std::{marker::PhantomData, net::SocketAddr};
use async_trait::async_trait;
use axum::{
middleware::{self, Next},
use axum_core::{
maxcountryman /
Created January 9, 2023 19:57
Generating tags with GPT
echo -e $(curl -s \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "Extract tags from the following text. Limit five tags. Output JSON.\\n\\nText: Folksonomy is a classification system in which end users apply public tags to online items, typically to make those items easier for themselves or others to find later. Over time, this can give rise to a classification system based on those tags and how often they are applied or searched for, in contrast to a taxonomic classification designed by the owners of the content and specified when it is published.[1][2] This practice is also known as collaborative tagging,[3][4] social classification, social indexing, and social tagging.\\n\\n<Output>", "temperature": 0, "max_tokens": 1000}' | jq .choices[0].text) | tr -d '\\' | sed -r 's/^"|"$//g' | jq .tags
maxcountryman / com.docker.system-prune.plist
Created June 1, 2021 14:51
launchctl load -w /Library/LaunchDaemons/com.docker.system-prune.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
set shell=/bin/bash
if &compatible
set nocompatible
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
Plug 'arcticicestudio/nord-vim'
maxcountryman / merkle.tree.clj
Last active January 13, 2022 20:53
A Clojure Merkle tree utilizing SHA-256.
(ns merkle.tree
(:import [ MessageDigest]))
(defn sha-256-digest [bs]
(doto (MessageDigest/getInstance "SHA-256")
(.update bs))))
(def double-sha-256 (comp sha-256-digest sha-256-digest))
> "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

Flask-Login Demo


$ pip install flask
$ pip install flask-login


(def ^{:const true :private true}
(defn encode
"Encodes v in a new base of ks."
[ks v]
(let [base (count ks)]
(apply str
(defn half
(bit-shift-right (count s) 1)) ;; faster division by 2
(defn left-right
(let [v (if-not (vector? v) (vec v) v)
h (half v)]
[(subvec v 0 h) (subvec v h)]))
(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)))]}