
Sinatra in 8 lines - jackowayed
https://github.com/rkh/almost-sinatra
======
eggbrain
Reminds me of the old bash.org joke:

    
    
        <@insomnia> it only takes three commands to install Gentoo
        <@insomnia> cfdisk /dev/hda && mkfs.xfs /dev/hda1 && mount /dev/hda1 /mnt/gentoo/ && chroot /mnt/gentoo/ && env-update && . /etc/profile && emerge sync && cd /usr/portage && scripts/bootsrap.sh && emerge system && emerge vim && vi /etc/fstab && emerge gentoo-dev-sources && cd /usr/src/linux && make menuconfig && make install modules_install && emerge gnome mozilla-firefox openoffice && emerge grub && cp /boot/grub/grub.conf.sample /boot/grub/grub.conf && vi /boot/grub/grub.conf && grub && init 6
        <@insomnia> that's the first one

~~~
apgwoz
It's been a long time, but I'd forgotten how easy Gentoo was to install!

------
mmphosis

        ['rack', 'tilt', 'backports', :INT, :TERM].map{|l|(l==l.to_s)?(require(l)):(trap(l){$r.stop})}
        $n=Sinatra=Module.new{$a,$o,$d,$h,$s,$f,$p=Rack::Builder.new,Object,:define_method,Hash,/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,File,4567;Application=$a}
        %w[get post put delete].map{|m|$o.send($d,m){|u,&b|$a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[$a.instance_eval(&b)]]}}}}
        Tilt.mappings.map{|k,v|$o.send($d,k){|n,*o|$t||=$f.read(caller.first[/^[^:]+/]).scan($s).inject({}){|h,(a,b,c)|h[a]=b;h};v.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|$o.send($d,m){|*_,&b|b.try(:[])}};at_exit{Rack::Handler.get("webrick").run($a,:Port=>$p){|s|$r=s}}
        ['params', 'session', Rack::Session::Cookie, Rack::Lock].map{|m|(m==m.to_s)?($o.send($d,m){$q.send(m)}):($a.use(m))}
        $o.send($d,:before){|&b|$a.use(Rack::Config,&b)};before{|e|$q=Rack::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"

------
daeken
The best part of this is one of their coding guidelines: "don't include tests.
tests just bloat the code base. just commit, the users will complain if you
break anything."

~~~
apgwoz
I was partial to:

> wrap at 200 characters to make it readable on a terminal

What happened to the days of 80 character line limits?

~~~
snprbob86
I've got a 27" iMac, and I've recently moved to a 79 character limit on
Python, Ruby, shell scripts, Sass, Javascript, and pretty much everything else
but HTML/Haml.

I now write better (i.e. flatter) code that is easier to compare to my other
(better :-P) code.

Highly recommended.

~~~
apgwoz
I'm almost the same way. I don't however used 79, it's normally like 75.

------
mapleoin
Oh, how I miss _why.

~~~
wtn
I miss the days when Zed Shaw was a Rubyist.

~~~
mapleoin
I think Zed Shaw is quite the opposite of _why. I can see _why playing with
kittens and making chalk drawings on the asphalt in a torrid calm summer day
and Zed driving through in a camo Hummer, smoking a big cigar and listening to
industrial metal. All the kittens run scared and _why goes hiding behind a
bush where he meets a new imaginary friend.

I much prefer _why.

~~~
knowtheory
Except _why and Zed got along fine. Zed is a perfectly cool dude in person.
And regardless of what you think of Zed he builds good tech, shares it with
others, takes contributions from other people.

~~~
mapleoin
Of course I haven't met either one of them and I can't really talk about the
kind of person they are, just about their personas and the way that I perceive
them.

------
richbradshaw
Not being a rubyist, I don't get the joke (if it is one...!) Can someone
explain?

~~~
jdminhbg
Sinatra is a minimalist Ruby web framework, this is a Perl Golf-style super-
minimalist clone of it, with lots of tongue-in-cheek comments in the docs,
e.g. "If your app does not run with Almost Sinatra, please open a Sinatra
issue."

------
riffraff
there are some low hanging fruits, I'll send a pull request :)

------
daemonize
The guidelines break the contract of being under 10 lines of code, maybe not
directly, but in spirit.

------
thomasfl
I've printed it and post it on the office wall.

