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 / Bash completion example.md
Last active January 8, 2026 02:22
Bash programmable completion example for "cuddled" options + arguments

Bash programmable completion for -nvalue / --name=value options

I was reading [an old debian-administration.org post][debadm] about [Bash programmable completion][pcomp], and I had the same question as this person:

I created a script and I use bash_completion, but I cannot figure out how to allow the completion of "--name=value1 --name=value2" (the "=" sign in the middle stop any other completion, and I tried to play with suffixes/prefixes without any success :s

@ernstki
ernstki / fc-reject.pl
Last active December 16, 2025 23:30
Easily disable fonts that aren't in your language, for Debian and derivatives (and possibly other Linux distros)
#!/usr/bin/env perl
##
## Easily disable fonts that aren't for your language, or language-specific
## variants from large font families like Noto -- WITHOUT uninstalling them
##
## Authors: Kevin Ernst <ernstki -at- mail.uc.edu>, @wdoekes
## License: MIT or CC-BY-SA-4.0, at your option
## Source: https://gist.github.com/ernstki/2ae279ad89888e4099c9852bf0ba5d11
##
## Usage:
@ernstki
ernstki / fullresmeetup.user.js
Last active December 7, 2025 20:33
Copy URLs of full-resolution images from Meetup event photos page
// ==UserScript==
// @name Copy Meetup full-res URLs
// @namespace https://gist.github.com/ernstki
// @version 1.1.1
// @description Copy URLs of full-resolution images from Meetup event photos page to the clipboard
// @author Kevin Ernst
// @match https://www.meetup.com/*/photos/*
// @icon https://icons.duckduckgo.com/ip2/meetup.com.ico
// @grant GM_setClipboard
// ==/UserScript==
@ernstki
ernstki / Unsafelinks.pm
Last active December 7, 2025 12:17
Convert Microsoft Outlook "safelinks" URL back into human-readable URLs
@ernstki
ernstki / fc-json
Last active December 7, 2025 12:06
fc-json - print the output of `fc-cat` as JSON
#!/bin/sh
##
## fc-json - print output of 'fc-cat' as valid JSON
##
## Usage:
## $ fc-json | jq -SC .
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 2 September 2023
## License: MIT
@ernstki
ernstki / ddt
Last active December 7, 2025 11:58
ddt - accept command line arguments for 'yum', 'apt', or 'port' and just do the danged thing based on the platform
#!/usr/bin/env bash
##
## Accept arguments from popular package management tools (except Homebrew)
## and just do the right thing, based on the platform.
##
## Created out of frustration at typing `yum` on Macs and `port` on Linux
## boxes, and `apt` on RHEL/CentOS boxes all too often.
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 16 Januar 2024
@ernstki
ernstki / !Makefile with built in help.md
Last active December 7, 2025 11:48
Auto-generated 'make help' from comments on Makefile targets

Screenshot of 'make help' as generated by this Makefile

This replaces an earlier Perl version I'd been using for years, but I started thinking, hey, Bash can do all that. It's about ten lines longer than the Perl version, but possibly more readable.

Usage

GIST=https://gist.githubusercontent.com/ernstki/982edcfbf93c357bdb09878f7c724389
THING=raw/Makefile_with_built_in_help
(set -x; curl -sL $GIST/$THING || wget -qO- $GIST/$THING) > Makefile
@ernstki
ernstki / flatpak-orphans.py
Last active December 7, 2025 11:40
List space used by Flatpak ~/.var/app directories for apps that are no longer installed
#!/usr/bin/env python3
##
## flatpak-orphans.py - lists orphaned Flatpak data in ~/.var/app
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 16 October 2025
## License: MPL 2.0
## Homepage: https://gist.github.com/ernstki/f3e279e8a050c2df94e9fcfd69d67c2f
##
## Originally based on `main.py` from Flatsweep by giantpinkrobots[1], but
@ernstki
ernstki / !elementary OS Contractor tricks.md
Last active December 3, 2025 11:40
Stupid Linux `.desktop` and elementary OS Contractor tricks

elementary OS's Contractor service uses standard Linux .desktop files (spec) with a .contract extension to provide context (secondary-click) menu entries for specific MIME types. System-wide apps put these in /usr/share/contractor, whatever the Flatpak version of that is, and you can create your own in ~/.local/share/contractor. Below are some examples.

Contractor actions for all MIME types

If you want a specific Contractor action to apply to all filetypes, including device special files, directories, whatever, you can exploit the ! (exclusion) operator in the MimeType key, like this:

MimeType=!nothing;
@ernstki
ernstki / dehectonanoseconds.py
Last active November 6, 2025 16:40
Convert LDAP timestamps (100-nanosecond intervals since 1 Jan, 1601) to human-readable times in your local timezone
#!/usr/bin/env python3
##
## Convert LDAP’s “number of 100-nanosecond intervals since January 1, 1601
## (UTC)” timestamps to human-readable dates, in the local timezone. See
## reference [1] for more details.
##
## Does not use f-strings, so should work in any old Python 3.
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 13 Oct 2025