Skip to content

Instantly share code, notes, and snippets.

View alanhoyle's full-sized avatar

Alan Hoyle alanhoyle

View GitHub Profile
@alanhoyle
alanhoyle / fix_file.sh
Created May 10, 2022 22:23
Insert line in file and keep timestamp
temp_file=$(mktemp)
touch -r $1 $temp_file
sed -i '/^.*put something above me.*/i text_to_be_inserted' $1
touch -r $temp_file $1
rm $temp_file
@alanhoyle
alanhoyle / treasurydirect_copypasta.user.js
Last active May 25, 2023 18:02 — forked from dennisstewart/treasurydirect_copypasta.user.js
Re-enables the password box on TreasuryDirect.gov so I can paste from my password manager
// ==UserScript==
// @name TreasuryDirect Copypasta
// @namespace https://www.treasurydirect.gov/RS/PW-Display.do
// @version 0.2
// @description Allow creds to be pasted from a password manager into the TreasuryDirect login form.
// @author Dennis Stewart (update by Alan Hoyle)
// @license The Strong Style Public License https://raw.githubusercontent.com/dennisstewart/cvs-checker-py/main/LICENSE
// @match https://www.treasurydirect.gov/RS/PW-Display.do
// @match https://treasurydirect.gov/RS/PW-Display.do
// @icon https://www.google.com/s2/favicons?sz=64&domain=treasurydirect.gov
@alanhoyle
alanhoyle / body.sh
Last active November 7, 2023 15:18
body (): a bash function that prints the first few lines of STDIN (1 line default) and then runs a command on the remaining STDIN
body() {
local HEADER_LINES=1
local COMMAND="sort"
if [ -t 0 ]; then
>&2 echo "ERROR: body requires piped input!"
>&2 echo ""
fi
if [[ -t 0 || "$1" == "-h" || "$1" == "--help" ]] ; then