Share
Embed
Transcript
55 slides
-
Sinatra in 8 Lines How to do crazy stuff with
ruby %w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{extend Rack;a,D,S,$p,q,Applica)on=Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" Saturday, August 18, 12 -
“second to K&R, the most lagom technical book I’ve read.”
Peter Cooper (Ruby Inside) discount code: AUTHD 50% off ebook ($6.50) 40% OFF PRINT Saturday, August 18, 12 -
Prepare for strange code slides also, no memes this 4me
Saturday, August 18, 12 -
Until programmers stop acting like obfuscation is morally hazardous, they’re
not artists, just kids who don’t want their food to touch. why the lucky s(ff Saturday, August 18, 12 -
eval \ '51966'+['.',1935634292, ' ', '1', '6'].pack('ala3') # => “cafe”
Saturday, August 18, 12 -
eval \ '51966'+['.', 'to_s', ' ', '1', '6'].pack('A4') # =>
“cafe” Saturday, August 18, 12 -
github.com / rkh / almost-sinatra more popular than a pair
of socks Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{extend Rack;a,D,S,$p,q,Applica)on=Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a
%w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" the code Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{extend Rack;a,D,S,$p,q,Applica)on=Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a
%w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" the code Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{ extend Rack;
a,D,S,$p,q,Applica)on =Builder.new, Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a %w[ get post put delete].map{|m|D.(m){|u,&b| a.map(u){run-‐>(e){ [200,{"Content-‐Type"=>"text/html"}, [a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}}; a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{extend Rack;a, D,S,$p,q,Applica)on
=Builder.new, Object.method(:define_method) ,/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a %w [get post put delete].map{|m| D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v| D.(k){|n,*o| $t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[ set enable disable configure helpers use register]. map{|m| D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[ params session].map{|m| D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b}; before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new{extend Rack;a,D, S,$p,q,Applica)on
=Builder.new,Object.method(:define_method), /@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o| $t||=(h={};File.read(caller[0][/^[^:]+/]) .scan(S){|a,b|h[a]=b};h); v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}. render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" Saturday, August 18, 12 -
%w.rack )lt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l} $n=Sinatra=Module.new {extend Rack;
a,D,S, $p,q,Applica)on =Builder.new, Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m, 4567,a %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run-‐>(e){[200,{"Content-‐Type"=>"text/html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0]. new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}}; END{Handler.get("webrick"). run(a,Port:$p){|s|$r=s}} %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}} puts "== almost #$n/No Version has taken the stage on #$p for development with backup from Webrick" Saturday, August 18, 12 -
“If your app does not run with Almost Sinatra, please
open a Sinatra issue.” Konstan(n Haase Saturday, August 18, 12 -
“Versions are to Software what Subversion is to Git.” Konstan(n
Haase Saturday, August 18, 12 -
“don't include tests. tests just bloat the code base. just
commit, the users will complain if you break anything.” Konstan(n Haase Saturday, August 18, 12 -
BEARS or Horses this slide is for James Coglan Saturday,
August 18, 12