Skip to content

Instantly share code, notes, and snippets.

@dave-burke
dave-burke / workadventure-userdata.sh
Last active February 2, 2022 04:04
Userdata script to initialize an Ubuntu 20.04 instance with https://workadventu.re
set -e
DOMAIN=example.com
LETS_ENCRYPT_EMAIL=todo@example.com
WORKADVENTURE_START_ROOM='_\/global\/workadventure.github.io\/game-room\/map.json'
JITSI_TIMEZONE='UTC'
JITSI_CONFIG_DIR="\/etc\/jitsi"
function setEnv() {
sed -i "s/#\?${1}=.*/${1}=${2}/" ${3}
@dave-burke
dave-burke / $JavaScript-Style.md
Last active March 13, 2023 16:59
Simple comparison of the Airbnb and StandardJs style guides

Simple comparison of the Airbnb and StandardJs style guides

Based on the things I actually care about.

Rule Airbnb Standard
Semicolons Required Never
Trailing Comma Required Never
Re-assign function param Never Allowed
++ Never Allowed
@dave-burke
dave-burke / are-you-sure.sh
Created November 25, 2019 13:20
An example of how to make sure the user is *really* sure before you do something.
#!/bin/bash
read -p "Are you sure? " sure
while [[ "${sure}" != "yes" && "${sure}" != "no" ]]; do
read -p "Please type 'yes' or 'no' " sure
done
echo "${sure}"
#------------- min (0 - 59)
# +----------- hour (0 - 23)
# | +--------- day of month (1 - 31)
# | | +------- month (1 - 12)
# | | | +----- day of week (0 - 6) (Sunday=0)
# | | | |
# * * * * command to be executed
@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
@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 / 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 {

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 / 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
@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}"