Toys: September 2006 Archives

I stole the code posted on reddit earlier today and ported it to ruby. Now I can do the following:

layout = BoxLayout.html <<-END
----------
|        |
----------
| |    | |
| |    | |
| |    | |
| |    | |
----------
|        |
----------
END

puts layout % [header, left_sidebar,
               body,
               right_sidebar, footer]

and get layout code that looks much much cleaner than the equivalent HTML/rhtml/whatever. I can instantly look at this code and know what it is gonna look like in a browser. I'll release this soon, but I have some enhancements for codeforpeople's rubyforge and seattle.rb's hoe first.

I found Shortest Python Quine? and thought I'd check it out. I wasn't aware of python's %r, but apparently it is equivalent to our %p (which I always forget about). Anyhow, here is our version:

% ruby quine.rb 
_="_=%p;puts _%%_";puts _%_
% ruby quine.rb | ruby
_="_=%p;puts _%%_";puts _%_

or eric's morph:

% echo '_="_=%p;puts _%%_";puts _%_' | ruby | ruby
_="_=%p;puts _%%_";puts _%_

Comes in at 28 characters, and ties the shortest on rubygarden.

About this Archive

This page is a archive of entries in the Toys category from September 2006.

Toys: August 2006 is the previous archive.

Toys: March 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.1