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 / !CHECKSUM_HOWTO.md
Last active June 16, 2025 20:46
How to create (and verify) checksums for NGS data

Hello, collaborators!

If you have the ability to do so, please compute SHA1 hashes for any files you intend to share with the Weirauch Lab. These hashes, or "checksums," are critical for verifying that we've received your data 100% intact and unmodified.

You will need to save these checksums into a file, then transmit or store that file alongside the original data. Instructions for macOS and Linux are directly below. For Windows, please follow the instructions in the "Generating checksums on Windows" section.

Generating checksums on Unix

Here is a one-liner that will do the job on a typical Unix/Linux system. macOS is also Unix, but if you are not familiar with the command line, see the section "Extra guidance for Mac users," below. If you use Windows and have Git Bash or Cygwin available, this method should also work for you.

@ernstki
ernstki / aplus.sh
Last active December 3, 2019 03:39
A+ - like 'cat -A' with Unicode symbols
#!/bin/bash
# h/t: https://unix.stackexchange.com/a/196783/278323
#
# Unicode characters
# ⇥ (rightwards arrow to bar)
# https://www.fileformat.info/info/unicode/char/21e5/index.htm
#
# · (middle dot)
# https://www.fileformat.info/info/unicode/char/00b7/index.htm
#
@ernstki
ernstki / bash-version-has-shopt.sh
Last active August 23, 2024 01:00
Determine if a given version of Bash has a specific 'shopt' option using all available 'bash' image tags on Docker Hub
#!/bin/bash
#
# old version that may not work anymore; see docker-image-test.sh instead
#
# source: http://www.googlinux.com/list-all-tags-of-docker-image/index.html
# maybe API documentation?
# shellcheck disable=SC2086
REGISTRY=https://registry.hub.docker.com/v2/repositories/library
@ernstki
ernstki / "Uncuddle" command line args.md
Last active November 23, 2024 18:20
Bash function to separate "cuddled" options like '-nvalue' or '--name=value'

"Uncuddle" arguments like -pVALUE, or --param=VALUE

Here's a Bash function that will separate option-value pairs where the option and value are glued together without an intervening space.

You give it:

  • a bunch of possible prefixes as arguments, like -p, --param=, and --parameter=
  • and as the last argument, the maybe-option-value-pair to be checked ($1 in the while (( $# )) loop below)

and it returns the VALUE part, or the empty string if there was no VALUE part (the option and argument were separate).

@ernstki
ernstki / Bash completion example.md
Last active November 23, 2024 18:24
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 / unwrap.sed
Last active March 21, 2025 00:36
unwrap - remove linebreaks from input lines—with sed!
#!/usr/bin/env bash
#
# Remove line breaks from text on stdin
#
# Author: Kevin Ernst
# Source: https://gist.github.com/ernstki/69ef6736068135d2597cee35b3f28ffb
#
# See also:
# - https://stackoverflow.com/a/1252191
# - https://stackoverflow.com/a/2764105
@ernstki
ernstki / mpv-enqueue.sh
Last active March 27, 2025 23:20
Enqueue items (like YouTube playlists) with mpv
#!/usr/bin/env bash
#
# Enqueue the named file(s) / URL(s) mpv's JSON IPC; starts an instance of mpv
# if one isn't already found in the process list
#
# Author: Kevin Ernst (ernstki -at- mail.uc.edu)
# Date: 03 July 2019; updated 12 November 2021
# Source: https://gist.github.com/ernstki/93bc8653556053e51c41cc1ba0c24255
#
# Requirements:
@ernstki
ernstki / README.md
Last active February 28, 2023 19:48
Create dropshadowed thumbnails with a simple command

thumb - a command-line thumbnailer & drop-shadower

Quickly generate drop-shadowed thumbnails from the command line using ImageMagick's [convert][convert], optionally specifying a maximum geometry for either (or both) dimensions.

Sample images created by this script

You can choose whether or not to draw a thin (1-pixel), grey ([#777][grey]) border around the image, or leave it off with the

@ernstki
ernstki / spell_check_and_talking_calc.sh
Last active August 13, 2021 17:16
Replicating Bell Labs 1982 demo of a spell checker and talking calculator - https://youtu.be/XvDZLjaCJuw
#!/bin/bash
#
# Replicating Kernighan's spell checker demo (https://youtu.be/XvDZLjaCJuw?t=315)
# and Lorinda Cherry's talking calculator (https://youtu.be/XvDZLjaCJuw?t=800)
# from the 1982 Bell Labs UNIX video
#
# Tested with Python 2.7 on Mac and Linux; your mileage may vary with Python 3.
# - You will need to 'pip install --user inflect' for the calculator part.
# - On Linux, you will need to install the 'flite' package for your distro.
#
@ernstki
ernstki / Classy .screenrc.md
Last active July 9, 2025 22:38
screenrc with a decent-looking caption / hardstatus line, including LSF job status

A classy .screenrc with LSF support

Screenshot of what you get

Here's a sensible .screenrc that does the following:

  • gives you a useful and hip-looking status line
  • tries really hard to enable 256 color support for programs that support it, like Vim
  • disables the visual bell and splash screen
  • remaps window #0 to be Ctrl+A, `, which feels more natural to me