Skip to content

Instantly share code, notes, and snippets.

func ExampleTx_Rollback() {
tx, err := db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
if err != nil {
log.Fatal(err)
}
id := 53
_, err = tx.ExecContext(ctx, "UPDATE drivers SET status = ? WHERE id = ?;", "assigned", id)
if err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
log.Fatalf("update drivers: unable to rollback: %v", rollbackErr)
#!/bin/bash
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>liveness-log.out 2>&1
echo "--START LIVENESS--"
while :; do
echo "`date`"
#!/bin/bash
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>readiness-log.out 2>&1
echo "--START READINESS--"
while :; do
echo "`date`"

Keybase proof

I hereby claim:

  • I am duthied on github.
  • I am devlonduthie (https://keybase.io/devlonduthie) on keybase.
  • I have a public key ASBMGgMJTpqNf4QyCSQMZEKOhK4GJ6xPsB6SZFFDArZ-Wwo

To claim this, I am signing this object:

@duthied
duthied / cb-load.sh
Last active March 6, 2018 14:42
Read a URL from a file and reload Chromium-browser with that url
#!/bin/bash
read -r url<./url.txt
# stop chromium
sudo killall chromium-browser
# manually set the display to one that is currently being used
# start chromium in kiosk mode with the URL we want to load
# use nohup so it stays up after we disconnect
@duthied
duthied / gist:0ceba52975cfc7ea5aed
Last active August 29, 2015 14:02
Example preflight for CORs
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
}
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
@duthied
duthied / git-standup.sh
Created August 12, 2013 23:23
git-standup.sh
#!/bin/bash
# from https://coderwall.com/p/gog45a
function lastworkingday()
{
if [[ "1" == "$(date +%u)" ]]
then
echo "last friday"
else
echo "yesterday"