Skip to content

Instantly share code, notes, and snippets.

# run with: god -c /path/to/worker.god
#
# Keep workers up & running
God.load File.join(File.dirname(__FILE__), 'email.god')
4.times do |worker_id|
God.watch do |w|
w.name = "asset-worker-#{worker_id}"
w.interval = 10.seconds
@cypher
cypher / god.sh
Created September 23, 2009 14:52
#!/bin/bash
### BEGIN INIT INFO
# Provides: god control
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts god at boot time
# Description: Starts god and all the services it is supposed to watch
@cypher
cypher / gist:189291
Created September 18, 2009 21:07 — forked from mattetti/gist:189283
def summer_monthly_usage
@summer_monthly_usage ||= rates.summer_months_nbr.
map{ |month| monthly_usage[month - 1] }.
inject(0, &:+)
end
Yup. Ich weiss das Fibonacci als Benchmark selbst bestenfalls nur bedingt geeignet ist, aber dieses Programm:
def fib(n)
if (n < 2)
n
else
fib(n-1) + fib(n-2)
end
end
» git clone git://github.com/petdance/ack.git Ack
Initialized empty Git repository in /Users/cypher/Code/Ack/.git/
fatal: protocol error: expected sha/ref, got '
*********'
Permission denied. Repository is not public.
*********'
# Define a handler for multiple http verbs at once
def any(url, verbs = %w(get post put delete), &block)
verbs.each do |verb|
send(verb, url, &block)
end
end
any '/url' do
# ...
"return value"
@cypher
cypher / gist:150248
Created July 20, 2009 10:45
A git pre-commit hook that makes sure any Ruby Syntax is OK
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
git config --global alias.track '! track() {
branch=$(git branch | sed -ne "s/^\*\ \(.*\)$/\1/p")
remote=$1
git config "branch.$branch.remote" $(dirname "$remote")
git config "branch.$branch.merge" "refs/heads/$(basename "$remote")"
}
track'
#!/bin/bash
git push ${1:-origin} $(git branch | sed -ne 's/^\*\ \(.*\)$/\1/p')
# Put this file somewhere in your PATH, call it 'git-up', make it +x,
# and then you can call "git up" to push to origin, or "git up foo"
# to push to 'foo'
--sort-files
--color
--context=1
--follow
--group
--all