Skip to content

Instantly share code, notes, and snippets.

@bds
bds / Plot verbose Siege output
Created August 19, 2010 19:17
Plot verbose Siege output
# Select response time, url id, and timestamp from verbose siege output
$ awk -F, '{ print $4","$7","$8 }' my_siege.log > ~/response.csv
# Load csv file into an R data.frame
> foo <- read.csv("~/response.csv", row.names=NULL, colClasses=c("numeric", "factor", "POSIXct"), col.names=c("response.time", "url.id", "timestamp"))
# Plot
> qplot(timestamp, response.time, data=foo, geom=c("point", "smooth"))
@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 / 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 / SparkLines in R
Created December 30, 2010 14:27
Sample sparkline plot using ggplot
library(ggplot2)
sparkLinePlot <- function(df, plot.file) {
highest <- subset(df, outcomes == max(outcomes))
lowest <- subset(df, outcomes == min(outcomes))
p <- ggplot(df, aes(x=date, y=outcomes)) +
geom_line() +
opts(panel.border = theme_rect(linetype = 0),
@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
@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