Skip to content

Instantly share code, notes, and snippets.

#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
9999years / static-site-generator.md
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):
@9999years
9999years / weird_rust_error.rs
Created March 15, 2019 16:27
Build fails when using type parameter for function in Rust
// this compiles
fn validator<F, T>(f: F) -> Box<Fn(String) -> Result<(), String> + 'static>
where F: Fn(String) -> Result<T, String> + 'static {
Box::new(move |s| f(s).map(|_| ()))
}
// this fails with:
// error[E0308]: mismatched types
// --> src\main.rs:17:14
// |
@9999years
9999years / build-command-t.ps1
Created February 27, 2019 22:51
Command-T Vim plugin build script
Begin { pushd; cd 'ruby/command-t/ext/command-t' }
Process {
/tools/ruby26/bin/ruby ./extconf.rb
/tools/msys64/usr/bin/make
}
End { popd }
@9999years
9999years / infix.scm
Created February 4, 2019 22:22
Infix arithmetic evaluation in Scheme
#lang r5rs
(#%require schemeunit)
(define (any pred lst)
(if (null? lst)
#f
(or (pred (car lst)) (any pred (cdr lst)))))
(define (list-contains? el lst)
(any (lambda (el*) (equal? el el*)) lst))
@9999years
9999years / girlmarkdown.py
Last active February 4, 2019 22:20
Girl’s Markdown
import sys
# `pip install Markdown`
from markdown import markdown
FLOWER = '🌸'
START_PINK = '<span style="color: pink">'
END_PINK = '</span>'
def girlmarkdown(text):
@9999years
9999years / ligs.py
Created February 4, 2019 15:08
something about the LaTeX listings package and OpenType ligatures
import sys
def esc(txt):
left = txt
right = txt
chrs = r'\~^'
for chr in chrs:
right = right.replace(chr, '\\char"' + format(ord(chr), 'X'))
left = left.replace('\\', '\\\\')
chrs = r'$&%#{}_'
from itertools import product
from operator import itemgetter
bools = [True, False]
def p6eq(a: bool, b: bool, c: bool) -> bool:
return (a and (b or c),
(a and b) or (a and c))
def p6():
return [list(p6eq(a, b, c))
@9999years
9999years / pragmata-pro-liga.sty
Last active October 13, 2021 07:17
Ligatures with PragmataPro 0.827, probably XeLaTeX or LuaTeX, and listings / fontspec
% setup
\usepackage{fontspec}
\setmonofont[
Contextuals=Alternate,
]{PragmataPro Liga}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
}