Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Konstantin Travis CI @konstan(nhaase  aka  rkh Saturday, August 18, 12

Slide 3

Slide 3 text

Sinatra Rack,  Tilt,  Rubinius,  ... Saturday, August 18, 12

Slide 4

Slide 4 text

“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

Slide 5

Slide 5 text

Prepare for strange code slides also,  no  memes  this  4me Saturday, August 18, 12

Slide 6

Slide 6 text

Obfuscation Saturday, August 18, 12

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

!?! Saturday, August 18, 12

Slide 9

Slide 9 text

!?! # => false Saturday, August 18, 12

Slide 10

Slide 10 text

?:??::?? Saturday, August 18, 12

Slide 11

Slide 11 text

?:??::?? Saturday, August 18, 12

Slide 12

Slide 12 text

?:??::?? # => “:” Saturday, August 18, 12

Slide 13

Slide 13 text

eval \ '51966'+[46,1935634292,32,49,54].pack('clC3') Saturday, August 18, 12

Slide 14

Slide 14 text

eval \ '51966'+[46,1935634292,32,49,54].pack('clC3') # => “cafe” Saturday, August 18, 12

Slide 15

Slide 15 text

eval \ '51966'+['.',1935634292, ' ', '1', '6'].pack('ala3') # => “cafe” Saturday, August 18, 12

Slide 16

Slide 16 text

eval \ '51966'+['.', 'to_s', ' ', '1', '6'].pack('A4') # => “cafe” Saturday, August 18, 12

Slide 17

Slide 17 text

51966.to_s(16) # => “cafe” Saturday, August 18, 12

Slide 18

Slide 18 text

0xcaFE # => “cafe” Saturday, August 18, 12

Slide 19

Slide 19 text

enter the heredocs Saturday, August 18, 12

Slide 20

Slide 20 text

Saturday, August 18, 12

Slide 21

Slide 21 text

Saturday, August 18, 12

Slide 22

Slide 22 text

Distraction Saturday, August 18, 12

Slide 23

Slide 23 text

Saturday, August 18, 12

Slide 24

Slide 24 text

Saturday, August 18, 12

Slide 25

Slide 25 text

github.com / rkh / almost-sinatra more  popular  than  a  pair  of  socks Saturday, August 18, 12

Slide 26

Slide 26 text

As little code as possible just  eight  lines Saturday, August 18, 12

Slide 27

Slide 27 text

Obfuscation was never the goal just  a  by-­‐product Saturday, August 18, 12

Slide 28

Slide 28 text

%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

Slide 29

Slide 29 text

What works? Saturday, August 18, 12

Slide 30

Slide 30 text

Saturday, August 18, 12

Slide 31

Slide 31 text

Saturday, August 18, 12

Slide 32

Slide 32 text

Saturday, August 18, 12

Slide 33

Slide 33 text

Saturday, August 18, 12

Slide 34

Slide 34 text

Simplify and compress Saturday, August 18, 12

Slide 35

Slide 35 text

Saturday, August 18, 12

Slide 36

Slide 36 text

Saturday, August 18, 12

Slide 37

Slide 37 text

Saturday, August 18, 12

Slide 38

Slide 38 text

Saturday, August 18, 12

Slide 39

Slide 39 text

Saturday, August 18, 12

Slide 40

Slide 40 text

Saturday, August 18, 12

Slide 41

Slide 41 text

Saturday, August 18, 12

Slide 42

Slide 42 text

Saturday, August 18, 12

Slide 43

Slide 43 text

%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

Slide 44

Slide 44 text

Fake it ‘till you make it Saturday, August 18, 12

Slide 45

Slide 45 text

%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

Slide 46

Slide 46 text

%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

Slide 47

Slide 47 text

%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

Slide 48

Slide 48 text

%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

Slide 49

Slide 49 text

It’s all about fun! Saturday, August 18, 12

Slide 50

Slide 50 text

“From now on, I’ll start quoting myself.” Konstan(n  Haase Saturday, August 18, 12

Slide 51

Slide 51 text

“If your app does not run with Almost Sinatra, please open a Sinatra issue.” Konstan(n  Haase Saturday, August 18, 12

Slide 52

Slide 52 text

“Versions are to Software what Subversion is to Git.” Konstan(n  Haase Saturday, August 18, 12

Slide 53

Slide 53 text

“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

Slide 54

Slide 54 text

BEARS or Horses this  slide  is  for  James  Coglan Saturday, August 18, 12

Slide 55

Slide 55 text

Thank You @konstan(nhaase Saturday, August 18, 12