Skip to content

Instantly share code, notes, and snippets.

@bds
bds / gist:2405926
Created April 17, 2012 13:18
Convert .iso to bootable USB on OSX
# Remove all partitions, erase, format with FAT with 'Disk Utility' BEFORE commands below
# Unmount flash drive, still shown in 'diskutil list`
diskutil unmountdisk /dev/disk2
# Write .iso to flash drive
sudo dd if=/path/to/your/distro.iso of=/dev/disk2 bs=1m
# Eject disk
diskutil eject /dev/disk2
@bds
bds / gist:2422119
Created April 19, 2012 16:25
Push to Github, Heroku and notify NewRelic of deployment
git push origin master && git push heroku master && newrelic deployments
@bds
bds / gist:2892707
Created June 8, 2012 00:46
Unix find, move and rename a downloaded file with a space in the filename
find ~/Downloads -name '*(2).yml' -exec cp {} ~/project-foo/config/newrelic.yml \;
@bds
bds / gist:2933211
Created June 14, 2012 21:54
Ruby copy string to OSX clipboard
IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts markdown.to_html }
@bds
bds / gist:3210386
Created July 30, 2012 21:22
Encrypt and decrypt files with openssl
# http://osxdaily.com/2012/01/30/encrypt-and-decrypt-files-with-openssl/
# Encrypt
openssl des3 -in file.txt -out encrypted.txt
# Decrypt
openssl des3 -d -in encrypted.txt -out normal.txt
@bds
bds / gist:3660246
Created September 6, 2012 20:45
Verify CSV has a uniform number of fields
awk -F ',' '{print NF}' foo.csv | uniq -c
@bds
bds / gist:3733733
Created September 16, 2012 18:49
Ignore EOL characters in a git diff
git diff HEAD --ignore-space-at-eol
@bds
bds / gist:4192180
Created December 3, 2012 02:11
Subset an R dataframe by a list of dates
subset(df, sprint.end.date %in% as.Date(c("2012-11-16", "2012-11-30")))
@bds
bds / gist:6556881
Created September 13, 2013 22:27
Get google.com every 60 seconds for 100 minutes. Helped me keep network connection "alive". Sure there is a better way to do this (curl and bash would be simpler, including only requesting HEAD)
while max <= 100 do; puts Net::HTTP.get('www.google.com', '/'); max +=1; sleep 60; end
@bds
bds / gist:6576210
Created September 16, 2013 02:43
Minitest Cheat Sheet
# Credit - http://mattsears.com/articles/2011/12/10/minitest-quick-reference
#
# must_be list.size.must_be :==, 0
# must_be_close_to subject.size.must_be_close_to 1,1
# must_be_empty list.must_be_empty
# must_be_instance_of list.must_be_instance_of Array
# must_be_kind_of list.must_be_kind_of Enumerable
# must_be_nil list.first.must_be_nil