Skip to content

Instantly share code, notes, and snippets.

@dave-burke
dave-burke / myconfig.ahk
Created October 8, 2013 16:39
My Autohotkey config
;Hotkeys
SendMode Input
^!t::Run C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -t "zsh" -e C:\cygwin\bin\zsh.exe -l -i
^!m::Send {Volume_Mute}
;Swap Capslock and Backspace
Capslock::Backspace
Backspace::Capslock
;Swap Function key and control key (DOESN'T WORK)
@dave-burke
dave-burke / gpg-info.md
Last active May 17, 2016 08:18
GPG Cheat Sheet

Creating a new key

gpg --gen-key # Generate a keypair
gpg --output my_key_revoke.asc --gen-revoke mykey # Generate a revocation certificate

Exchanging keys

Locally

gpg --output my_key.gpg --export mykey
@dave-burke
dave-burke / init-bootplate.sh
Created June 3, 2014 20:59
Create a new repository based on enyojs/bootplate, but with an empty history.
#!/bin/bash
PROJECT_NAME=${1}
ENYO_VERSION=${2}
ENYO_GIT=https://github.com/enyojs
if [[ -z ${PROJECT_NAME} ]]; then
echo "First arg should be project name"
exit 1
fi
@dave-burke
dave-burke / bash-strings.sh
Last active June 24, 2023 03:54
Demo of string manipulation in Bash
#!/bin/bash
# based on http://www.tldp.org/LDP/abs/html/string-manipulation.html
test=abcABC123ABCabc
echo "\${test} = ${test}"
echo && echo "Substrings:\${test:pos:length}"
echo "\${test:3} = ${test:3}" # ABC123ABCabc
@dave-burke
dave-burke / bash-filenames.sh
Created July 24, 2014 19:16
Demo of filename parsing in Bash
#!/bin/bash
echo "\${0} = ${0}"
echo "dirname \${0} = `dirname ${0}`"
echo "basename \${0} = `basename ${0}`"
echo "readlink -m \${0} = `readlink -m ${0}`" #In BSD (maybe not with -m option, though)
echo "realpath -m \${0} = `realpath -m ${0}`" #Easy to remember
echo "\$(cd \$(dirname \${0}); pwd)/\$(basename ${0}) = $(cd $(dirname ${0}); pwd)/$(basename ${0})" #Should be truly cross-platform
echo "\${0/%.sh/.foo} = ${0/%.sh/.foo}"
@dave-burke
dave-burke / vim-splits.md
Last active February 18, 2023 03:57
A reference for splitting windows in VIM
frame   horizontal up     -->  :topleft     split
frame   horizontal down   -->  :botright    split
frame   vertical   left   -->  :topleft     vsplit
frame   vertical   right  -->  :botright    vsplit
window  horizontal up     -->  :leftabove   split
window  horizontal down   -->  :rightbelow  split
window  vertical   left   -->  :leftabove   vsplit
window  vertical   right  -->  :rightbelow  vsplit

Keybase proof

I hereby claim:

  • I am dave-burke on github.
  • I am thoughtcriminal (https://keybase.io/thoughtcriminal) on keybase.
  • I have a public key whose fingerprint is B07B D02E 17B9 892B 9C06 96A5 94F8 A7C4 7EBC 60EE

To claim this, I am signing this object:

@dave-burke
dave-burke / bash-signals.sh
Created June 3, 2016 14:48
Bash script demonstrating how to handle signals and clean up after yourself when the script is ended unexpectedly.
#!/bin/bash
temp_dir="/tmp"
if [ -d "${TEMP}" ]; then
temp_dir="${TEMP}"
fi
this_file="$(basename ${0})"
temp_file="${temp_dir}/${this_file%.*}.$$.$RANDOM"
function cleanup {
@dave-burke
dave-burke / pre-commit
Created November 17, 2016 13:23
Git pre-commit hook for running gradle tests
#!/bin/bash
# Exit with non-zero (i.e. reject the commit) if anything fails, particularly
# the gradle tasks.
set -e
# change to the project root directory
cd $(git rev-parse --show-toplevel)
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "dev" ]]; then
@dave-burke
dave-burke / Babble.groovy
Last active January 5, 2018 18:55
Generate technobabble (and optionally use them as demo git commit messages)
#!/usr/bin/env groovy
void usage(){
println """
usage: ${this.class.name}.groovy [-p, -g] [n]
Generates technobabble.
-p Print n paragraphs instead of n phrases. An optional third
argument may be used to specify the number of sentences per