Skip to content

Instantly share code, notes, and snippets.

@bds
bds / gist:ee7d42e82a86d601489d
Created October 23, 2014 05:47
Disable Pry
DISABLE_PRY_RAILS=1 rails console
@bds
bds / .vimrc
Created August 6, 2015 22:08
Minimal .vimrc
set nocompatible " We are using Vim
syntax on
set colorcolumn=80
set ruler
hi StatusLine ctermfg=0 ctermbg=3 cterm=bold " Window highlighting
hi StatusLineNC ctermfg=white ctermbg=4 cterm=none
hi Folded ctermfg=244 ctermbg=0 cterm=none " Code folding highlight
@bds
bds / .vimrc
Created August 20, 2010 19:58
Basic .vimrc file
set nocompatible " We are using Vim
syntax on
set colorcolumn=80
set ruler
hi StatusLine ctermfg=0 ctermbg=3 cterm=bold " Window highlighting
hi StatusLineNC ctermfg=0 ctermbg=238 cterm=none
hi Folded ctermfg=244 ctermbg=0 cterm=none " Code folding highlight
@bds
bds / gist:9670328
Last active September 12, 2015 17:42
Test Rails endpoints from console with Rack::Test
require 'rack/test'
browser = Rack::Test::Session.new(Rack::MockSession.new(Fooproject::Application))
browser.get("/posts.json")
browser.post("/posts.json", {:id => 1})
@bds
bds / rstats_domain.R
Created September 4, 2010 02:13
Return domain string for #rstats dataframe of email addresses
# For an R dataframe that has a column of email
# addresses, e.g. joe@example.com, return just
# the domain name
sapply(strsplit(my.df$email, "@"), "[", 2)
@bds
bds / gist:613122
Created October 6, 2010 10:10 — forked from retr0h/gist:98308
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'}
before do
request_uri = case request.env['REQUEST_URI']
when /\.css$/ : :css
when /\.js$/ : :js
else :html
end
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8'
end
@bds
bds / gist:704559
Created November 18, 2010 02:54
Regex creator
Regexp.new(%w[ www www3 ].collect { |p| Regexp.escape(p) }.join('|'))
@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
@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 / 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