Skip to content

Instantly share code, notes, and snippets.

View jelder's full-sized avatar

Jacob Elder jelder

View GitHub Profile
@jelder
jelder / coffeerun.sh
Created November 27, 2012 17:16
coffeerun - Wait for changes to a CoffeeScript file, compile it, and run it under either Mongo or Mac OS X's native JavaScript runtime.
#!/bin/bash
# Wait for changes to a CoffeeScript file, compile it, and run it under either Mongo or Mac OS X's native JavaScript runtime.
set -o nounset
set -o errtrace
set -o errexit
set -o pipefail
usage() {
cat <<END
@jelder
jelder / configuration.rb
Created September 7, 2012 18:02
Alternative to Configatron compatible with the 12 Factor App philosophy.
# This is an attempt at constructing an application which complies with the
# ideas expressed at http://www.12factor.net/, specifically section 3, "Config"
# which states that configuration parameters which vary between environments
# should be stored in environment variables.
#
# `Configuration` is a thin wrapper around Ruby's ENV hash which also allows
# traditional custom config parameters to be set. Add an `attr_accessor` line
# and define the value in `config/environments/*.rb`.
#
# For example, `Configuration.api_token` called in the foobar environment will
@jelder
jelder / app.rb
Created September 6, 2012 21:40 — forked from vangberg/app.rb
minimal sinatra rackup
require 'sinatra'
set :public_folder, Proc.new { File.dirname(__FILE__) }
get '/' do
File.read("index.html")
end
@jelder
jelder / Gemfile
Created August 7, 2012 16:41
Ping a URL and report 95th percentile timings
gem 'smart_colored', :require => 'smart_colored/extend'
gem 'rest-client'
@jelder
jelder / template.sh
Created July 26, 2012 17:25
Template for robust shell scripting
#!/bin/bash
set -o nounset
set -o errtrace
set -o errexit
set -o pipefail
progname=$(basename $0)
default_name="Marley"
@jelder
jelder / chef.log
Created July 25, 2012 15:27
Chef logs: threat or menace?
[2012-07-25T15:22:50+00:00] INFO: Processing log[my message] action write (example::default line 5)
[2012-07-25T15:22:50+00:00] INFO: my message
@jelder
jelder / bench.rb
Created July 11, 2012 21:43
Quick and dirty Ruby benchmark method
#!/usr/bin/env ruby
def benchmark(count)
timing = []
count.times do
start = Time.now
yield
timing << Time.now - start
print "."
end
If you can read this, your Twitter still loves GitHub Gists.
@jelder
jelder / bash_parallel.sh
Created July 6, 2012 20:11
Example of managing lots of background jobs from Bash
#!/bin/bash
function my_slow_job() {
sleep 1
}
function parallel_demo() {
count=${1:-10}
echo "Starting $count parallel processes:"
for i in $(seq -w $count) ; do
@jelder
jelder / drivethru.knife
Created June 26, 2012 21:00
drivethru - continuous deployment for chef
#!/usr/bin/env ruby
# drivethru - continuous deployment for chef
# June 2012 Jacob Elder <[email protected]>
require 'listen'
require 'net/ssh'
require 'smart_colored/extend'
node = ARGV[2]
abort("usage: knife exec drivethru.knife NODE") unless node