Skip to content

Instantly share code, notes, and snippets.

@leesmith
leesmith / spec_helper.rb
Created February 6, 2014 21:37
Control garbage collection in rspec
RSpec.configure do |config|
# ...snip
config.before(:each) do
DatabaseCleaner.start
GC.disable
end
config.after(:each) do
DatabaseCleaner.clean
@leesmith
leesmith / event.js.coffee
Last active August 29, 2015 14:04
jQuery event delegation
$(document).ready ->
$(document)
.on('ajax:before', ".single-line-qualification", (e) ->
debugger
# do validation and return false to cancel ajax
if e.target[1].value.trim() == ''
e.target[1].value = ''
alert 'You must enter a name!'
return false
)
@leesmith
leesmith / mysql-csv-dump.sql
Created August 13, 2015 13:28
Dump mysql to CSV
select * from users into outfile 'users.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\n';
@leesmith
leesmith / pgsql-csv-dump.txt
Created November 1, 2011 18:43
Dump postgresql table into csv file
COPY (SELECT foo,bar FROM whatever) TO '/tmp/dump.csv' WITH CSV HEADER;
@leesmith
leesmith / gist:2307505
Last active October 2, 2015 19:48
OSX software
Alfred http://www.alfredapp.com/
Shiftit http://code.google.com/p/shiftit/
Spectacle http://spectacleapp.com/
Adium http://adium.im/
Dropbox https://www.dropbox.com/
VMware Fusion http://www.vmware.com/products/fusion/overview.html
Teleport http://abyssoft.com/software/teleport/
TextWrangler http://www.barebones.com/products/textwrangler/
Skype http://www.skype.com/
iTerm2 http://www.iterm2.com/
@leesmith
leesmith / psql.txt
Created April 17, 2012 02:54
Ubuntu postgresql notes
# install database server
apt-get install postgresql libpq-dev
# install postgresql gem
gem install pg
# create postgres (super)user
createuser --superuser lsmith -U postgres
# change postgres user password
@leesmith
leesmith / openssl.txt
Created May 3, 2012 15:52
Password generation with openssl
openssl rand -base64 6
openssl rand -hex 4
openssl rand -base64 8 |md5 |head -c8;echo
date |md5 | head -c8; echo
ping -c 1 yahoo.com |md5 | head -c8; echo
@leesmith
leesmith / geokitr.rb
Created May 3, 2012 18:47
Basic geokit geocoding
#!/usr/bin/env ruby
require 'rubygems'
require 'geokit'
require 'csv'
Geokit::Geocoders::google = 'your_key'
places = CSV.read('places.csv', headers: true)
@leesmith
leesmith / notes.txt
Created June 20, 2012 14:49
wkhtmltopdf EY install notes
cd /data/regions_brandworks/shared
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
tar xfj wkhtmltopdf-0.9.9-static-i386.tar.bz2
sudo mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
@leesmith
leesmith / brew.txt
Created July 2, 2012 18:21
Homebrew: install specific version of formula
cd /usr/local
brew versions postgresql
git checkout -b postgresql-8.4.4 [some hash]
brew install postgresql
git checkout master
git branch -d postgresql-8.4.4
http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula