Skip to content

Instantly share code, notes, and snippets.

View popmonkey's full-sized avatar

popmonkey popmonkey

View GitHub Profile
@popmonkey
popmonkey / speedy_tm.sh
Last active October 22, 2019 22:44
dramatically speed up Time Machine backups on OS X
#!/bin/sh
# Turns off low priorioty throttling while Time Machine backups are in progress.
# Also prevents sleeping/idling while TM is running
#
# by https://github.com/popmonkey
#
# to truly automate this, add the following to /etc/sudoers (sudo visudo)
# (remove one set of # and change 'user' to your username)
@popmonkey
popmonkey / network_test.sh
Last active April 16, 2023 05:20
EdgeOS ready script that tests for WAN connection degradation (via packet loss and latency checks)
#!/bin/sh
#
# USG and EdgeRouter route-test script for failover
#
# uses ping to check latency and packet loss.
# returns zero when within thresholds and non zero (1) when above thresholds
# uses ping, traceroute, and logger
#
# by https://github.com/popmonkey
#
@popmonkey
popmonkey / looklog.py
Last active September 21, 2019 00:34
log parser that reads multiple sources and captures SQL statements to follow a row's lifecycle - can optionally filter for specific tables and specific ids
#! /usr/bin/env python3
"""
This script is a log file parser that looks for sql UPDATE statements and filters for specified tables and ids.
It can read from multiple sources and write to a separate file for each table and id combination.
examples:
`./looklog.py -t user,order *.log`: prints UPDATE statements for the ORDER and USER tables in *.log to stdout
`tail -F current.log | ./looklog.py -t user -i 12345`: real time tails current.log and filters for updates to
@popmonkey
popmonkey / keys.sh
Last active October 16, 2018 17:13
load ssh keys into ssh key agent
# keys
for key in # list or glob of identities
do
KEY_SIG=$(cat ~/.ssh/$key.pub)
if [ `ssh-add -L | grep "$KEY_SIG" | wc -l` -ne 1 ] ; then ssh-add ~/.ssh/$key ; fi
done
@popmonkey
popmonkey / .screenrc
Created April 2, 2018 15:31
screenrc for useful prompts and window navigation
# allow the scrollback to scroll through SCREEN buffer
termcapinfo xterm* ti@:te@
# fix the damn delete key (mac Terminal.app users)
termcapinfo xterm-color kD=\E[3~
# visual bell, c'mon!
vbell off
# go directly to work
startup_message off
@popmonkey
popmonkey / fast_mysql_bak.sh
Last active April 1, 2018 17:17
fast mysql backups (and fast restore instructions)
#!/bin/bash
### WARNING!!!!! WARNING!!!!! WARNING!!!!!
#
# this script should *not* be used as is without understanding everything it does (and possibly modifying):
# 1. it assumes you want to backup all your dbs on the source machine
# 2. the restore instructions are also for restoring all dbs in the tar file
# 3. there are hardcoded paths to various utilities
#
# i'm not responsible for your lost data
@popmonkey
popmonkey / backup_base.sh
Created April 1, 2018 17:04
time machine like backups using rsync
#!/bin/bash
#
# will create new directories each time it is executed with hard links to unchanged files
# exclude file can be used to skip certain files/directories as specified by rsync
# see the FILTER section of https://linux.die.net/man/1/rsync
SRC=$1
DST=$2
if [ ! \( -d "$DST" -a -d "$SRC" \) ]; then
@popmonkey
popmonkey / keybase-popmonkey.txt
Last active August 4, 2016 04:42
keybase proof
### Keybase proof
I hereby claim:
* I am popmonkey on github.
* I am popmonkey (https://keybase.io/popmonkey) on keybase.
* I have a public key whose fingerprint is 93DD 72A0 A9F8 D017 8641 3F06 9A3A DE35 F7DA 1018
To claim this, I am signing this object: