Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tomgidden on github.
  • I am gid (https://keybase.io/gid) on keybase.
  • I have a public key ASA-MZNrERCaWZArGbZpB8uKyVbzBIG7Xr3JmR7kUZcilgo

To claim this, I am signing this object:

@tomgidden
tomgidden / get_iplayer_filter
Last active February 26, 2017 15:52
Command line to partially cure get_iplayer's verbal diarrhoea. ie. don't show output unless/until ERROR or WARNING appears; then display it ALL.
get_iplayer --pvr 2>&1 | perl -ne 'if(/ERROR|WARNING/){$q=1;print $b;undef $b;}if($q){print $_;}else{$b.=$_;}'
@tomgidden
tomgidden / README.md
Last active November 24, 2017 18:51
Espruino Puck.js code for Page-Turn-O-Matic 4000™
@tomgidden
tomgidden / bleh.zsh
Last active July 4, 2017 02:10
Miscellaneous Docker and Gearman admin commands
# Drop all unused Gearman jobs that match _v5
while (gearadmin --drop-function `gearadmin --status | cut -f 1 | grep _v5 | xargs`) {}
# Drop all unserved functions
while (gearadmin --status -h g1 | egrep "\\s+0$" | cut -f 1 | xargs gearadmin -h g1 --drop-function) {}
# Stop and delete all running Docker containers
docker rm -f $(docker ps -q)
# Remove all docker images
@tomgidden
tomgidden / wget_files_to_names.bash
Created June 28, 2017 07:06
Like `-i` for `wget`, but allows for a second parameter to save to filename; stupid that `wget` and `curl` don't do this.
err=0
while read -r url filename tail; do
wget -O "$filename" "$url" || err=1
done < urls
@tomgidden
tomgidden / hosts.txt
Last active July 8, 2017 09:13
tcpdump filter script for iPad typing delay investigation
52.6.92.48 cognito-identity.us-east-1.amazonaws.com
52.94.216.48 aax-eu.amazon-adsystem.com
52.94.216.6 mads-eu.amazon.com
52.94.220.16 aax-eu.amazon-adsystem.com
52.94.218.7 aax-eu.amazon-adsystem.com
54.239.24.180 mobileanalytics.us-east-1.amazonaws.com
54.239.35.205 mads-eu.amazon.com
52.222.227.170 Images-na.ssl-images-amazon.com
@tomgidden
tomgidden / docker-blocker.service
Last active August 4, 2017 11:07
iptables firewall rules to stop Docker being quite so profligate on all interfaces.
# This is to get around what appears to be a colossal flaw in Docker (Swarm)
# at the time of writing.
#
# I'm no expert by any stretch, but I've googled all I can think of, and I
# can't see a way to get Docker to _NOT_ listen on all interfaces when
# exposing a port. As a result, a private unsecured service like
# "Gearman" or "Memcached" gets published to the outside world... there's
# the option of _either_ having it available only to the Docker swarm, or
# to publish it to the entire world; there's no option to have it publish
# to other network interfaces, eg. to our own webservers that are not in
@tomgidden
tomgidden / easing.h
Last active March 1, 2018 12:46
Penner's Easing Equations, cleaned up for modern compiler
/*
Disclaimer for Robert Penner's Easing Equations license:
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright © 2001 Robert Penner
All rights reserved.
@tomgidden
tomgidden / calzone.py
Created March 18, 2018 16:23
ics event organisation for webframe
#!/usr/bin/env python3
import copy
from types import SimpleNamespace
from icalendar import Calendar
from pytz import timezone, utc
from dateutil.rrule import *
from dateutil.tz import tzoffset
import datetime
import email.utils
@tomgidden
tomgidden / GNUmakefile
Created March 29, 2018 22:29
Use someone's SSH public key to encrypt a file into a self-extracting script
PRV ?= ~/.ssh/id_rsa
PUB ?= $(PRV).pub
clean:
rm -f *.enc *.key *.keyenc *.dec *.sh
# Encryption
$(PUB).pkcs8: $(PUB)
ssh-keygen -e -f $< -m PKCS8 > $@