5 ms·
Sinatra in 8 lines
- thomasfl 16y agoI've printed it and post it on the office wall.
- daeken 16y agoThe 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 16y agoI was partial to: > wrap at 200 characters to make it readable on a terminal What happened to the days of 80 character line limits?
- tjogin 16y agoThe visual user interface happened.
- thenduks 16y agoOdd. 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!).
- elliottcable 16y agoI 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/Paws.c#files 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.
- thenduks 16y agoI 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.
- smanek 16y agoWhat "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).
- tjogin 16y agoI 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.
- mapleoin 16y agoI think that was tongue-in-cheek.
- snprbob86 16y agoI'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 16y agoI'm almost the same way. I don't however used 79, it's normally like 75.
- mapleoin 16y agoOh, how I miss _why.
- wtn 16y agoI miss the days when Zed Shaw was a Rubyist.
- mapleoin 16y agoI 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.
- glenjamin 16y agoFor 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.
- nkassis 16y ago30 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.
- knowtheory 16y agoExcept _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 16y agoOf 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.
- mmphosis 16y ago['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"
- daemonize 16y agoThe guidelines break the contract of being under 10 lines of code, maybe not directly, but in spirit.
- riffraff 16y agothere are some low hanging fruits, I'll send a pull request :)
- eggbrain 16y agoReminds 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 16y agoIt's been a long time, but I'd forgotten how easy Gentoo was to install!
- richbradshaw 16y agoNot being a rubyist, I don't get the joke (if it is one...!) Can someone explain?
- jdminhbg 16y agoSinatra 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."