Skip to content

Instantly share code, notes, and snippets.

@finchd
finchd / script-template.sh
Created December 22, 2020 03:52 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@finchd
finchd / myscript.sh
Created December 6, 2019 08:19 — forked from jesusaurus/myscript.sh
Redirect a bash script's output and error to syslog
#!/usr/bin/env bash
# The pattern `exec > $X 2>&1` does two things: the last bit redirects standard
# error to go to standard output, and the first bit sends standard output to the
# file $X. Here our $X is the process substitution `>( $process )` which takes
# the standard input of $process and presents it as a file handle. Putting
# these two together, we have both our standard out and our standard error
# going to the standard input of $process. Our $process here first runs tee,
# which sends its standard input to both standard out and to the file listed.
# We then pipe our standard out into the logger command, which sends it to syslog.
@finchd
finchd / boxstarter.ps1
Created December 6, 2019 07:52 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@finchd
finchd / buses.py
Created November 12, 2013 08:08 — forked from relsqui/buses.py
#!/usr/bin/python
from urllib2 import urlopen
from json import loads
from xml.dom.minidom import parseString
from datetime import datetime, timedelta
from math import floor
TRIMET_API_KEY = "" # redacted for privacy