Skip to content

Instantly share code, notes, and snippets.

@toonetown
toonetown / patch-emulator
Created November 4, 2014 01:01
Launch Android Emulator with patch scripts
###############
# Launches (and patches) the android emulator by running all the scripts within the patch directory. The default
# value of ANDROID_EMU_PATCHES is ${HOME}/.android/avd/patches. You can specify a different value for the patch
# directory by specifying ANDROID_EMU_PATCHES as an environment variable.
#
# The scripts within the patch directory will be executed in order. The variable "${ADB}" can be used within a
# script to get the correct adb command to run (targetted to the appropriate port). The variable "${ANDROID_EMU_TDIR}"
# points to a directory that will be cleaned up when the emulator exits. The variable "${ANDROID_EMU_PATCHES}" will
# be set to the effective patch directory.
#
@toonetown
toonetown / add_user
Created May 12, 2016 18:24
Adds a user to OS X (Yosemite and later), sets the machine as "Setup Done" and skips iCloud registration for the created user.
#!/bin/bash
# Adds a user via command line, and sets the machine as "Setup Done"
# Ensure that it runs as root
if [ "$(id -u)" != "0" ]; then
echo "${0} must be run as root, or using sudo"
exit 1
fi
if [ -n "${1}" -a -n "${2}" -a -n "${3}" -a -n "${4}" ]; then
@toonetown
toonetown / docker_pipe
Last active May 20, 2016 19:56
Allows passing of data from the host to a docker container
#!/bin/bash
#
# A script to facilitate passing data from host to container in a daemon
#
# To read a variable (from within the container):
# VAR="$(docker_pipe read)"
#
# !!! Note that reading a variable will block until it is written to !!!
#
# To write to the variable that is being read (from the host):
@toonetown
toonetown / check-code
Last active June 7, 2016 17:11
A script which performs some code style checking (line length, trailing spaces, etc.)
#!/bin/bash
#######
# A script which finds various code violations (such as line spacing or trailing spaces)
#
_SCRIPT="${0}"
_QUIET=""; _TRAIL_ONLY=""; _EMPTY=""; _LENGTH_ONLY=""; _MAX_LENGTH=120; _PATHS=(); _ERR=""
_err () { "${_SCRIPT}" __XXX__ "$@"; exit $?; }
while [ $# -gt 0 ]; do
@toonetown
toonetown / link-sdks
Last active July 8, 2016 03:50 — forked from rnapier/fix-xcode
Links Xcode SDKs from the /SDKs directory (which you maintain yourself)
@toonetown
toonetown / disableAnimations.sh
Created July 11, 2016 22:52
Disables animations (helpful for accessing machines over a network)
###########
# Stops animations for the current user (or all new users if run as root). Note, if you want to use this in
# conjunction with the defaultSettings.sh gist, run that one first.
#
#!/bin/bash
# Change to our home preference directory, unless we are running as root
if [ "$(id -u)" != "0" ]; then
cd "${HOME}/Library/Preferences" || exit $?
else
@toonetown
toonetown / keychain-stoken
Last active January 20, 2017 22:21
Helper script for managing stoken with macOS keychain storage
#!/bin/bash
case "${1}" in
add)
set -e
shift; SERVICE="${1}"
[ -n "${SERVICE}" ] || { echo "Usage $0 add <service>" >&2; exit 1; }
echo "Adding keychain stoken service '${SERVICE}' token password data"
/usr/bin/security add-generic-password -s "${SERVICE}" -a "${SERVICE}.token" -w || exit $?
echo "Adding keychain stoken service ${SERVICE} token PIN data..."

Keybase proof

I hereby claim:

  • I am toonetown on github.
  • I am toonetown (https://keybase.io/toonetown) on keybase.
  • I have a public key ASCl7NIsx3WSlx1TVGSXxwSzS8_xBkoqbHtlay-DSlEhRQo

To claim this, I am signing this object:

@toonetown
toonetown / shimo-auto-alias
Last active August 29, 2017 14:03
Leverages alias-local to automatically add/remove SSH hosts.
#!/bin/bash
source /etc/profile
# The location of the ssh config file and alias-local
: ${SSHCONF:="/var/run/Shimo/configs/${CS_UNIQUE_IDENTIFIER}.sshconf"}
: ${ALIAS_IFACE:="lo0"}
: ${ALIAS_LOCAL:="$(which alias-local 2>/dev/null)"}
# Read the mappings in the config file - only if we have an alias-local command installed in our path
[ -f "${SSHCONF}" -a -x "${ALIAS_LOCAL}" ] && {
@toonetown
toonetown / alias-local
Last active August 29, 2017 14:04
Aliases localhost to an address
#!/bin/bash
if [ "$(id -u)" != "0" ]; then sudo "${0}" "$@"; exit $?; fi
if [ "${1}" == "-d" ]; then
[ -n "${2}" ] || { echo "Usage $0 [-d] <addr> [iface]"; exit 1; }
ifconfig ${3:-lo0} -alias ${2}
else
[ -n "${1}" ] || { echo "Usage $0 [-d] <addr> [iface]"; exit 1; }
ifconfig ${2:-lo0} alias ${1} 255.255.255.255