Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
require 'sinatra'
enable :sessions
post '/counter' do
(session[:counter] ||= 0) += 1
end
get '/' do
"You've hit me #{session[:counter]} times!"
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 'rest_client'
class Unfuddle < Sinatra::Base
post '/unfuddle/:project' do
RestClient.post "/#{params[:project]}/builds"
end
end
#! /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
#
# 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
---
twitter:
password: xxxx
login: sinatra
irc:
nick: nancie
nickserv: xxxx_nickserv_pwd_here
channel: sinatra
server: irc.freenode.net
cheat:
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
@vangberg
vangberg / app.rb
Created May 30, 2009 15:00
minimal sinatra rackup
require 'sinatra'
get '/' do
"Hello world"
end
get '/:foo' do
if request.xhr?
...
else
...
end
end
<html>
<head>
<script type="text/javascript">
window.onload = function() { alert("window.onload") }
</script>
</head>
<body>
Testside.
<script type="text/javascript">
alert("end of <body>");