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 / link-rel-next-userscript.js
Last active November 13, 2024 21:19
A userscript for adding link rel='next' to the head of the perl.org NNTP browser
@ernstki
ernstki / isoize.pm
Created November 3, 2024 09:27
Convert wacky date formats into ISO 8601 YYYY-MM-DD
#!/usr/bin/env perl
use v5.12;
use Time::Piece;
sub isoize {
# convert any wacky date formats to ISO 8601
my @dates;
foreach (@_) {
push @dates, Time::Piece->strptime($_, '%d %b %Y') if /\d+ \w+ \d{4}/;
# other date formats here
@ernstki
ernstki / gitlab-mystery-meat-userstyle.css
Last active November 2, 2024 02:12
Userstyle to fix GitLab mystery meat icons in file header - https://github.com/openstyles/stylus
button[data-testid="copy-contents-button"]::after {
content: "Copy contents";
}
svg[data-testid="copy-to-clipboard-icon"] {
display: none;
}
a[aria-label="Open raw"]::after {
content: "Open raw";
@ernstki
ernstki / reborder
Last active August 31, 2024 11:58
Use ImageMagick to trim extra pixels from an image and replace with a uniform border (default 10 pixels); good for screenshots
#!/usr/bin/env bash
##
## Trim extra pixels from around an image, e.g., a screenshot, and replace
## with a border of uniform width, of a color sampled from the four image
## corners, using ImageMagick 6.x (or above?)
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 29 August 2024
## License: WTFPL or ISC at your option
## Homepage: https://gist.github.com/ernstki/74aba058622a9cea43bebc4028aba5cd
@ernstki
ernstki / Makefile_with_built_in_help
Last active August 18, 2024 02:17
Auto-generated 'make help' from comments on Makefile targets
TITLE = A Makefile that makes its own 'make help' target
ME = $(lastword $(MAKEFILE_LIST))
HOMEPAGE = https://gist.github.com/ernstki/982edcfbf93c357bdb09878f7c724389/edit
help: # prints this help
@bash -c "$$AUTOGEN_HELP_BASH" < $(ME)
define AUTOGEN_HELP_BASH
declare -A targets; declare -a torder
targetre='^([A-Za-z]+):.* *# *(.*)'
@ernstki
ernstki / gitlapi
Last active August 17, 2024 23:37
Query GitLab v4 API endpoints with curl and jq; handles record pagination
#!/usr/bin/env bash
##
## Query a GitLab v4 API endpoint, with pagination
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## License: WTFPL
## Date: 22 May 2024
## Requires: jq (https://github.com/jqlang/jq)
## Homepage: https://gist.github.com/ernstki/3707675c8a4ddb06d128154947c49e29
##
@ernstki
ernstki / pkgutil-list-files
Created April 19, 2024 16:58
Wrapper script for macOS's `pkgutil` to list full pathnames of files in all packages, or packages matching a pattern
#!/bin/sh
pkgutil --packages \
| if [[ "$1" ]]; then grep -i "$1"; else cat; fi \
| perl -nE '
#line 5 "pkgutil-list-files"
chomp;
print STDERR "# scanning $_…\n";
$location = `pkgutil --pkg-info $_`;
$location =~ s/.*location: (.*?)\n.*/$1/s;
print STDERR "# location: $1\n";
@ernstki
ernstki / jdtt
Last active January 17, 2024 01:34
jdtt - accept command line arguments for 'yum', 'apt', or 'port' and just do the 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 / tika
Last active January 16, 2024 22:49
Wrapper script for Apache Tika, optionally enable Tesseract OCR for a single invocation
#!/bin/bash
##
## Simple wrapper script for Apache tika
##
## Usage: download the latest `tika-app*.jar` from [1] to your ~/bin
## and copy this script alongside. Make executable with
##
## chmod a+x ~/bin/tika`
##
## Test with `tika --help`.
@ernstki
ernstki / fc-reject.pl
Last active October 28, 2024 23:43
Easily disable fonts that aren't in your language, for Debian and derivatives (and possibly other Linux distros)
#!/usr/bin/env perl
##
## Usage: fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## License: MIT or CC-BY-SA-4.0, at your option
## Source: https://gist.github.com/ernstki/2ae279ad89888e4099c9852bf0ba5d11
##
use v5.12;
use warnings;
use autodie;