Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -euo pipefail
IFS=$'\t\n'
cookie_jar="$(mktemp)"
trap 'rm -f "$cookie_jar"' EXIT
ejuror_url='https://ecf.casd.uscourts.gov/ejuror/TransportRoom'
args=(
@sirhc
sirhc / wordle
Last active January 21, 2022 16:45
Script to help identify words for Wordle (https://powerlanguage.co.uk/wordle)
#!/bin/bash
#
# Usage: wordle [-f <word file>] [-g <green pattern>] [-y <yellow pattern>]... [-x <gray letters>]
#
# The word file defaults to '/usr/share/dict/words'.
#
# The green pattern defaults to '.....', which will include all five letter
# words from the word file.
#
# Multiple yellow patterns can be given, typically corresponding to each
#!/bin/bash
set -euo pipefail
IFS=$'\t\n'
cookie_jar="$(mktemp)"
trap 'rm -f "$cookie_jar"' EXIT
ejuror_url='https://ecf.casd.uscourts.gov/ejuror/TransportRoom'
args=(
#!/bin/bash
set -euo pipefail
IFS=$'\t\n'
PATH='/usr/bin:/usr/local/bin'
while read -r line; do
[[ $line =~ ^\s*$ ]] && continue
[[ $line =~ ^\s*# ]] && continue
#!/bin/bash -eu
show-config() {
readlink -f "$0"
}
trap 'exit 0' SIGINT
trap 'kill 0' EXIT
while :; do
@sirhc
sirhc / gist:34e68f1595a78189a8bf
Created April 17, 2015 03:44
Install Git with Stow

Install Git with Stow

Git requires jumping through a hoop, since it will install a full tree under the specified prefix (e.g., $prefix/usr/local/bin/git).

A couple of convenience variables.

old=2.2.1     ;# old version installed with Stow
new=2.4.0-rc2 ;# new version to be installed with Stow
@sirhc
sirhc / help.bash
Last active August 29, 2015 14:19
Print man page with -h option
#!/bin/bash -eu
tag="$( basename "$0" )"
arg1= ;# single value, required
arg2= ;# multi-value, optional
arg3= ;# multi-value, optional
nothing= ;# dry-run
verbose=
while getopts '1:2:3:nvh' opt; do
@sirhc
sirhc / gist:81253a60ec19c2e4dbac
Last active August 29, 2015 14:17
OCPM Challenge, March 2015
#!/usr/bin/env perl
use v5.20;
use warnings;
use Text::Roman qw( roman2int );
my %fn = (
b => sub { chr oct "0b$_[0]" },
d => sub { chr $_[0] },
h => sub { chr hex $_[0] },
@sirhc
sirhc / whilst.pl
Created July 25, 2014 21:34
Add a whilst keyword to Perl
#!/usr/bin/perl
#
# Inspired by https://github.com/mattt/BritishInvasion
#
# This is still a terrible idea. Just dreadful.
use 5.016;
use warnings;
BEGIN {