This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
twitter: | |
password: xxxx | |
login: sinatra | |
irc: | |
nick: nancie | |
nickserv: xxxx_nickserv_pwd_here | |
channel: sinatra | |
server: irc.freenode.net | |
cheat: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest_client' | |
class Unfuddle < Sinatra::Base | |
post '/unfuddle/:project' do | |
RestClient.post "/#{params[:project]}/builds" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
enable :sessions | |
post '/counter' do | |
(session[:counter] ||= 0) += 1 | |
end | |
get '/' do | |
"You've hit me #{session[:counter]} times!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
post "/foo" do | |
redirect "/bar" | |
end | |
get "/bar" do | |
"Hello, World!" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
class Blog < Sinatra::Default | |
get '/' do | |
.. | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test::Unit::TestCase.send :include, Sinatra::Test | |
class Waste < Sinatra::Base | |
get '/' do | |
puts session[:test] | |
end | |
end | |
describe 'Waste' do | |
before do |