Skip to content

Instantly share code, notes, and snippets.

View chrishunt's full-sized avatar
🏕️
Adventuring

Chris Hunt chrishunt

🏕️
Adventuring
View GitHub Profile
@chrishunt
chrishunt / shas.sh
Last active December 17, 2015 22:49
Show commits with a 1 char diff
# Find all SHAS with a single line diff
SHAS=`git log --stat --oneline |\
grep "| 2 +-" -B1 |\
egrep -v "^(\s|-)" |\
cut -d' ' -f1`
# Of those SHAS, find the ones with single character diff
git show --word-diff=plain -p --oneline `echo $SHAS` |\
egrep "(\[-|{\+).(\+}|-\])" -B10 |\
grep "$SHAS"
@chrishunt
chrishunt / gist:5537390
Last active December 17, 2015 02:39
Remove trailing whitespace for all files in a project using vim
:args `git grep -l .`
:argdo :%s/\s\+$//gc | w
@chrishunt
chrishunt / .gitconfig.sh
Last active December 17, 2015 02:28
Delete merged branches with `git bam`
[alias]
bam = "!source ~/.githelpers && delete_local_merged_branches"
bamr = "!source ~/.githelpers && delete_remote_merged_branches"
@chrishunt
chrishunt / house_hunting.rb
Last active December 16, 2015 16:19
Be notified when a new house matching your criteria is posted to Craigslist
# Be notified when a new house matching your criteria is posted to Craigslist
require 'snoop'
MAX_RENT = 1900
BEDROOMS = 2
CITY = 'portland'
CATS = true
DOGS = true
@chrishunt
chrishunt / README.md
Last active December 16, 2015 09:29
_why ?
$ curl -o pspc16 https://dl.dropboxusercontent.com/u/856934/pspcl6
$ chmod +x pspc16
$ gem install snoop terminal-notifier
$ ruby why.rb
@chrishunt
chrishunt / arabic.yml
Last active December 16, 2015 07:28
i18n in Ruby
arabic:
hello: "مرحبا العالم!"
@chrishunt
chrishunt / Gemfile
Last active December 16, 2015 00:28
Fake service for testing
source 'https://rubygems.org'
gem 'foreman'
gem 'sinatra'
@chrishunt
chrishunt / .vimrc
Created April 8, 2013 17:45
Run specs with ,t
" Run specs with ',t' via Gary Bernhardt
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !clear
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
if filereadable("script/test")
exec ":!script/test " . a:filename
@chrishunt
chrishunt / arity.rb
Last active December 14, 2015 13:58
def foo(x, y); end
def bar(x, y = 2); end
def baz(x = 1, y = 2); end
method(:foo).arity #=> 2
method(:bar).arity #=> -2
method(:baz).arity #=> -1
def buz(x, y: 2); end
def pat(x: 1, y: 2); end
def test_proc
Proc.new { return }.call
puts 'Never see this...'
end
def test_lambda
lambda { return }.call
puts 'Do see this...'