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
// 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
@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
def substr(str1, str2)
len = str1.length
last = (0...len).detect{|i| str1[i] != str2[i]}
last ||= len
str1[0...last]
end
def gcp(strings)
sorted = strings.sort
substr(sorted.first, sorted.last)
@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
#!/usr/bin/env zsh
if [[ -s "${TM_PROJECT_DIRECTORY}/.rvmrc" ]]
then
source "${TM_PROJECT_DIRECTORY}/.rvmrc"
fi
`which ruby` $*
require 'rubygems'
require 'system_timer'
def try_for_a_bit
result = nil
e_last = nil
begin
SystemTimer.timeout_after(2) do
until result
begin
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000