Skip to content

Instantly share code, notes, and snippets.

@jpf
jpf / turretpaste.lua
Created January 5, 2021 18:29
Hammerspoon code to do a "turret paste"
popHopper = function()
return nil
end
turretPaste = function()
next = popHopper()
if next == nil then
-- this will result in no action after a keypress
clip = hs.pasteboard.readString()
popHopper = string.gmatch(clip, "[^%s]+")
else

After many years of writing and thinking about developer documentation, I'm convinced that the discipline is still in its infancy. The goal of this document is to summarize my current opinions on the topic of documenting software.

When you ask a software developer what their favorite documentation is, you'll get a wide range of opinions with consensus centering roughly around the Stripe and Twilio documentation, as well as the documentation for open source software like Django, Perl, Flask, etc.

In academia, the uncontested master craftsman of developer documentation is Donald Knuth, who pioneered "Literate Programming"

At the frontier of developer documentation, we find projects like Eve and other projects inspired by Bret Victor's seminal "Inventing on Principle" video.

However, as folks at Dynamicland will often point out, the medium (in the McLuhan sense of the word) of software hasn't changed much since the days when code was written on teletypes: We still write software on fancy typewriters. The

{ config, pkgs, ... }:
let
chatServer = "chat.example.com";
in
{
imports = [
./hardware-configuration.nix
];
@jpf
jpf / clean-token.el
Created August 26, 2019 05:09
Clean up passwords and tokens for use in documentation
;; Turns a password like "qWXNNXb6m(TM77WiVtC87c*" into "aABCDEb0c(FG12HdIeJ34f*"
;;
;; Use the clean-token function by marking a region you want to be "cleaned" and then running M-x clean-token
(defun token-cleaner (token)
"Given a TOKEN as a string, return a string where the letters in TOKEN have been replaced with letters from the same type"
(defun next-letter (letter smallest-letter largest-letter)
"Given LETTER, return the next letter in the sequence between SMALLEST-LETTER and LARGEST-LETTER"
(let ((proposed-letter (char-to-string (1+ (string-to-char letter)))))
(if (string> proposed-letter largest-letter)
smallest-letter
@jpf
jpf / count-bits.py
Created August 27, 2018 20:17
Counts the number of "1" and "0" bits in an input file
#!/usr/bin/env python3
# Counts the number of "1" and "0" bits in an input file
import sys
bits_per_byte = 8
# Via: https://stackoverflow.com/a/1035456
def bytes_from_file(filename, chunksize=8192):
with open(filename, "rb") as f:
while True:
var tracery = require('tracery-grammar'); // https://github.com/v21/tracery
var grammar = tracery.createGrammar({
'aas': ['#thing# as a service.'],
'thing': [
'Chaos',
'Denial of Service',
'Insurrection',
'Monday',
'Sucks',
'apocalypse',
@jpf
jpf / showoff.sh
Last active October 23, 2021 19:41
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl -p xmlstarlet -p imagemagick -p jp2a -p lolcat
#
# showoff.sh:
# Demonstrate the capabilities of Nix by writing a gratuitously complex shell
# script that combines 5 different command line utilities together.
#
# Do the following to run this demo:
# If you don't have Nix yet, install it with this command:
# $ curl https://nixos.org/nix/install | sh
@jpf
jpf / nix_and_python.py
Created June 1, 2016 18:00
A Python script that uses Nix to automatically bootstrap dependencies.
#! /usr/bin/env nix-shell
#! nix-shell -i python -p python27Packages.flask python27Packages.emoji
#
# This is a demo of using Nix to manage packages for a program in a language agnostic way.
# If you run this example as an executable, it'll Just Work, even if you don't have Flask or emoji installed. Try it out!
#
# $ curl https://nixos.org/nix/install | sh
# $ chmod a+x nix_and_python.py
# $ ./nix_and_python.py
from flask import Flask
@jpf
jpf / thoughts-on-literate-programming.md
Last active June 7, 2021 03:50
Thoughts after 6 months of literate programming

Thoughts after 6 months of literate programming

I wrote my first literate program in November of 2015. Since then, I've been writing literate programs on an almost daily basis. It has been an experience with a sort of enlightenment that I haven't had in a long time. Not only is it a lot of fun to write literate programs, I feel like I have gained a new "super power" of sorts.

Below are my thoughts on my experiences with literate programming so far.

#!/bin/bash
# http://stackoverflow.com/questions/8175000/parsing-arguments-options-flags-in-a-bash-script
base_url=""
client_id=""
origin=""
password=""
username=""
verbose=0