Skip to content

Instantly share code, notes, and snippets.

View scm-prompt
# Copyright (C) 2015 Facebook, Inc
# Maintained by Ryan McElroy <rm@fb.com>
#
# Inspiration and derivation from git-completion.bash by Shawn O. Pearce.
#
# Distributed under the GNU General Public License, version 2.0.
#
# ========================================================================
#
# Quickly determines the and emits some useful information about the state
@toonetown
toonetown / tot
Last active Feb 29, 2020 — forked from zrzka/!IMPORTANT.md
A shell script for Tot
View tot
#!/usr/bin/env bash
# Fork of gruber's tot.sh https://gist.github.com/gruber/b18d8b53385fa612713754799ed4d0a2
# which is a fork of chockenberry's tot.sh https://gist.github.com/chockenberry/d33ef5b6e6da4a3e4aa9b07b093d3c23
# Exit immediately if a pipeline returns a non-zero status.
set -e
# If set, the return value of a pipeline is the value of the last (rightmost) command
# to exit with a non-zero status, or zero if all commands in the pipeline exit successfully.
set -o pipefail
@toonetown
toonetown / nuke-gsw
Last active Apr 16, 2020
Nukes the Google Software Update so that you can just use homebrew instead
View nuke-gsw
#!/bin/bash
defaults write com.google.Keystone.Agent checkInterval 0
mkdir -p ~/Library/Google
rm -rf ~/Library/Google/GoogleSoftwareUpdate
sudo touch ~/Library/Google/GoogleSoftwareUpdate
sudo chown root:wheel ~/Library/Google/GoogleSoftwareUpdate
sudo chmod go-w ~/Library/Google/GoogleSoftwareUpdate
@toonetown
toonetown / print-cpp-tokens
Created Feb 21, 2020
Prints out all the c++ tokens (keying off ::) in a file
View print-cpp-tokens
#!/bin/bash
[ -f "${1}" ] || { echo "Usage: ${0} <file>" >&2; return 1; }
cat "${1}" \
| sed -e 's|//.*$||g' \
| sed -e 's/::/xxDOUBLExCOLONxx/g' \
| perl -ne '{ print join("\n",split(/[[:^word:]]+/)),"\n"; }' \
| sed -e 's/xxDOUBLExCOLONxx/::/g' \
| grep '::' \
| grep -v '^::' \
| sort -u
@toonetown
toonetown / auto-exclude.sh
Created Feb 20, 2020
A script which automatically will exclude build directories from time machine
View auto-exclude.sh
#!/bin/bash
: ${BASEDIR="${HOME}/Documents/Programming"}
: ${MAXDEPTH=6}
find "${BASEDIR}" -maxdepth ${MAXDEPTH} -type f \( -name pom.xml -o -name build\.sh \) -print0 \
| while read -d $'\0' _f; do
find "$(dirname "${_f}")" -maxdepth 1 -type d \( -name target -o -name build \) -exec tmutil addexclusion {} \;
done
@toonetown
toonetown / ksymbolicate
Last active May 22, 2020
A script which will help decode macOS kernel panics
View ksymbolicate
#!/bin/bash
###########
# A script which will help to decode macOS kernel panics
###########
# Helper functions
function do_jq {
_J="$(which jq 2>/dev/null)" || {
echo "You must install jq (brew install jq) to use the script" >&2; return 1;
}; "${_J}" "$@"
@toonetown
toonetown / oc
Last active Jan 21, 2020
Openconnect helper script
View oc
#!/bin/bash
[ -f "${OC_CONFIG:="${HOME}/.oc-config"}" ] || { echo "Not configured - set up ${OC_CONFIG}" >&2; exit 1; }
if [ "$(id -u)" != "0" ]; then OC_CONFIG="${OC_CONFIG}" sudo "${0}" "$@"; exit $?; fi
OC_PID="/var/run/openconnect.pid"
OC_LOG="/var/log/openconnect.log"
case "${1}" in
connect)
@toonetown
toonetown / QuickSetup.sh
Last active Jan 17, 2020
A list of steps to perform to quickly set up a machine like I like it.
View QuickSetup.sh
# Default Settings (run from recovery partition before user creation)
cd "/Volumes/Macintosh HD"
curl -sSL -o data https://gist.githubusercontent.com/toonetown/c5664875177e8253a99814c6184db41b/raw
chroot .
/bin/bash data
exit
rm data
# First-run setup, create user, set auto-login, download folder options, Parallels Tools (if on VM)
@toonetown
toonetown / copy-diff
Last active Aug 23, 2019
Copies a file if it is different than the target
View copy-diff
#!/bin/bash
# Copies a file if and only if it is different
if [ "$(diff -q "${1}" "${2}" 2>&1 | wc -l)" -gt 0 ]; then cp "${1}" "${2}"; fi
View boot-shutdown.sh
#!/bin/bash
function shutdown()
{
# INSERT HERE THE COMMAND YOU WANT EXECUTE AT SHUTDOWN OR SERVICE UNLOAD
exit 0
}
function startup()
{