Skip to content

Instantly share code, notes, and snippets.

View agibralter's full-sized avatar
:shipit:

Aaron Gibralter agibralter

:shipit:
View GitHub Profile
require 'ruby-debug'
require 'socket'
require 'forwardable'
class SporkDebugger
DEFAULT_PORT = 10_123
HOST = '127.0.0.1'
extend Forwardable
def_delegators :state, *[:prepare_debugger, :initialize]
@toastdriven
toastdriven / .tmux.conf
Created October 8, 2009 20:12
.tmux.conf
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set bell-action none
set-option -g status-left ""
set-option -g status-right "#S"
set -g status-bg black
set -g status-fg white
set utf8-default on
@toastdriven
toastdriven / haystack.sh
Created October 9, 2009 05:30
haystack.sh
#!/bin/sh
# First, open up GitX
cd ~/Code/Python/django-haystack; gitx
tmux start-server
tmux new-session -d -s Haystack -n git
tmux new-window -tHaystack:1 -n test
tmux new-window -tHaystack:2 -n solr
tmux new-window -tHaystack:3 -n docs
tmux new-window -tHaystack:4 -n runserver
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
// Finds the longest common starting substring in an array of strings
function common_substring(data) {
var i, ch, memo, idx = 0
do {
memo = null
for (i=0; i < data.length; i++) {
ch = data[i].charAt(idx)
if (!ch) break
if (!memo) memo = ch
else if (ch != memo) break
@paulirish
paulirish / README.md
Created January 4, 2010 02:38
imagesLoaded() jquery plugin
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
@mattetti
mattetti / connection_fix.rb
Created May 22, 2010 00:52 — forked from defunkt/connection_fix.rb
limit the amount of retries to 5
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@defunkt
defunkt / ii.rb
Created May 24, 2010 23:33
{{.}} in mustache.rb
require 'mustache'
Mustache::Parser::ALLOWED_CONTENT = /(\w|[?!\/.-])*/
class ImplicitIterator < Mustache
define_method "." do
self[:to_s]
end
def names
@agibralter
agibralter / gist:468653
Created July 8, 2010 21:19
Given an array of path strings, find the longest common prefix path.
# Given an array of path strings, find the longest common prefix path.
def find_base_path(paths)
return paths.first if paths.length <= 1
arr = paths.sort
f = arr.first.split('/')
l = arr.last.split('/')
i = 0
i += 1 while f[i] == l[i] && i <= f.length
f.slice(0, i).join('/')
end