Skip to content

Instantly share code, notes, and snippets.


Nathan Henrie n8henrie

View GitHub Profile
n8henrie /
Last active Jun 15, 2022
Make alacritty into a pop-up scratchpad
#!/usr/bin/env bash
set -Eeuf -o pipefail
shopt -s inherit_errexit
log() {
echo "$*" > /dev/stderr
err() {
n8henrie /
Created Mar 8, 2022
Convenience script to build a Quicksilver plugin from CLI
# bash 3.2-compatible convenience script to:
# - search by partial name for a plugin in the `QSPLUGINS` subdirectory
# (default `./QSPlugins`)
# - clean plugin directory
# - clean QS directory
# - `rm -rf /tmp/QS`
#!/usr/bin/env python3
Use the MacOS `airport` utility to get a running average of the WiFi signal
strength (RSSI).
Python 3.8+, so works with `/usr/bin/python3` on Monterey.
import os
import statistics
n8henrie /
Last active Oct 6, 2021
Modify a nixos image to use a BTRFS root
# NB: I am no bash pro, so this could be dangerous.
# Please read through it and make sure you double check my work.
# Assuming nixos image nixos-sd-image-21.05pre-git-aarch64-linux.img and sdcard at /dev/sdx
# Example usage: `sudo ./ nixos-sd-image-21.05pre-git-aarch64-linux.img /dev/sdx`
# NB: This will overwrite /dev/sdx!
set -Eeuf -o pipefail
n8henrie / quick replace.applescript
Created Aug 13, 2021
Quicksilver action to run a regex on input text
View quick replace.applescript
using terms from application "Quicksilver"
on get direct types
return {"NSStringPboardType"}
end get direct types
on get indirect types
return {"NSStringPboardType"}
end get indirect types
n8henrie / Open in MacVim.js
Last active Sep 13, 2021
JXA to open finder selection in MacVim, or default to an empty buffer
View Open in MacVim.js
// For use in Hammerspoon via hs.osascript.javascriptFromFile
'use strict';
(function () {
const finder = Application("Finder")
const currentApp = Application.currentApplication()
currentApp.includeStandardAdditions = true
let selection = finder.selection()
n8henrie /
Last active Mar 24, 2021
Create all permutations from a collection
/// My naive implementation based on
/// [this javascript implementation](
/// ([blog post here](
/// NB: Runs fine on stable rust, unstable only needed for the benchmarking
/// For comparison:
/// using [itertools](
n8henrie / Make AppleTV Screensaver.applescript.js
Last active Dec 3, 2021
Apple JXA script to create and populate an album with a random sample of favorite photos
View Make AppleTV Screensaver.applescript.js
#!/usr/bin/osascript -l JavaScript
// Apple JXA script to create and populate an album with a random sample of favorite photos
// Author: @n8henrie
// Rename from .applescript.js to .applescript (.js for GitHub syntax highlighting)
function getRandomSubarray(arr, size) {
var shuffled = arr.slice(0), i = arr.length, temp, index;
while (i--) {
index = Math.floor((i + 1) * Math.random());
#!/usr/bin/env python3
import argparse
import sys
import typing as t
__author__ = "Benjamin Kane"
__version__ = "0.1.0"
__doc__ = f"""
Pretty-print simple Bash command from one line of stdin
n8henrie / congress.ipynb
Last active Dec 20, 2019
A quick look at congress bills in recent history by unified or divided congress
View congress.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.