Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / httperf_tests_one
Created July 6, 2012 19:40
httperf tests of ditty using Diskcached
# code sample for httperf test
# - no cache
# get "/archive/?*" do
# items = archive_items
# haml :archive, :layout => choose_layout, :locals => { :state => :archive }
# end
httperf --client=0/1 --server=localhost --port=9001 --uri=/archive --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
@jmervine
jmervine / bm_test.rb
Created July 22, 2012 01:35
Benchmark A/B Test Suite
#!/usr/bin/env ruby
require 'benchmark'
# require libs here
iterations = ARGV[0]||100000 # pass in iterations or
@jmervine
jmervine / gist:3716306
Created September 13, 2012 18:09
Radiant Monkey Patch -- db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb
--- a/db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb
+++ b/db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb
@@ -1,9 +1,9 @@
class ChangePagesAllowedChildrenCacheToText < ActiveRecord::Migration
def self.up
- change_column :pages, :allowed_children_cache, :text
+ remove_column :pages, :allowed_children_cache
+ add_column :pages, :allowed_children_cache, :text
end
:Gist -- posts a gist
:Gist -l -- lists my gists
" for use before a colorscheme definition
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" for use when not using a colorscheme
" highlight ExtraWhitespace ctermbg=red guibg=red
" show unwanted whitespace
match ExtraWhitespace /\s\+\%#\@<!$/
" strip unwanted trailing whitespace on save
@jmervine
jmervine / install.sh
Created October 19, 2012 08:34
example dot-files install script
#!/usr/bin/env bash
files=( $( ls -a -d1 .* | grep -v .git | xargs echo ) )
for file in "${files[@]}"
do
test -L ~/$file && rm -v ~/$file
test -f ~/$file && mv -v ~/$file ~/$file.bak
test -f $file && \
ln -v -s $(pwd)/$file ~/$file
done
@jmervine
jmervine / shell.vim
Created October 19, 2012 18:00
vim shell command
" :Shell <cmd>
" put shell command in new buffer.
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
@jmervine
jmervine / bash-version-checking.sh
Created October 19, 2012 18:46
bash version checking
#!/usr/bin/env bash
if test "$( zsh --version | awk '{print $2}' | awk -F'.' ' $1 >= 4 && $2 >= 3 && $3 >= 17 ' )"
then
# do someting that only higher zsh versions support
else
# do something else for low versions
fi
@jmervine
jmervine / gist:3921235
Created October 19, 2012 23:13
script/server_unicorn, because webrick is slow
#!/usr/bin/env bash
################################################################################
# Author: Joshua Mervine <joshua@mervine.net>
# Date: 2012-10-19
#
################################################################################
# set up optional variables
################################################################################
test "$UNICORN_ROOT" || UNICORN_ROOT="$(pwd)"
@jmervine
jmervine / thin.sh
Last active October 11, 2015 22:18
thin wrapper
# Directory pathing context should be that of the thin
# init script sourcing this file, not this file itself.
#
# allow for overides as such
#
test "$RACK_ENV" || RACK_ENV="production"
test "$THIN_PORT" || THIN_PORT="4321"
test "$THIN_PID" || THIN_PID="./log/listener.pid"
test "$THIN_LOG" || THIN_LOG="./log/listener.log"
test "$THIN_ADDY" || THIN_ADDY="0.0.0.0"