Skip to content

Instantly share code, notes, and snippets.

@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: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 / gist:1279925
Created October 12, 2011 01:03
List available gem versions to install
gem list somegem --remote --all
@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:906467
Created April 6, 2011 20:33
View Git commit hash on Heroku
heroku console "ENV['COMMIT_HASH']"
@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 / heroku_db_pull_monitor.sh
Created March 28, 2011 14:02
A more verbose way to monitory `heroku db:pull'
sudo ngrep -d en1 -W byline port 80 and host heroku.com
@bds
bds / typhoeus_proxy.rb
Created March 26, 2011 01:31
Typhoeus using a proxy
require 'rubygems'
require 'typhoeus'
require 'ap'
begin
request = Typhoeus::Easy.new
request.url = "http://www.google.com"
request.max_redirects = 2
request.verbose = 1
request.method = :get
@bds
bds / rvm_1_9_2_upgrade.sh
Created March 1, 2011 16:45
Update to latest version of Ruby 1.9.2, include Readline and Rails gems
rvm get latest
rvm package install readline
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
rvm 1.9.2 --default
gem install rails
bundle install
@bds
bds / newrelic_deploy.sh
Created February 19, 2011 02:34
Notify New Relic of a code deploy, include last git commit hash and message
git log --oneline -1 | newrelic deployments -c