News for hackers. Stuff that matters.
Re:Sinatra in 8 lines by eggbrain on Tuesday March 08, 2011 @04:17PM (#2302627)
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
Re:Sinatra in 8 lines by apgwoz on Wednesday March 09, 2011 @08:32AM (#2304756)
It's been a long time, but I'd forgotten how easy Gentoo was to install!
Re:Sinatra in 8 lines by mmphosis on Tuesday March 08, 2011 @04:01PM (#2302578)

    ['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"
Re:Sinatra in 8 lines by daeken on Tuesday March 08, 2011 @02:46PM (#2302314)
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."
Re:Sinatra in 8 lines by apgwoz on Tuesday March 08, 2011 @03:55PM (#2302556)
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?

Re:Sinatra in 8 lines by snprbob86 on Wednesday March 09, 2011 @02:36AM (#2304220)
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.

Re:Sinatra in 8 lines by apgwoz on Wednesday March 09, 2011 @08:31AM (#2304753)
I'm almost the same way. I don't however used 79, it's normally like 75.
Re:Sinatra in 8 lines by mapleoin on Tuesday March 08, 2011 @04:14PM (#2302610)
I think that was tongue-in-cheek.
Re:Sinatra in 8 lines by tjogin on Tuesday March 08, 2011 @04:13PM (#2302607)
The visual user interface happened.
Re:Sinatra in 8 lines by thenduks on Tuesday March 08, 2011 @04:52PM (#2302728)
Odd. my 'visual user interface' for editing text is still about 80 characters wide. I just get to decide on how many pixels that is now with fonts/sizes/etc. I'm not sure why I'd want more horizontal room than that - readability begins to suffer greatly (not for you? think of the others you work with!).
Re:Sinatra in 8 lines by elliottcable on Tuesday March 08, 2011 @06:11PM (#2302988)
I actually spent an inordinate amount of time calculating the ideal a while back. As a sometime designer, I’m quite intimately familiar with the limits of comfortable reading for the human eye. After a silly quantity of math, I arrived at exactly 115 columns in fixed-width text as the ideally comfortable balance between readability and compactness.

Subtracting two for `diff` output, I hard-wrap all of my source-code and documentation files at column 113 exactly, and have for quite a while. It results in some quite sane output, in my opinion: https://github.com/elliottcable/Paws.c/blob/d2a5f3f/Source/P...

There are, of course, arguments to be made about source code itself; arguments you didn’t generally need to worry about at 78 characters, but that start to come into play when given that extra 35 columns; you need to start worrying about whether a given line of code is sane or readable once it starts to stretch towards 113 characters. There’s some situations where that’s perfectly normal and looks fine; but there’s also several where that indicates a serious problem in your code’s style. It’s just one more thing to think about while you design your source code.

Re:Sinatra in 8 lines by smanek on Wednesday March 09, 2011 @05:03AM (#2304446)
What "silly quantity of math" did you do to reach your conclusion?

I would have assumed that this sort of thing was simply an unquantifiable aesthetic preference (as long as you're below the char width of the screen, of course). I'm very interested in learning more about how you can come up with a 'right' answer to this sort of question, since I struggle with similar problems all the time (website layouts, etc).

Re:Sinatra in 8 lines by thenduks on Tuesday March 08, 2011 @06:55PM (#2303130)
I definitely agree. It matters more that there is a sane limit than what that limit actually is. Your 113 column files look good to me.
Re:Sinatra in 8 lines by tjogin on Wednesday March 09, 2011 @01:35AM (#2304114)
I was kidding, a little. I think 80 characters wide feels a bit cramped (and an artifact from a time before the visual user interface and high resolution displays), but 200 character lines is clearly way too much.
Re:Sinatra in 8 lines by mapleoin on Tuesday March 08, 2011 @03:17PM (#2302425)
Oh, how I miss _why.
Re:Sinatra in 8 lines by defroost on Wednesday March 09, 2011 @07:06AM (#2304632)
I second that. His awesome quirkiness and creativity are not easily replaced. His Seeing MetaClasses Clearly is one of my favorite Ruby metaprogramming ever.
Re:Sinatra in 8 lines by wtn on Tuesday March 08, 2011 @04:01PM (#2302579)
I miss the days when Zed Shaw was a Rubyist.
Re:Sinatra in 8 lines by mapleoin on Tuesday March 08, 2011 @04:13PM (#2302605)
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.

Re:Sinatra in 8 lines by knowtheory on Tuesday March 08, 2011 @05:00PM (#2302759)
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.
Re:Sinatra in 8 lines by mapleoin on Tuesday March 08, 2011 @06:35PM (#2303064)
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.
Re:Sinatra in 8 lines by nkassis on Tuesday March 08, 2011 @04:17PM (#2302626)
30 inch of snow fell where I live yesterday, I'd take zed and the hummer ;p

In all seriousness, they both were(are) awesome ruby developers and I wish they would come back and code more. We still use mongrel for our Rails app where I work and I've used shoes to develop a desktop client for our application.

Re:Sinatra in 8 lines by glenjamin on Tuesday March 08, 2011 @04:16PM (#2302621)
For some reason your description of Zed Shaw reminds me of maddox. Which has given me the idea to go see what he's written lately.
Re:Sinatra in 8 lines by ascendant on Tuesday March 08, 2011 @05:11PM (#2302798)
I don't know Zed but I got my start on the infamous rant. I read it and assumed he was just a guy that was tired of being shit on. In reading what he says and does in the following months and years, I don't get the sense he's an asshole, just that he doesn't really put up with crap unless there's a good reason.
Re:Sinatra in 8 lines by michaelcampbell on Tuesday March 08, 2011 @08:13PM (#2303347)
> I don't get the sense he's an asshole, just that he doesn't really put up with crap unless there's a good reason.

Which for some, make him an asshole.

Re:Sinatra in 8 lines by richbradshaw on Tuesday March 08, 2011 @05:21PM (#2302829)
Not being a rubyist, I don't get the joke (if it is one...!) Can someone explain?
Re:Sinatra in 8 lines by jdminhbg on Tuesday March 08, 2011 @06:20PM (#2303019)
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."
Re:Sinatra in 8 lines by riffraff on Tuesday March 08, 2011 @04:15PM (#2302615)
there are some low hanging fruits, I'll send a pull request :)
Re:Sinatra in 8 lines by daemonize on Tuesday March 08, 2011 @04:02PM (#2302584)
The guidelines break the contract of being under 10 lines of code, maybe not directly, but in spirit.
Re:Sinatra in 8 lines by thomasfl on Wednesday March 09, 2011 @03:44AM (#2304331)
I've printed it and post it on the office wall.