Skip to content

Instantly share code, notes, and snippets.

Working from home

Martin Kealey kurahaupo

Working from home
  • Brisbane, Australia
View GitHub Profile
View transcode.bash
shopt -s globstar
mkdir -vp "$tdir"
kurahaupo / xterm-colourtest
Created Jan 10, 2016
Xterm Colour test pattern
View xterm-colourtest
use 5.008;
use strict;
use warnings;
use Getopt::Long qw(:config bundling);
use POSIX qw( floor );
use utf8;
kurahaupo / chresolvconf
Created Jan 14, 2015
Manually change /etc/resolv.conf but protect it from meddling by NetworkManager et al
View chresolvconf
# Update /etc/resolv.conf but keep it unwritable, even by root-owned processes.
# Useful to stop WiFi and/or DHCP from messing with it, and quite essential when
# there are multiple managers for different interface types.
# Because symlinks don't work, instead we bind-mount an appropriate file onto
# /etc/resolv.conf, chosen from those in ~/.resolvconf.d/.
# Since BIND is running locally, almost all the time that will work, so it's the
kurahaupo / xr
Last active Nov 25, 2021
Script using "xrandr" to configure multi-head display
View xr
die() { echo "$*" >&2 ; exit 1 ; }
declare -a R=( normal right inverted left ) # rotation descriptions
declare -A S
declare -A DX
declare -a EX
kurahaupo / twelve-days-of-christmas.bash
Last active Aug 29, 2015
twelve days of christmas, in bash
View twelve-days-of-christmas.bash
dox=( [1]='a partridge in a pair tree'
'2 turtle doves, and'
'3 french hens'
'4 calling birds'
$'5 gold rings\n ...'
'6 geese a-laying'
'7 swans a-swimming'
'8 maids a-milking'
View example of bash aliases inside functions
$ alias randomly='if ((RANDOM%2)) ; then'
$ dorand() { randomly print Hi ; fi ; }
$ type dorand
dorand is a function
dorand ()
if ((RANDOM%2)); then
print Hi;
kurahaupo / shorten-symlinks
Created Jan 7, 2014
Convert absolute symbolic links (those whose target starts with /) to be relative (to their containing directory). Written for Linux, but will work anywhere that has `readlink -m` and `ln -T` (the GNU versions do).
View shorten-symlinks
kurahaupo / wideascii
Created Jan 3, 2014
Convert normal ascii to equivalent double-width unicode characters
View wideascii
use utf8;
binmode STDOUT, ":utf8";
while (<>) {
s/ / /g;
print $_;
kurahaupo / foo
Last active Jun 21, 2022
There's no excuse for using #!/usr/bin/env ...
kurahaupo / siginfo
Last active Dec 29, 2015
Show signal names from Sig* lines in Linux's /proc/$PID/status
View siginfo
signals="$(trap -l)"
declare -A SIG
for s in ${signals//') '/=}