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 / 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
@ernstki
ernstki / lman.sh
Created November 2, 2022 09:12
Fetch man pages from manpages.debian.org and typeset in the terminal (for macOS)
#!/usr/bin/env bash
##
## lman - fetch GNU/Linux man pages from manpages.debian.org
##
## Author: Kevin Ernst
## Date: 1 November 2022
## License: Unlicense - https://unlicense.org/#the-unlicense
##
# can override any of these by setting LMAN_* in the environment
@ernstki
ernstki / humantime.awk
Last active October 16, 2022 18:19
Awk function to print seconds elapsed in a human-friendly format
##
## Awk function to print seconds elapsed in a human-friendly format
##
## via: https://stackoverflow.com/q/12199631#comment71504103_28451379
##
function humantime(secs, fmt) {
fmt = "%2dh %2dm %2ds"
if (secs/86400 > 1) {
@ernstki
ernstki / bumpver
Last active November 3, 2022 21:20
Bump a SemVer-like version string
#!/usr/bin/awk -f
##
## Bump a version number in x.y.z (semver) format; defaults to incrementing
## the patchlevel (the 'z' part in the example) by one.
##
## Usage: $ bumpver x.y.z [major|minor|patch]
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 11 February 2020
## License: WTFPL
@ernstki
ernstki / trunc.awk
Last active October 4, 2022 15:45
Truncate a field to an arbitrary length with awk
#!/usr/bin/env awk -f
##
## Truncate a string to an arbitrary length, with ellpsis in the middle
##
## Author: Kevin Ernst <ernstki -at- mail.uc.edu>
## Date: 4 October 2022
## License: WTFPL
## Source: https://gist.github.com/ernstki/ed98dfaa1bc718bad1e15f810825c814
##
@ernstki
ernstki / browser
Last active August 30, 2023 14:42
Pipe into a browser, or a previewer like Quick Look (macOS and Linux)
#!/usr/bin/env bash
##
## pipe into a browser or a previewer like Quick Look on Mac or Linux
##
## Authors: Kevin Ernst <ernstki -at- mail.uc.edu>
## Geoff Nixon <geoff -at- geoffnixon.net>
## Date: 24 September 2022
## See also: https://gist.github.com/defunkt/318247#gistcomment-1196817
##
@ernstki
ernstki / htmlalpine.vim
Last active July 22, 2022 23:09
Syntax highlighting for JavaScript within HTML 'x-data' attributes (for Alpine.js)
" Vim syntax file
" Language: HTML with Alpine.js directives
" Maintainer: Kevin Ernst (ernstki -at- mail.uc.edu)
" Latest Revision: 22 July 2022
"
" Original source: https://stackoverflow.com/a/5182769
" Put this file your ~/.vim/syntax directory or equivalent for Windows
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@ernstki
ernstki / centering-plaintext.md
Last active November 25, 2022 14:17
Guide to centering 80-ish column plain text content within wider terminal windows (a work-in-progress)

Centering fixed-width plaintext files in widescreen terminals

How to pad out 80-ish column plain text documents such that they're placed in the center of a much wider terminal (or other application window), for better readability.

Plain text documents in your web browser

Simplest CSS that could possibly work, assuming an 80-column plain text document. Requires Stylus or a similar browser extension. I use "URLs matching the regexp" .*\.(|TXT|txt|rst|md|ME|me)$.

@ernstki
ernstki / manc
Last active March 4, 2022 00:04
Center a man page within a wide terminal
#!/bin/bash
manc ()
{
local DEFAULT_WIDTH=100
local manpage margin pad
local width=$DEFAULT_WIDTH
local termwidth=$(tput cols)
while (( $# )); do
case $1 in
@ernstki
ernstki / getsnpcoords
Last active April 18, 2022 19:24
Fetch SNP coordinates from the UCSC MySQL server
#!/usr/bin/env bash
#
# Script to query UCSC MySQL server for SNP coordinates (but could easily be
# repurposed to query any arbitrary database/table)
#
# Author: Kevin Ernst
# Date: 2 March 2019; updated 30 August 2021
# Source: https://gist.github.com/ernstki/91b427d6714cdd4dd6560e5b4fb961f4
# License: MIT
#