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 / 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
@ernstki
ernstki / !flatpak-du.md
Last active June 21, 2026 17:36
A `du` for Flatpak

flatpak-du: like du for Flatpaks

This utility is intended to produce more consistent and useful output than flatpak list, while papering over some of the more irritating quirks of flatpak list --show-details, such as:

  • showing completely different columns depending on whether standard out is a terminal or not
  • inability to control column headers; shown when stdout is a terminal, hidden otherwise
@ernstki
ernstki / bigdirs
Last active June 6, 2026 02:16
GNU Awk script to report large directories, N levels deep in a hierarchy
#!/usr/bin/gawk -E
##
## List the top N directories (N levels deep) by cumulative file size
##
## Usage:
##
## find . -type f -printf "%p\t%s\n" | gawk -E bigdirs [options]
##
## # or, if `bigdirs` is in your search path
## find some/path -type f -printf "%p\t%s\n" | bigdirs [options]