Skip to content

Instantly share code, notes, and snippets.

# 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"
» 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.
*********'
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
@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
@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
# 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
#!/usr/bin/env ruby
#
# Released under MIT License
# Copyright (c) 2009 Markus Prinz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
require 'sinatra'
class App < Sinatra::Base
get '' do
request.script_name
end
end
map '/foo' do
run App
From 6a9579d52d531a29ea1b8bc9e9dbb61385f53197 Mon Sep 17 00:00:00 2001
From: Markus Prinz <markus.prinz@nuclearsquid.com>
Date: Wed, 28 Oct 2009 22:21:02 +0100
Subject: [PATCH] You have to run ./configure before running rake when compiling Rubinius for the first time
---
doc/getting_started.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/doc/getting_started.txt b/doc/getting_started.txt
require 'sinatra'
class SinatraApp < Sinatra::Base
get '/' do
SinatraApp.environment.inspect
end
end
run SinatraApp