Skip to content

Instantly share code, notes, and snippets.

@kgaughan
kgaughan / upload.sh
Created January 5, 2016 17:00
PyPI-style documentation server upload script.
#!/bin/sh
# Require the given tools all be present.
require () {
for tool in $@; do
if ! which $tool 2>&1 >/dev/null; then
printf "%s required.\n" "$tool" >&2
exit 1
fi
done
@kgaughan
kgaughan / saner_getopt.php
Created December 18, 2015 15:57
A saner PHP getopt.
<?php
function saner_getopt($opts, $longopts=null, $argv=null) {
if (is_null($argv)) {
$argv = $GLOBALS['argv'];
}
if (is_null($longopts)) {
$longopts = array();
}
$parsed = getopt($opts, $longopts);
@kgaughan
kgaughan / retools.py
Created November 4, 2015 16:42
retools caching example
import time
from retools.cache import cache_region, CacheRegion
@cache_region('short_term')
def myfunc(arg1):
print "In myfunc"
return 2 * arg1
Jul 29 11:10:13 cian knot[86688]: notice: [talideon.eu] NOTIFY, incoming, 2a01:a8:dc2:33::33@53755: unauthorized request
Jul 29 11:10:13 cian knot[86688]: notice: [talideon.eu] NOTIFY, incoming, 78.153.202.4@5042: unauthorized request
Jul 29 11:10:21 cian knot[86688]: notice: [gaughan.me] NOTIFY, incoming, 78.153.202.4@5042: unauthorized request
Jul 29 11:10:22 cian knot[86688]: notice: [gaughan.me] NOTIFY, incoming, 2a01:a8:dc2:33::33@33170: unauthorized request
Jul 29 11:10:25 cian knot[86688]: notice: [talideon.com] NOTIFY, incoming, 2a01:a8:dc2:33::33@13798: unauthorized request
Jul 29 11:10:25 cian knot[86688]: notice: [talideon.com] NOTIFY, incoming, 78.153.202.4@5042: unauthorized request
Jul 29 11:10:25 cian knot[86688]: notice: [stereochro.me] NOTIFY, incoming, 2a01:a8:dc2:33::33@12630: unauthorized request
Jul 29 11:10:25 cian knot[86688]: notice: [stereochro.me] NOTIFY, incoming, 78.153.202.4@5042: unauthorized request
@kgaughan
kgaughan / gist:d1498b42156ecb89980f
Created June 15, 2015 10:52
Sending an email from the shell
# To send a email, use the 'mailx' command. This takes the email to send on
# standard input. The -s flag is used to specify your subject, and the
# recipient address is specified without any flags. Everything after '--' is
# passed on to the Mail Transport Agent (MTA, the local mailserver), and the
# '-f' flag is used to specify the sender address, while '-F' is used to
# specify the sender name.
#
# See 'man 1 mailx' for details. The Debian packages you can use for this are
# 'bsd-mailx' or 'heirloom-mailx', though both present slightly different
# command line interfaces. I'm using 'bsd-mailx' here.
@kgaughan
kgaughan / gist:4ab0f0fca88838cfa280
Created May 29, 2015 15:26
Bad IP in autoritative section section: dns9.linuxpl.com should have 78.46.68.78 as its A record, not 144.76.189.18
% dig +aaonly @dns9.linuxpl.com admpassivewindows.ie ANY
; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> +aaonly @dns9.linuxpl.com admpassivewindows.ie ANY
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30496
;; flags: qr aa rd; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 3
;; WARNING: recursion requested but not available
@kgaughan
kgaughan / gist:cf9a01bda8daf0a43741
Created May 15, 2015 15:12
DNS isn't rocket science... or maybe it is...
lir:~% host 1.39.35.161
161.35.39.1.in-addr.arpa domain name pointer 1-39-35-161.live.vodafone.in.
lir:~% host 1-39-35-161.live.vodafone.in
Host 1-39-35-161.live.vodafone.in not found: 3(NXDOMAIN)
May 15 14:13:06 lir postfix/smtpd[86084]: connect from unknown[115.134.25.73]
May 15 14:13:06 lir postfix/smtpd[86084]: lost connection after CONNECT from unknown[115.134.25.73]
May 15 14:13:06 lir postfix/smtpd[86084]: disconnect from unknown[115.134.25.73]
May 15 14:13:06 lir postfix/smtpd[86084]: connect from unknown[115.134.25.73]
May 15 14:13:08 lir postfix/smtpd[86084]: lost connection after UNKNOWN from unknown[115.134.25.73]
May 15 14:13:08 lir postfix/smtpd[86084]: disconnect from unknown[115.134.25.73]
May 15 14:13:17 lir postfix/smtpd[86084]: connect from unknown[115.134.25.73]
May 15 14:13:19 lir postfix/smtpd[86084]: lost connection after UNKNOWN from unknown[115.134.25.73]
May 15 14:13:19 lir postfix/smtpd[86084]: disconnect from unknown[115.134.25.73]
May 15 14:13:22 lir postfix/smtpd[86084]: connect from unknown[115.134.25.73]
@kgaughan
kgaughan / hlm2-dewad
Created March 15, 2015 06:33
Extracts resources from Hotline Miami 2 WAD files
#!/usr/bin/env python
"""\
Extract files from Hotline Miami 2 WAD files.
Usage:
hlm2-dewad --help
hlm2-dewad [--flatten] <wad-path> [<path>]
hlm2-dewad --list <wad-path>
Options:
@kgaughan
kgaughan / gist:5196af89eca7d2a8ce69
Created December 6, 2014 16:41
Submission port test
234.<--220 lir.talideon.com ESMTP Postfix\r\n
372.-->EHLO from.com\r\n
377.<--250-lir.talideon.com\r\n
250-PIPELINING\r\n
250-SIZE\r\n
250-VRFY\r\n
250-ETRN\r\n
250-STARTTLS\r\n
250-ENHANCEDSTATUSCODES\r\n
250 8BITMIME\r\n