Skip to content

Instantly share code, notes, and snippets.

9999years /
Created July 12, 2021 20:31
An unnamed type of map
from dataclasses import dataclass
from typing import Any
from typing import cast
from typing import Dict
from typing import Generic
from typing import Type
from typing import TypeVar
T = TypeVar("T")
9999years /
Created July 12, 2021 20:01
Python TypeMap; a container holding at most one value of a given type
from typing import Type
from typing import TypeVar
class ValueTypeError(ValueError):
"""Raised when a `TypeMap` receives a key-value pair where ``type(value) != key``."""
def __init__(self, key: type, value: object, message: str) -> None:
"""Construct a `ValueTypeError`.
9999years / cookie-clicker-mods.js
Created July 7, 2021 17:27
Cookie clicker mod loader userscript
9999years / yaml-spec-tweaks.js
Created June 29, 2021 15:47
YAML spec user styles
// ==UserScript==
// @name YAML spec tweaks
// @description Better link indicators
// @namespace
// @version 1.0.0
// @author Rebecca Turner
// @match*
// @icon
// @grant GM_addStyle
// ==/UserScript==
9999years /
Created September 28, 2020 19:28
Rename the default branch on all your GitHub repos. Warning: this script deletes the old default branch, which makes GitHub *automatically close* open PRs to that branch.
#! /usr/bin/env bash
set -e
# {{{ Colors, logging boilerplate
readonly PROG_NAME="$0"
function RESET { echo -e "\e[0m"; }
//! Kat Spiers has yet again bullied me into writing code.
//! Today we worked on type-level arithmetic.
use std::ops::{Add, Sub, Mul};
#[derive(Debug, Clone, PartialEq)]
enum Kat {
9999years / scheme-infix.scm
Created August 22, 2019 02:04
Infix evaluation in scheme...?
#lang r5rs
(#%require schemeunit)
(define ** expt)
(define (!= x y) (not (= x y)))
(define (^^ a b) (or (and a (not b))
(and b (not a))))
; can you believe they made && and || special forms???
(define (&& a b) (and a b))
(define (|| a b) (or a b))
#lang r5rs
(define-syntax push!
(syntax-rules (push!)
((push! x s)
(set! s (cons x s)))))
(define-syntax pop!
(syntax-rules (pop!)
((pop! s)
9999years /
Created May 28, 2019 21:00
Ideal static site generator

I want a static site generator that

  • Lets me write in Markdown, but with some syntax for injecting HTML I can't express in plain Markdown, like Hugo's shortcodes
  • Has a good pipeline for writing CSS in SASS, Javascript in Typescript, and ideally minifying / importing those assets into the page in different ways (i.e. inline OR linking) with low friction
  • Has a good templating language that I can configure on a per-page basis, customize (to add new functions / constructs), and import data to from YAML
#! /usr/bin/env python3
# Short program to read macOS plist files and output JSON; useful for manipulating / viewing the JSON with a tool like jq.
import fileinput
import json
import plistlib
def plist_to_json(plist):