Skip to content

Instantly share code, notes, and snippets.

@dpwright
dpwright / git-merge-keep-theirs.sh
Created May 11, 2012 03:33
Git merge driver which always accepts their version of a file
# I want to keep THEIR version when there is a conflict
# Copy their version over ours and report success
cp -f $3 $2
exit 0
@dpwright
dpwright / git-merge-keep-mine.sh
Created May 11, 2012 03:29
Git merge driver which always accepts your own version of a file
# I want to keep MY version when there is a conflict
# Nothing to do: %A (the second parameter) already contains my version
# Just indicate the merge has been successfully "resolved" with the exit status
exit 0
@dpwright
dpwright / selectivelydelete-ex.sh
Created April 17, 2012 00:57
Selectively deleting any instance of LINE from files matching SEARCH using ex
grep -Rl "SEARCH" . | while read FILE; do (echo "g/LINE/d"; echo 'wq') | ex -s FILE; done
@dpwright
dpwright / selectivelydelete-sed.sh
Created April 17, 2012 00:46
Selectively deleting any instance of LINE from files matching SEARCH using sed
grep -Rl "SEARCH" . | while read FILE; do sed -i "" "/LINE/d" $FILE; done
grep -Rl "SEARCH" . | while read FILE; do sed "/LINE/d" $FILE > tmp; mv tmp $FILE ; done
@dpwright
dpwright / rubygmail.rb
Created April 16, 2012 00:57
Sending email with Ruby + Google Apps Mail
#!/usr/bin/env ruby
require 'rubygems'
require 'tlsmail'
msg=<<EOF
From: Test Sender <[email protected]>
To: Test Recipient <[email protected]>
Subject: test