Skip to content

Instantly share code, notes, and snippets.

View ernstki's full-sized avatar

Kevin Ernst ernstki

  • Earth, Sol
View GitHub Profile
@ernstki
ernstki / clippy-pre-commit
Last active November 13, 2026 00:34
Clippy in your pre-commit hook
#!/usr/bin/env bash
##
## If src/wurl is to be committed but the version number hasn't changed,
## remind (me) to do that; then add any changed files to the index
##
## Usage: Save as .git/hooks/pre-commit and make it executable. Obviously,
## paths to files that are checked would need updated, it's written
## for a Perl script with a pod2man man page, and presupposes the
## existence of a Makefile with 'make pod2man' and other targets.
##
@ernstki
ernstki / webpin-cookie-cleaner.py
Last active October 23, 2026 01:39
Clean tracking cookies from WebPin’s cookie store
@ernstki
ernstki / Makefile.compose
Created September 2, 2026 22:16
A Makefile that does the minimum stuff you'd want for a simple Docker Compose setup (example for a Rails app)
TITLE = Project tasks
SERVICE = campfire
CONTAINER = $(shell basename ${PWD} | tr -dc -- -_A-Za-z0-9)-$(SERVICE)-1
HOMEPAGE = https://gist.github.com/ernstki/ad68bcc8db0fcff79da47ec9a95a38c7
include .env
help: # prints this help
@perl -e "$$AUTOGEN_HELP_PL" Makefile
@ernstki
ernstki / dewebp.sh
Last active August 19, 2026 23:29
De-google WebP images into the most sensible format
#!/usr/bin/env bash
##
## A hand-crafted script that de-googles WebP images into the most sensible
## format; GIF for animated ones, PNGs for transparent ones, otherwise JPEG
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 19 August 2026
## Homepage: https://gist.github.com/ernstki/2964db62385758031a6e2a504bcca8e1
## License: https://opensource.org/license/0bsd
##
@ernstki
ernstki / Makefile.usr.local.stow
Last active August 17, 2026 23:08
Makefile to put in `/usr/local/stow` with some common Stow update tasks
TITLE = Stow update tasks
help: # prints this help
@perl -e "$$AUTOGEN_HELP_PL" Makefile
clear: clear-schemas clear-icons # clear both GLib schema and hicolor icon caches
clear-schemas:
-sudo rm ../share/glib-2.0/schemas/gschemas.compiled
clear-icons:
@ernstki
ernstki / help.sh
Last active August 17, 2026 23:25
A sensible wrapper around 'help', 'command --help', and 'man' that does does what you mean
#!/usr/bin/bash
##
## A sensible 'help' command that wraps 'help', 'command --help', and 'man'
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: December 8 2020; updated 17 August 2026
## License: Zero-Clause BSD (effectively public domain)
## Homepage: https://gist.github.com/ernstki/cd9d7cee5e977b23b02a8818a729d5e8
##
## Installation:
@ernstki
ernstki / humansize.awk
Last active August 3, 2026 18:09
Convert human-readable figures to/from byte sizes using AWK
#!/usr/bin/awk -f
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu
## Homepage: https://gist.github.com/ernstki/8cde67c2593d10cd6e24f771f09fd5a9
## License: Zero-Clause BSD (basically public domain)
##
## Notes: Library functions themselves should work with any AWK, but the
## self-tests in the `END` block will only run with Gawk, because
## they're using the three-argument `match` which is GNU-only
##
@ernstki
ernstki / .gitignore
Created July 21, 2026 15:27
`.gitignore` to exclude Debian build artifacts from a typical `dpkg-buildpackage -b`
# Debian build artifacts
debian/remarkable/
debian/.debhelper/
debian/debhelper-build-stamp
debian/files
debian/*.substvars
debian/*.log
*.deb
*.buildinfo
*.changes
@ernstki
ernstki / imapfrm.py
Last active July 13, 2026 21:27
imapfrm - Print selected headers from an IMAP inbox
#!/usr/bin/env python3
##
## imapfrm - Print selected headers from an IMAP mailbox
##
## Uses sensible defaults that should work with DavMail[1], but you must
## define IMAP_LOGIN in the environment (or hard-code it below).
##
## The name is meant to vaguely invoke `frm` from the GNU Mailutils suite,
## and earlier historical utilities, although I made no attempt to match its
## options or output format.
@ernstki
ernstki / watchmeincrement.py
Last active July 3, 2026 19:26
Watch for new files created matching a pattern, move them somewhere else with an auto-incrementing numerical prefix
#!/usr/bin/env python3
##
## Authors: Kagi Quick, gemini/gemini-3.1-pro-preview, Kevin Ernst
## Date: 3 July 2026
## Licence: WTFPL
## Homepage: https://gist.github.com/ernstki/ba50c42ec22984afdf870030fdb84132
##
## Usage: python watchincrement.py "*.pdf" ~/Documents/00_TO_READ
##
import re