Skip to content

Instantly share code, notes, and snippets.

@icgood
icgood / wg-new.sh
Last active January 8, 2022 15:35
Configure Wireguard VPN and add new peers
#!/usr/bin/env bash
#
# Reads environment file, e.g. `wg-new.env`
# Configures WireGuard if it is not yet configured
# Adds a new peer with name and IP address
# arguments
name=$1
ip=$2
#!/bin/bash
branch=${BRANCH:-$(git symbolic-ref -q --short HEAD)}
remote=${REMOTE:-$(git config "branch.$branch.remote")}
remote=${remote:-origin}
default_branch=${DEFAULT_BRANCH:-$(git config "remote.$remote.defaultBranchName")}
default_branch=${default_branch:-$(git remote show $remote | awk '/HEAD branch/ {print $NF}')}
if [ -z "$@" ]; then
echo "usage: git open-path path/to/file"
#!/bin/bash -e
# Install to $PATH
# Usage: git diff-stats
output=$(git diff $@)
echo + $(grep -e '^\+[^\+]' -e '^\+$' <<<"""$output""" | wc -l)
echo - $(grep -e '^\-[^\-]' -e '^\-$' <<<"""$output""" | wc -l)
@icgood
icgood / socks-proxy.sh
Last active August 29, 2015 14:06
Maintains an always-open SOCKS proxy over SSH.
#!/bin/bash
HOST="$1"
if [ "$HOST" = "" ]; then
echo "usage: $0 <ssh-host>"
exit 1
elif [ "$HOST" = "--reconnect" ]; then
pkill -USR1 autossh
exit 0
fi
@icgood
icgood / sendsmtp.py
Last active December 16, 2015 22:49
Sends a message over SMTP.
#!/usr/bin/env python
"""
Sends a file through an SMTP transaction.
Author: Ian Good <ian.good@rackspace.com>
"""
import sys
import smtplib
import optparse
@icgood
icgood / proxy-chromium.sh
Last active March 7, 2023 21:59
Creates a separate, incognito Chrome/Chromium browser instance, proxied through the given SSH host to maximize privacy.
#!/bin/bash
APPLICATION="chromium"
which google-chrome
if [ $? -eq 0 ]; then
APPLICATION="google-chrome"
fi
HOST="$1"
if [ "x$HOST" = x ]; then
@icgood
icgood / away-on-lock-x.py
Created November 7, 2011 21:52
Sets and clears away status in pidgin/purple when xscreensaver locks and unlocks the screen.
#!/usr/bin/env python2
# Author: Ian Good <ian.good@rackspace.com>
# Inspired by http://costela.net/projects/awayonlock/
# Use at your own risk!
import os
import sys
import signal
import hashlib