Skip to content

Instantly share code, notes, and snippets.

@whylom
whylom / gist:2127639
Created March 19, 2012 22:19
Snippet to get a stack trace string from an Exception
"#{error.message}\n#{error.backtrace.join("\n")}"
@whylom
whylom / tunnel.sh
Created March 8, 2012 14:49
Open an SSH tunnel to a remote MySQL server
# Open an SSH tunnel to port 3306 (default MySQL port) on a remote machine.
# Specify the local port with an optional 2nd argument.
# The default is 3307, in case you have MySQL running locally on 3306.
#
# $ tunnel user@host
# -> opens tunnel to host on port 3306, using local port 3307
#
# $ tunnel user@host 3333
# -> opens tunnel to host on port 3306, using local port 3333
@whylom
whylom / gist:1448530
Created December 8, 2011 20:53
Ruby method that shells out to git describe and formats results
def get_tag_info(commit)
info = `git describe --tags #{commit}`.chomp
if info[/(.*)-(\d+)-g([a-z0-9]{7})/]
matches = Regexp.last_match
last_tag = matches[1]
commits_since_tag = matches[2]
noun = (commits_since_tag.to_i == 1) ? 'commit' : 'commits'
"#{last_tag} + #{commits_since_tag} #{noun}"
else