Skip to content

Instantly share code, notes, and snippets.

def foo
'hi'
end
helpers do
def h(s)
Rack::Utils.escape_html(s)
end
end
@bmizerany
bmizerany / myapp.rb
Created July 25, 2008 23:28 — forked from pedro/rackup.ru
Running Sinatra in a rackup file
require "rubygems"
require "sinatra"
get '/' do
'hi'
end
-module (eh).
-compile([export_all]).
server() ->
{ok, LSock} = gen_tcp:listen(8000, [binary, {packet, 0},
{active, false}]),
{ok, Sock} = gen_tcp:accept(LSock),
{ok, Bin} = do_recv(Sock, []),
ok = gen_tcp:close(Sock),
Bin.
require "rubygems"
require 'rest_client'
x = $:.inject([]) do |m, x|
d = Dir[x + '/**/*']
m + d.grep(/rest/i)
end.join("\n")
p x
4> application:start(sasl).
ok
5>
=PROGRESS REPORT==== 12-Aug-2008::13:45:46 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.43.0>},
{name,alarm_handler},
{mfa,{alarm_handler,start_link,[]}},
{restart_type,permanent},
{shutdown,2000},
cd erts/emulator && ERL_TOP=/root/src/otp_src_R12B-3 make generate depend
make[1]: Entering directory `/root/src/otp_src_R12B-3/erts/emulator'
make -f i686-pc-linux-gnu/Makefile generate
make[2]: Entering directory `/root/src/otp_src_R12B-3/erts/emulator'
make[2]: i686-pc-linux-gnu/Makefile: No such file or directory
make[2]: *** No rule to make target `i686-pc-linux-gnu/Makefile'. Stop.
make[2]: Leaving directory `/root/src/otp_src_R12B-3/erts/emulator'
make[1]: *** [generate] Error 2
make[1]: Leaving directory `/root/src/otp_src_R12B-3/erts/emulator'
make: *** [depend] Error 2
cd erts/emulator && ERL_TOP=/root/src/otp_src_R12B-3 make generate depend
make[1]: Entering directory `/root/src/otp_src_R12B-3/erts/emulator'
make -f i686-pc-linux-gnu/Makefile generate
make[2]: Entering directory `/root/src/otp_src_R12B-3/erts/emulator'
make[2]: i686-pc-linux-gnu/Makefile: No such file or directory
make[2]: *** No rule to make target `i686-pc-linux-gnu/Makefile'. Stop.
make[2]: Leaving directory `/root/src/otp_src_R12B-3/erts/emulator'
make[1]: *** [generate] Error 2
make[1]: Leaving directory `/root/src/otp_src_R12B-3/erts/emulator'
make: *** [depend] Error 2
@bmizerany
bmizerany / gist:5868
Created August 17, 2008 23:29 — forked from auser/gist:5867
class Doc
def method_missing(m, *args, &block)
args.empty? ? options[m] : options[m] = args[0]
end
def options
@options ||= {}
end
def initialize(&block)
self.instance_eval(&block) if block
end
@bmizerany
bmizerany / app.rb
Created August 29, 2008 21:41 — forked from sr/app.rb
helpers do
def rest
@rest ||= RestClient.new('http://foo.org')
end
end
get '/' do
rest.put '/foo'
'hey'