Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
mc = class << self; self; end
mc.send :define_method, :__my_method, &block
# this
__my_method(arg, barg, carg)
# or that
send :__my_method, arg, barg, carg
---
twitter:
password: xxxx
login: sinatra
irc:
nick: nancie
nickserv: xxxx_nickserv_pwd_here
channel: sinatra
server: irc.freenode.net
cheat:
# Classical top-style apps and Sinatra::Default has a bunch of useful
# default settings not found in Sinatra::Base:
#
# - Exceptions are mapped to the error handler of your Sinatra app
# instead of propagating to Rack
#
# - The Rack::MethodOverride middleware is enabled, allowing the
# '_method=PUT' hack
#
# - Static files are served from the public directory
#! /usr/bin/env ruby
# this program will give you a 'named screen' (ns) command that will create
# named screens that will also name Terminal.app tabs, even on re-attach.
# save it in ~/bin/ns and use as in
#
# to create a named screen
#
# ns foobar
#
require 'rest_client'
class Unfuddle < Sinatra::Base
post '/unfuddle/:project' do
RestClient.post "/#{params[:project]}/builds"
end
end
00:10 @jsmith: LemensTS: I'm not a big Dell fan, but the 2950 makes is a rock-solid Asterisk box
00:10 @jsmith: s/makes is/makes/
00:10 jbot: jsmith meant: LemensTS: I'm not a big Dell fan, but the 2950 makes a rock-solid Asterisk box
# that's awesome!
require 'sinatra'
enable :sessions
post '/counter' do
(session[:counter] ||= 0) += 1
end
get '/' do
"You've hit me #{session[:counter]} times!"
require "sinatra"
post "/foo" do
redirect "/bar"
end
get "/bar" do
"Hello, World!"
end
require 'sinatra'
class Blog < Sinatra::Default
get '/' do
..
end
end
Test::Unit::TestCase.send :include, Sinatra::Test
class Waste < Sinatra::Base
get '/' do
puts session[:test]
end
end
describe 'Waste' do
before do