Skip to content

Instantly share code, notes, and snippets.

@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: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: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: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: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: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:2285686
Created April 2, 2012 17:53
Dump OSX Internet Keychain Contents
sudo security dump-keychain -d login.keychain | grep inet -A23
@bds
bds / gist:2207826
Created March 26, 2012 17:58
Convert files from .scss to .sass
sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass
HrtBus::Config.routes_uri = "ftp://216.54.15.3/Anrd/vid.csv"
HrtBus::Config.buses_uri = "ftp://216.54.15.3/Anrd/hrtrtf.txt"
HrtBus::Config.hydra ||= Typhoeus::Hydra.new
HrtBus::Bus.download {|buses| @buses = buses }
HrtBus::Route.download {|routes| @routes = routes }
HrtBus::Config.hydra.run
@routes.each do |route|
@bds
bds / gist:1805529
Created February 12, 2012 01:01
Rails + Postgres Time Series Model Counts
Model.order("DATE(created_at)").group("DATE(created_at)").count