Skip to content

Instantly share code, notes, and snippets.

View bk2204's full-sized avatar

brian m. carlson bk2204

View GitHub Profile
#!/bin/sh
#
# Run this script as "ssh-key-algo [email protected]". You can also specify a
# different location if you'd like to run this against an GitHub Enterprise
# Server instance.
DIR=$(mktemp -d -t tmp.XXXXXXX)
trap 'rm -fr "$DIR"' EXIT
@bk2204
bk2204 / list-unsubscribe
Created February 2, 2024 21:13
A script to unsubscribe users from mailing lists
#!/bin/sh
# Pipe an email to standard input and, if it supports RFC 8058 one-click unsubscribe, you will be automatically unsubscribed.
formail -c -x List-Unsubscribe | perl -pe 's!<https?://([^>]+)>!$1!' | \
xargs curl -X POST -H'Content-Type: application/x-www-form-urlencoded' -dList-Unsubscribe=One-Click
@bk2204
bk2204 / local.sh
Created August 5, 2024 01:38
A way to make local variables work across a variety of shells
#!/bin/sh -e
# This shell script demonstrates how to use the local keyword to create
# dynamically-scoped variables in various shells. Notably, this technique works
# with AT&T ksh, as well as bash, dash, mksh, pdksh, zsh, busybox sh, and other
# Debian Policy-compliant sh implementations.
# Simple Perl-compatible testing framework. Produces TAP output.
COUNT=0
is () {