Skip to content

Instantly share code, notes, and snippets.

@bds
bds / .vimrc
Last active September 25, 2015 08:27
Latest Vim settings
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set background=dark
set tabstop=2
set shiftwidth=2
set expandtab
set history=50 " keep 50 lines of command line history
@bds
bds / gist:906467
Created April 6, 2011 20:33
View Git commit hash on Heroku
heroku console "ENV['COMMIT_HASH']"
@bds
bds / gist:942195
Created April 26, 2011 12:45
Mean for array of Ruby values
sample.inject{ |sum, el| sum + el }.to_f / sample.size
@bds
bds / gist:1279925
Created October 12, 2011 01:03
List available gem versions to install
gem list somegem --remote --all
@bds
bds / gist:1345955
Created November 7, 2011 19:50
Example Debug for Sunpsot Solr hit objects
search = Sunspot.search(JobPosting) do
keywords 'sales'
end
search.hits.each do |h|
ap [ h.score,
h.result.attributes.select {|k,v| ["title", "description"].include? k }]
end;nil
@bds
bds / snowy_terminal
Last active September 28, 2015 22:38
Make is snow in your terminal window
clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS));sleep 0.1;done|awk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH*\033[0;0H",a[x],x;}}'
@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
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: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
@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