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 / dropshadow.sh
Created July 11, 2018 19:35
Create a drop shadow for screenshots using ImageMagic's 'convert'
# add a 1-pixel #777 border and a 2-pixel offset drop shadow of 5 px radius
#
# source: https://stackoverflow.com/a/7136561
function dropshadow() {
# inner border color and radius
local ibc=${DS_INNER_BORDER_COLOR:-#777}
local ibr=${DS_INNER_BORDER_RADIUS:-1}
# drop shadow color, alpha, width and offset
local dsc=${DS_DROP_SHADOW_COLOR:-black}
@ernstki
ernstki / README.md
Last active September 17, 2018 23:03
Timing / logging functions for Bash shell scripts

Timer functions for Bash

Inspired by similar commands tic and toc from Matlab.

Usage

$ tick            # start a timer

$ tock            # print elapsed time
2s elapsed
@ernstki
ernstki / spinner.py
Created October 17, 2018 20:35 — forked from cevaris/spinner.py
Simple Python CLI Spinner
#!/usr/bin/env python
# source: https://gist.github.com/cevaris/79700649f0543584009e
# updated to allow an arbitrary message to be displayed in front of the spinner
import itertools
import sys
import time
import threading
@ernstki
ernstki / SHA1SUMS-win7.txt
Last active February 25, 2019 20:37
Output of 'certutil -hashfile c:\windows\notepad.exe SHA1' on Windows 7
SHA1 hash of file c:\windows\notepad.exe:
26 40 c2 90 04 2e 09 e0 41 fa 76 ae 86 37 74 7e 10 0a 5c 2c
CertUtil: -hashfile command completed successfully.
@ernstki
ernstki / SHA1SUMS-win10.txt
Last active February 25, 2019 20:37
Output of 'certutil -hashfile C:\windows\notepad.exe SHA1' on Windows 10
SHA1 hash of C:\windows\notepad.exe:
867b54f1bc5b71045a9a00baca485a24176b202c
CertUtil: -hashfile command completed successfully
@ernstki
ernstki / putty_sensible_defaults.reg
Created April 5, 2019 21:53
Sensible defaults for PuTTY
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"TerminalType"="xterm-256color"
"FullScreenOnAltEnter"=dword:00000001
; 110 characters
"TermWidth"=dword:0000006e
"Font"="Consolas"
; 11 point
"FontHeight"=dword:0000000b
@ernstki
ernstki / pubmed_search_xpath.js
Last active April 11, 2019 01:39
Using XPath to extract PMIDs from PubMed search results
// this must be run in the browser's dev console, because XMLHttpRequests will
// fail in a JS Bin or a JSFiddle document
//
// useful references
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_using_XPath_in_JavaScript
var searchURL = 'https://www.ncbi.nlm.nih.gov/pubmed/?term=';
// this is the XPath for the part of the search results containing the PMID
var pmidXPath = '//dl[@class="rprtid"]/dd';
@ernstki
ernstki / remux.sh
Last active April 12, 2019 19:49
remux - resume tmux sessions painlessly
# written as a function; either put this somewhere and source it from your
# .bashrc, or else remove the function wrapper and replace all the 'return's
# with 'exit's.
# Alias 'tmux attach-session -d -t 0' to something easier to type
function remux() {
local -a sessions tmuxopts
local sid lastsid USAGE
local USELAST=0
local TRACE=${TRACE:-0}
@ernstki
ernstki / Makefile-git-release
Last active January 1, 2022 11:53
Makefile with "release" target that creates a Git release commit + tag
SHELL = bash
SCRIPT = thescriptname
PREFIX ?= /usr/local
BINDEST = $(PREFIX)/bin
# this pattern works w/ a script where version is defined as "VERSION='x.y.z'"
# update here and line 75 if yours looks different (e.g., Perl instead of Bash)
PKGVER = $(shell sed -n "s/^VERSION='\(.*\)'/\1/p" $(SCRIPT))
READMEURL = https://gist.github.com/ernstki/75bba9e99a85bf273e8ec0f17dba6cfe
# ANSI terminal colors (see 'man tput') and
@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