Skip to content

Instantly share code, notes, and snippets.

View jsgarvin's full-sized avatar
💭
Mashing keys, but with feeling this time!

Jonathan Garvin jsgarvin

💭
Mashing keys, but with feeling this time!
View GitHub Profile
@jsgarvin
jsgarvin / gist:a8676c659926e7c2479aa8661135990e
Created November 23, 2016 01:15
Get saturation value to pass to `dcraw -S` for multiple raw files.
$ for f in *CANON/*.CR2; do dcraw -D -4 -j -c "$f" | pamsumm -max; done | cut -f 7 -d ' ' | sort -n | tail -1
@jsgarvin
jsgarvin / .bashrc
Last active December 23, 2016 18:24
List recently checked out git branches and quickly jump to one
# Add to your .bashrc or sourced alias file
#
# Without any arguments, lists the last 9 branches you've been
# on, prompts for a number, and then switches you back to the
# corresponding branch.
#
# When passed a number as an argument, instantly switches you
# to the corresponding branch. This is particularly useful for
# toggeling back to your previous branch with `grb 1`.
function grb() {
@jsgarvin
jsgarvin / autosnap.rb
Last active August 29, 2015 14:08
Automatic rotating snapshots of AWS EC2 Linux instances
#!/usr/bin/ruby
#
# Take automatic rotating snapshots of your AWS EC2 linux instance(s).
#
# Slap this file into /etc/cron.hourly/ on your EC2 instance,
# edit the constants at the top of the class to your liking,
# and give it the execute bit.
#
# Known to work on Ubuntu 14.04 64bit. Presumed to work on most other flavors.
#
@jsgarvin
jsgarvin / gist:9573255
Last active August 29, 2015 13:57
Name your MiniTest::Mock for more descriptive errors.
MiniTest::Mock errors are especially vague, particularly when you need more than one mock in your test.
To improve things slightly, add this to the bottom of your test_helper...
module MiniTest
class NamedMock < Mock
attr_reader :name
def initialize(name)
@name = name
super()
@jsgarvin
jsgarvin / autossh-tunnel.conf
Created November 28, 2013 05:50
Automatically establish ssh tunnel to remote postgresql db server on boot, and auto re-establish if connection is lost (eg reboot of remote machine or network failure). Requires autossh.
# Modified version of technique borrowed from
# http://theantway.com/2012/08/how-to-create-ssh-tunnel-at-boot-time-under-ubuntu/
# Place in /etc/init/
# autossh
description "autossh daemon"
start on net-device-up IFACE=eth1
stop on runlevel [01S6]