Skip to content

Instantly share code, notes, and snippets.

Keith Gaughan kgaughan

Block or report user

Report or block kgaughan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#!/usr/bin/env python3
# talideon-wallpaper
# by Keith Gaughan <>
# A pipemenu script for Openbox for selecting and setting the current
# wallpaper.
# Copyright (c) Keith Gaughan, 2008.
# All Rights Reserved.
kgaughan /
Created Sep 11, 2019
Wrapper around acme-tiny for automation
#!/bin/sh -e
while getopts hc:w:t: name; do
case $name in
kgaughan / chan.go
Created Aug 4, 2019
Iteration benchmark
View chan.go
package iteration
func fiboChan(n int) <-chan int {
c := make(chan int)
go func() {
a := 0
b := 1
for i := 0; i < n; i++ {
a, b = b, a+b
View gist:1c3e694130210ed8247258dad0409783
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a horseshoe nail.
kgaughan /
Created Mar 8, 2019
Using a python script as its own mutex to prevent it executing concurrently with multiple instances of itself
#!/usr/bin/env python3
import contextlib
import fcntl
import sys
import time
class MutexException(Exception):
#!/usr/bin/env python3
def is_dyck_word(word):
i = 0
for ch in word:
if ch == '[':
i += 1
elif ch == ']':
i -= 1
kgaughan / jslib.js
Created Jan 22, 2019
Some old JS code from an older version of my site. The timestamp is April 2006, but it probably dates from earlier. Looks to be a way to make smart blockquotes.
View jslib.js
function addEvent(obj, type, fn) {
// Mozilla/W3C listeners?
if (obj.addEventListener) {
obj.addEventListener(type, fn, false);
return true;
// IE-style listeners?
if (obj.attachEvent) {
return obj.attachEvent('on' + type, fn);
kgaughan /
Created Jan 21, 2019
Treating a script as its own mutex lock.
import contextlib
import fcntl
import time
class MutexException(Exception):
Failed to lock a file.
View data_bunker.patch
diff --git a/modules/data_bunker/ b/modules/data_bunker/
new file mode 100644
index 0000000..ffd6aec
--- /dev/null
+++ b/modules/data_bunker/
@@ -0,0 +1,14 @@
+# data_bunker
+Deploys security groups and rules specific to the data bunker.
kgaughan / gist:b0ed6852f681be576f61aa0d0bf01314
Last active Dec 12, 2017
Get A records for a given domain name
View gist:b0ed6852f681be576f61aa0d0bf01314
get_nss () {
dig +aaonly @$(dig +short $(echo $1 | cut -f2- -d.) NS | head -n1) $1 NS | \
grep -v '^;' | \
awk '$4 == "NS" {print substr($5, 1, length($5) - 1)}' | sort -u
dig +short @$(get_nss $fqdn | head -n1) $fqdn A
You can’t perform that action at this time.