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 / 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 April 30, 2024 10:19
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;
@ernstki
ernstki / fc-json
Last active September 3, 2023 21:03
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 / md5sum
Last active September 1, 2023 22:47
[WIP] The standard 'md5sum' implemented as a Bash function for (older?) macOS
#!/usr/bin/env bash
# h/t: https://stackoverflow.com/a/28776166
if ( return 0 2>/dev/null ); then sourced=1; else sourced=0; fi
# fail on unset variables unless sourced from another script
if (( !sourced )); then set -u; fi
# set TRACE=1 in the environment to enable execution tracing
if (( ${TRACE:-} )); then set -x; fi
@ernstki
ernstki / parse-ics
Last active August 15, 2023 01:51
Quick-and-dirty iCalendar .ics parser in AWK; extracts attendees only
#!/usr/bin/awk -f
##
## Parse ATTENDEEs from iCalendar (.ics) files
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 26 July 2021
## Source: https://gist.github.com/ernstki/6d17ab342aa6a1a2de788b487e7fb29b
## License: WTFPL
##
## Hint: Pipe into `column -ts$'\t'` for a visually-aligned table
@ernstki
ernstki / convertto
Last active August 15, 2023 01:53
Convert many images to any ImageMagick-supported format in parallel
#!/bin/bash
# intended for use with https://github.com/erichs/composure
# requires ImageMagick's 'convert' and GNU Parallel
# source: https://gist.github.com/ernstki/495ff1a60509e0b771f0d65740de1a19/edit
convertto ()
{
author 'Kevin Ernst'
about 'Convert arguments to another image format based on extension'
example "$ convertto jpg *.heic"
@ernstki
ernstki / fullresmeetup.user.js
Last active July 25, 2023 23:47
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.0
// @description Copy URLs of full-resolution images from Meetup event photos page to the clipboard
// @author Kevin Ernst
// @match https://www.meetup.com/*
// @icon https://icons.duckduckgo.com/ip2/meetup.com.ico
// @grant GM_setClipboard
// ==/UserScript==
@ernstki
ernstki / annoyances.txt
Created January 18, 2023 19:30
uBlock Origin filters for various annoyances
! ref: https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters
! Stack Overflow sites
stackexchange.com##.js-consent-banner
stackexchange.com##.js-dismissable-hero
stackexchange.com##.mb16.s-anchors__grayscale.s-anchors.s-sidebarwidget__yellow.s-sidebarwidget
stackexchange.com##.left-sidebar
! https://gitlab.com
gitlab.com##.js-autodevops-banner