Skip to content

Instantly share code, notes, and snippets.

@dunhamsteve
dunhamsteve / notion_todo.py
Created December 5, 2018 02:55
reads cached data from Notion.app's localStorage, collects incomplete todo items, and writes them to todo.html
#!/usr/bin/env python3
# This is written for OSX, python3, and the current (2018-12-04) version of the Notion app
# It writes incomplete todo items, found in Notion's localStorage, to a "todo.html" file,
# with links back to the Notion app
import os
import sqlite3
import json
from html import escape
@dunhamsteve
dunhamsteve / paperback
Created January 15, 2021 17:10
Script to back up dropbox paper
#!/usr/local/bin/python3
# Backup dropbox paper.
# This expects a ~/.auth/dropbox file that contains your dropbox bearer token.
import requests, os, json, re
from pprint import pprint
oj = os.path.join
#!/usr/bin/env node
// Placed in the public domain
// list folders in primary Craft space
// I've combined this into one file for the gist
// The top reads the Craft DB into memory (takes about 380ms for 50k blocks)
// The end looks up and prints the folder names
// You can reuse the top bits for other purposes.
@dunhamsteve
dunhamsteve / dumpCraftDB.js
Last active May 1, 2021 03:50
This script exports your Craft.app databases as json files.
#!/usr/bin/env node
// Placed in the public domain
// Dump craft database as json
// This is intended as a sample of how to extract craft raw data for
// playing around with. It has no dependencies aside from node.
// The top section reads the Craft DB into memory (takes about 380ms for 50k blocks)
@dunhamsteve
dunhamsteve / getcraftdoc
Last active May 20, 2021 00:26
Copy a shared craft document to pasteboard
#!/usr/bin/env python3
# pip3 install pyobjc requests
from AppKit import NSPasteboard
import json, requests, re, sys
def rewrite(url):
m = re.match(r'https://www.craft.do/s/(\w+)',url)
if not m:
#!/usr/bin/env python3
# This script creates Idris2.docset for use in Dash.app
# It expects idris to be in ~/.idris2 and is hardcoded to 0.5.1 at the moment.
import os, sqlite3, html5lib, re
oj = os.path.join
debug = lambda *x: None
-- https://www.cs.nott.ac.uk/~psymp4/files/dependently-typed-compilers.pdf
data Exp : Type -> Type where
Val : t -> Exp t
Add : Exp Nat -> Exp Nat -> Exp Nat
If : Eq t => Exp Bool -> Exp t -> Exp t -> Exp t
eval : Exp t -> t
eval (Val x) = x
eval (Add x y) = eval x + eval y
@dunhamsteve
dunhamsteve / agda_keys.txt
Last active July 20, 2022 20:38
Keymap dumped from VSCode Agda extension
\  
\!! ‼
\! ¡
\!? ⁉
\"' “
\"< «
\"> »
\" ̈
\"A Ä
\"E Ë
@dunhamsteve
dunhamsteve / psmap
Last active August 2, 2022 14:35
Process Treemap
#!/bin/bash
# This script generates a treemap of the current memory usage (RSS)
awkcode='
$1 == "PID" { next }
/.*/ {
cmd = substr($0,index($0,$4));
sub(/.*\//,"",cmd);
gsub(/\//,"_",cmd);
@dunhamsteve
dunhamsteve / WellTyped.idr
Created September 6, 2022 13:35
"Well-Typed Interpreter" from the Idris2 docs.
module WellTyped
import Data.Vect
data Ty = TyInt | TyBool | TyFun Ty Ty
interpTy : Ty -> Type
interpTy TyInt = Integer
interpTy TyBool = Bool
interpTy (TyFun x y) = interpTy x -> interpTy y