Skip to content

Instantly share code, notes, and snippets.

@jgdavey
jgdavey / rvm_gem_migrate.sh
Created January 4, 2010 20:01
rvm gem migration
# Switch back to system just to make sure
rvm use system
# Print a list of all gems installed on the system
gem list | awk '{print $1}' > gems.txt
# Switch to the new version of ruby
rvm use ree
# Install each gem from the list, skipping documentation
def self.up
if connection.tables.include?('posts')
drop_table :posts
end
end
function! s:ToggleDoEndOrBrackets()
let char = getline('.')[col('.')-1]
if char =~ '[{}]'
if char=='}'
norm %
endif
norm h
" Bracket touching previous word
if getline('.')[col('.')-1] =~ '[^ ;]'
exe "norm! a "
@jgdavey
jgdavey / _hitch.sh
Created October 2, 2011 17:51
Hitch author completion
#compdef hitch
__hitch_authors() {
local expl
local -a _authors
if [ -f $HOME/.hitch_pairs ]; then
_authors=(${${(f)"$(cat $HOME/.hitch_pairs | awk '/:/ { print }')"}/:[ $'\t']##/:})
fi
_describe -t hitch-authors 'hitch authors' _authors "$@"
}
@jgdavey
jgdavey / gist:1685824
Created January 26, 2012 23:28
Harvest your git messages
#!/usr/bin/env ruby
# Adapted from https://gist.github.com/946311
#
# To use, put something like the following in your .bashrc.local:
#
# alias harvest='rvm use 1.9.2@harvester;harvester;cd ..;cd -'
author = `git config --global user.name`.chomp
@jgdavey
jgdavey / .gitconfig
Created March 30, 2012 22:16
Git alias to add untracked files
[alias]
add-untracked = !"git status --porcelain | awk '/\\?\\?/{ print $2 }' | xargs git add"
@jgdavey
jgdavey / hinder.sh
Created May 14, 2012 21:03
Simulate network latency and packet loss on Mac OS X (requires sudo)
#!/bin/bash
set -e
USAGE="Usage: $0 [ip_address | reset]"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
@jgdavey
jgdavey / atomically
Created December 20, 2012 17:08
Verify a series of commits are atomic
#!/usr/bin/env bash
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: You have a dirty working copy. This command would remove any files not already checked in"
exit 1
fi
log() {
if [ -z "$quiet" ]; then
echo
@jgdavey
jgdavey / trace_paths.clj
Created March 4, 2014 02:26
How to get paths for map of sets?
(use 'clojure.test)
(deftest tracing-paths
(testing "trace-paths"
(is (= (trace-paths {:a nil} :a)
[[:a]]))
(is (= (trace-paths {:a #{:b}
:b nil} :a)
@jgdavey
jgdavey / projections.json
Created April 24, 2014 18:40
Clojure .projections.json
{
"*" : {
"start" : "lein repl",
},
"src/*.clj": {
"command": "namespace",
"alternate": "test/{}_test.clj",
"template": "(ns {dot|hyphenate})\n\n"
},
"test/*_test.clj": {