RSS RedHanded

http://redhanded.hobix.com

Friday January 19th, 2007

Kchhhk (Small Implosion)

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Kevin Clark: This might be the longest post with the least substance I’ve read in a long time. Why would you use this space to tout your history? How did you get post access on the O’Reilly Ruby Blog?

Let the blogging contests begin!!

Thursday January 18th, 2007

Camping's Youthfulness Wins Annual Award

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Today, the International Kayak Consortium celebrates Camping (a Microframework)’s 1st birthday. They have honored the paragraph of code by awarding it the Annual First Place in Birthdaying Special Day Award and So Brave.

The commissioner of kayaking LeBrock Mitchell gave an acceptance speech on behalf of Camping at this morning’s banquet. His sentiments were brief, but stirring:

I have written two speeches for today, a long one and a short one. However, the pages for both got wet inside my kayak. Yes, I tried blow-drying them. But as I held that that cylinder of hot air, I realize that I couldn’t say anything as brief as Camping itself.

And he held up a printout of Camping from trunk and he wept exactly 4k of tears. We, in fact, measured with a graduated cylinder.

Here is Camping today.

%w[active_support markaby tempfile uri].map{|l|require l}
module Camping;Apps=[];C=self;S=IO.read(__FILE__).sub(/S=I.+$/,'')
P="Cam\ping Problem!";module Helpers;def R(c,*g);p,h=/\(.+?\)/,g.grep(Hash)
(g-=h).inject(c.urls.find{|x|x.scan(p).size==g.size}.dup){|s,a|s.sub p,C.
escape((a[a.class.primary_key]rescue a))}+(h.any?? "?"+h[0].map{|x|x.map{|z|C.
escape z}*"="}*"&": "")end;def URL c='/',*a;c=R(c,*a)if c.respond_to?:urls
c=self/c;c="//"+@env.HTTP_HOST+c if c[/^\//];URI(c)end;def/p;p[/^\//]?@root+p :
p end;def errors_for o;ul.errors{o.errors.each_full{|x|li x}}if o.errors.any?end
end;module Base;include Helpers;attr_accessor:input,:cookies,:env,:headers,:body,
:status,:root;def method_missing*a,&b;a.shift if a[0]==:render;m=Mab.new {},self
s=m.capture{send(*a,&b)};s=m.capture{send(:layout){s}} if /^_/!~a[0].to_s and m.
respond_to?:layout;s end;def r s,b,h={};@status=s;@headers.merge!h;@body=b end
def redirect*a;r 302,'','Location'=>URL(*a)end;Z="\r\n";def to_a;[@status,@body,
@headers]end;def initialize r,e,m;e=H[e.to_hash];@status,@method,@env,@headers,
@root=200,m.downcase,e,{'Content-Type'=>"text/html"},e.SCRIPT_NAME.sub(/\/$/,'')
@k=C.kp e.HTTP_COOKIE;q=C.qsp e.QUERY_STRING;@in=r;if%r|\Amultipart/form-.*boun\
dary=\"?([^\";,]+)|n.match e.CONTENT_TYPE;b=/(?:\r?\n|\A)#{Regexp::quote("--#$1" 
)}(?:--)?\r$/;until@in.eof?;fh=H[];for l in@in;case l;when Z;break
when/^Content-D.+?: form-data;/;fh.u H[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten]
when/^Content-Type: (.+?)(\r$|\Z)/m;fh[:type]=$1;end;end;fn=fh[:name];o=if
fh[:filename];o=fh[:tempfile]=Tempfile.new(:C);o.binmode;else;fh=""end;while l=@in.
read(16384);if l=~b;o<<$`.chomp;@in.seek(-$'.size,IO::SEEK_CUR);break;end;o<<l
end;C.qsp(fn,'&;',fh,q) if fn;fh[:tempfile].rewind if fh.is_a?H;end;elsif@method==
"post";q.u C.qsp(@in.read)end;@cookies,@input=@k.dup,q.dup end;def service*a
@body=send(@method,*a)if respond_to?@method;@headers["Set-Cookie"]=@cookies.map{
|k,v|"#{k}=#{C.escape(v)}; path=#{self/'/'}"if v!=@k[k]}-[nil];self end;def to_s
a=[];@headers.map{|k,v|[*v].map{|x|a<<"#{k}: #{x}"}};"Status: #{@status}#{Z+a*Z+
Z*2+@body}"end;end;X=module Controllers;@r=[];class<<self;def r;@r;end;def R*u
r=@r;Class.new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end;def M;def M
end;constants.map{|c|k=const_get(c);k.send:include,C,Base,Models;r[0,0]=k if
!r.include?k;k.meta_def(:urls){["/#{c.downcase}"]}if !k.respond_to?:urls}end;def
D p;r.map{|k|k.urls.map{|x|return k,$~[1..-1]if p=~/^#{x}\/?$/}};[NotFound,[p]]end
end;class NotFound<R();def get p;r(404,Mab.new{h1 P;h2 p+" not found"})end end
class ServerError<R();def get k,m,e;r(500,Mab.new{h1 P;h2"#{k}.#{m}";h3"#{e.class
} #{e.message}:";ul{e.backtrace.each{|bt|li(bt)}}}.to_s)end end;self;end;class<<
self;def goes m;eval S.gsub(/Camping/,m.to_s).gsub("A\pps=[]","Cam\ping::Apps<<\
self"),TOPLEVEL_BINDING;end;def escape s;s.to_s.gsub(/[^ \w.-]+/n){'%'+($&.
unpack('H2'*$&.size)*'%').upcase}.tr(' ','+')end;def un s;s.tr('+',' ').gsub(
/%([\da-f]{2})/in){[$1].pack('H*')}end;def qsp q,d='&;',y=nil,z=H[];m=proc{|_,o,n|o.u(
n,&m)rescue([*o]<<n)};q.to_s.split(/[#{d}] */n).inject((b,z=z,H[])[0]){|h,p|k,v=un(p).
split('=',2);h.u k.split(/[\]\[]+/).reverse.inject(y||v){|x,i|H[i,x]},&m}end;def
kp s;c=qsp(s,';,')end;def run r=$stdin,e=ENV;X.M;k,a=X.D un("/#{e[
'PATH_INFO']}".gsub(/\/+/,'/'));k.new(r,e,(m=e['REQUEST_METHOD']||"GET")).Y.
service *a;rescue Object=>x;X::ServerError.new(r,e,'get').service(k,m,x)end
def method_missing m,c,*a;X.M;k=X.const_get(c).new(StringIO.new,H['HTTP_HOST',
'','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s);H.new(a.pop).each{|e,f|k.send(
"#{e}=",f)}if Hash===a[-1];k.service *a;end;end;module Views;include X,Helpers
end;module Models;autoload:Base,'camping/db';def Y;self;end;end;class Mab<
Markaby::Builder;include Views;def tag!*g,&b;h=g[-1];[:href,:action,:src].map{
|a|(h[a]=self/h[a])rescue 0};super end end;H=HashWithIndifferentAccess;class H
def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m]:raise(
NoMethodError,"#{m}")end;alias_method:u,:regular_update;end end

More recently:

Dream Ledger, a campsite for journaling yr sleep time. An introduction to Camping by Eric Mill. Feedchamp, an rss aggregator in Camping.

Update: If all of you can get out your copy of the Camping core team’s group picture, Indian Chief Skittles McQueeny has just sent me the following legend:

Ranger Jake (holding a lizard) Tiffany Rabbitsapple (a non-notable prince) why the lucky stiff Spud Webb (the same) Indian Chief Skittles McQueeny Mrs. Rummly Jonas Pfenniger Oarsman C. S. “Celery Shirt” Acornson Camera Nap Helps the Janitor (holding a soccer ball under his poncho)

Update from Air Force Staff Sargeant Guds Mandragon:

We try to keep a lid on it, but some pilot folklore has infiltrated our ranks. The tale goes that if you eject from your plane on Camping’s birthday that you will be visited in the night by a red fairy who will grant you a free batch of caramel apples, answering to any quantity you provide. In some permutations of the rumor, she grants an infinite quantity. Four aircraft have been ditched, two have struck earth, one crushing a cereal factory. I am told Grape Nuts. Please dispell this rumor forthrighly.

Hmm, interesing stuff. Thanks, Guds!

Update:

Update: The latest Camping trunk lets you add a query string to your routes by adding a Hash argument.

 >> a "version 2", :href => R(Show, page.title, :version => 2)
 => "<a href='/wiki/title?version=2'>version 2</a>" 

Wednesday January 10th, 2007

Gemtacular Gone Be Bona Fide

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Chad Fowler: I was thinking we could deploy this on rubygems.org and maybe open up the source for a few collaborators.

RE: Gemtacular.com. Added to hoodwink.d, if you want to comment on gems. Also related and interesting: Dr. Nic and Erik Kastner offer Gem metastuff in JSON.

Monday January 8th, 2007

Eigenclass Considered... Considered!

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Matz is warming up to the term eigenclass, the People’s slang for (class << self; self; end). From [ruby-talk:231992]:

In my mindset, two candidates have survived. singleton_class (or singletonclass), which can easily be confused with a class in the singleton design pattern. And eigenclass, which is unfamiliar for most people.

Does anyone know if Perl 6 folks still use it?

Friday January 5th, 2007

Instiki to Junebug

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Want to move from Instiki to Junebug? I exported my Instiki as a zip of .textile pages and wrote instiki2junebug.rb to import my pages. Give it the Junebug username to assign the pages to and a path to the unzipped directory of files.

 junebug wiki
 cd wiki
 ruby instiki2junebug.rb _why ~/instiki-dump

Thursday January 4th, 2007

Christoffer's Hpricot Goodies

RedHanded From RedHanded, 1 year ago, 0 comments Comment

So, in what ways have you guys extended Hpricot? I really enjoy this collection of accessories to Hpricot by Christoffer Sawicki, who also wrote the Hpricot-based HTML-to-feed library called Feedalizer.

He has one script that does gsub! on all text nodes in the document. Another script is for generating tables of contents from the headers on an HTML page. I imagine that would go great with Markdown and Textile. (See also: del.icio.us/tag/hpricot.)

(Poignant) Guide Earlies

RedHanded From RedHanded, 1 year ago, 0 comments Comment

As I’m wrapping up the 8th chapter of my obscure Ruby book, you might be interested in a sneak peek at some of the art going into this 20-page fully-illustrated chapter. The Poignant Guide Earlies set on flickr has just a few scans.

This weekend I’ll also be posting some scans from Expansion Pak No. 2, which covers packaging libraries. This expansion pak will have appearances by Spiderman, Indiana Jones, various illegal Windows product keys, illegal scans of sheet music—in short, a pile of things which will render the book unprintable. With any luck, the first illegal programming manual.

Monday January 1st, 2007

YARV is Ruby, It Is, It Really Is

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Koichi has finished committing YARV to Ruby’s trunk. We’re on our way to Ruby 1.9.1. Great work, Ruby-Core!

 $ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby
 $ autoreconf -ivf
 $ ./configure --prefix=/opt/ruby-trunk
 $ make
 # make install-nodoc
 $ export PATH=/opt/ruby-trunk/bin:$PATH
 $ ruby -v
 ruby 1.9.0 (2007-01-01 patchlevel 0) [i386-freebsd6.0]

Oh, and if you want to install extensions, you’ll need to uncomment them in ext/Setup.

Update: Murphy’s got some informal benchmarks which produce a YARV speed-up chart. Try out this script here. (from [ruby-core:9825])

Saturday December 30th, 2006

A Fine Time, Oh Yes!

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Hey, what a fun year, you know?

January – Zed releases Mongrel 0.1. Chris Pine’s classic Learn to Program is published. Ruby-doc redesigns. Steve Yegge’s A Little Anti-Anti-Hype sets Steve apart as one of Ruby’s most-heard proponents, proving that Rubyists (aside from being just “nice”) can still be grumpy and drunken and all that. Camping, it’s the little wheels.

February – YARV 0.4.0 comes out. Minero Aoki gets Rails running on it. Ruby brigades are a hot topic.

March – Translation of Ruby Hacking Guide to English begins. Rubyists at SXSW Interactive. Lots of people rip on poor, poor James McGovern.

AprilCanada on Rails. DHH says the F-word. And flips the crowd off or something. It’s a pretty serious deal. Later that month: healing.

MayRuby Inside pops up, suddenly, helping lots of little projects and interesting things everywhere. Google Summer of Code kicks off, sponsoring 10 fledgling Ruby projects. Pat Eyler interviews Zed and then does like a hundred more interviews after that.

Ruby’s Core Team at RubyKaigi in Japan.

JuneRailsConf 2006. Railsers shake hands and go nuts. Try Ruby appears in Second Life. Intangible coders made of various polygons go nuts.


The RailsConf message board, a fond memory.

July – Tim Bray starts to get serious about Ruby. He and Sam Ruby descend upon RedHanded. Lots of Rubyists at OSCON. FOSCON, a Ruby-themed grassroots conf, makes its second year.

August – After a year and a half, the new Ruby site goes up. The LLRing is held in Japan. RubyConf-MI. Rails Blob.


London

September – Matz starts messing around in the lab. (:symbol.is_a? String => true) and (String < Enumerable == false). RailsConf Europe in London. I get to meet Chris Neukirchen and Hampton Caitlin gives a talk with a nice, tall beer in his hand. Aaron Patterson opens up his webcam and BetaBrite to remote hacking.

OctoberRubyConf 2006 and the subsequent Denver Accord. Rails gets UTF-8. Lots of speculation about Ruby’s future that keeps the blogs busy for awhile—InfoQ summarizes.

November – Spanish and Polish translations of the Ruby site open. Piles of other languages start translation teams. Avi writes smalltalk.rb whilst a blizzard of work transpires on Rubinius.

December – The Ruby team moves to Subversion. Zed Shaw starts a mission to win a popularity contest and he wins!! He was just so stunning in the eveningwear portion of the pageant!!

I hope this isn’t too glad-handed or self-congratulatory so far. I’m just playing historian for a bit.

So, I asked a bunch of various Rubyists to give me a single sentence (a moment, a bit of code, a hiccup, whatever) that represents this year to them. If I didn’t ask you, it’s probably because I got tired of hunting down e-mail addresses, so go ahead and add your one-liner in the comments.

I get the impression that in 2006 Ruby was recognized on its own merits aside from Rails. Marcel Molina, Jr

YARV.sub(/Yet Another/, ‘The’) Sasada Koichi

This year Ruby got more awesome. Chris Wanstrath

Ruby this year was a further spreading; I’m happy many people got interested in it. Urabe Shyouhei

The joy which is Ruby attacked me this year; it was everywhere like a herd of pigs negotiating a river of fire. Bil Kleb

Ruby shared its power and shed its light throughout 2006 — with a big surge in book publication, numerous conferences around the world, users group meetings, forum posts, and coding activities of all sorts — as it will, with any luck, for years to come! David Alan Black

diamonds
on a red dirt path
a shell
in the mountains
but we aren’t at war. Evan Weaver

There was no computer magazine in which “Ruby” (as well as Matz) was not seen here in Japan. Daigo Moriwaki

A gold rush is coming to an end, leaving part of the original excitement behind, and even though new (and some half-abandoned) deposits show great promise, mining them will prove hard. Mauricio Fernandez

begin; Ruby.extend(World) ensure defined? MINASWAN end James Edward Gray II

ruby code—
beautiful like the sun
don’t look too closely. Zed Shaw

2006 was the year Ruby brought the joy of programming back to the adventurous, the creative, the kind, and the brave, in the greatest numbers since the Commodore 64. Peter Cooper

July/August: Arrived in Netherlands, visited Chicago, started a blog, and had a baby; both doing well. Dr Nic Williams

300 blogs, 25 books, 7 interpreters, 5 conferences, but still just one Ruby. Pat Eyler

At the beginning of the year I hoped Ruby would change my life. With my move to Sun and the progress we’ve made on JRuby, I can safely say it’s exceeded my wildest expectations. Charles Oliver Nutter

If anything is secret, it’s just because I haven’t thought of it yet. Geoff Grossenbach (quoting Sam Stephenson)

map.resources :posts Jamis Buck

Our little challenger has become the incumbent, the bleeding edge took a few steps forward, and a lot of us that usually pride ourselves on staying ahead of the game are starting to realize that Ruby is becoming the game. Chad Fowler

release lecture release consult release overwhelmed release conference release. Ryan Davis

Ruby in 2006: A catalyst for both personal and professional change. James Britt

Do it for yourself. David Heinemeier Hansson


An immortal shot of DHH, Matz and Babie doing a tribute to some cat guy who poses like an airplane.

2006 was the year Ruby turned from implementation to a language, JRuby grew up and ran Rails, and Rails grew bigger. Ola Bini

Struck out on my own and actually paid bills with rails work, launched a few cool OSS apps, and made a lot of great contacts in the rubyverse both offline and online. Rick Olson

A shiny new Web site, the Ruby job market growing by leaps and bounds, a ton of new Ruby libraries and projects—what’s next? John W. Long

This year featured documentation and automation with a fair bit of destruction on the side… next year I will bring the Ruby community automated destruction. Eric Hodel

Hurry! It’s leaving!
All aboard the ruby train
for gorgeous bytecode. Evan Phoenix

Suddenly, we are not alone. MenTaLguY

And we’ll offer matz a more spacious portion, you know?

2006 is the year of acceptance, the year of social movement. We do little in making the language better this year. But many have found its goodness we’ve already made, and rushed toward joy of programming. It is good thing. I expect this social movement continues in 2007 too. I hope we can get technical advancement as well in the next year. matz

Friday December 29th, 2006

The Siphoning Splat

RedHanded From RedHanded, 1 year ago, 0 comments Comment

I’m serious about this. The splat is such a wildly devious little asterisk.

>> instruments = {'trombones' => 1, 'clarinets' => 2} 
>> p instruments.to_a
[["trombones", 1], ["clarinets", 2]]
>> p *instruments
["trombones", 1]
["clarinets", 2]

A 2-in-1 combo move! Look at that splat. It’s not just to_a. It called to_a and it siphoned the arguments.

So, Camping has an r method which is for making HTTP responses from scratch. The signature of this method is: r(status, body, headers = {}).

 r(404, 'Not Found', 'X-Powered-By' => 'Camping')

And it has controller objects (descended from Camping::Base) which you run into sometimes. These objects have @status, @headers and @body ivars inside them.

 class Camping::Base
 def to_a
 [@status, @body, @headers]
 end
 end

With the above to_a method, I can now do:

 r(*controller)

Which can be used as a syntax for forwarding HTTP requests.

See, Camping has a technique for making requests inside itself. For example, let’s say we’ve got a Search controller that takes a q variable with search terms in it. And, let’s say we want the front page (the Index controller) to show the results page for a search containing the word “clarinet.”

 class Index < R '/'
 def get
 r *AppName.post(:Search, :env => @env, :input => {:q => "clarinet"})
 end
 end

The splat is Ruby’s pipe for arrays. Put that in your pipe and splat it!

Wednesday December 27th, 2006

require_gem is Deprecated

RedHanded From RedHanded, 1 year ago, 0 comments Comment

The require_gem command is gone. It’s just gem now. (RubyGems 0.9.0.8 and later.)

 require 'rubygems'
 gem 'camping', '=1.5'
 require 'camping'

To try out the latest beta gem:

 gem update --system --source http://onestepback.org/betagems

(Thanks 1vy!)

Elizabeth's How to Think... With Ruby

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Okayyy. So, I really thought our free books were in decline. But what’s this? Elizabeth Wiethoff started a book back during the summer titled How To Think Like a Computer Scientist: Learning With Ruby. (She translating from the Java one.) I checked del.icio.us and only one person knew about it.

She’s only three chapters deep, but a lot of the code is there. One thing about this book: if you’re precocious, I’m sure you could help her translate some chapters. I mean there’s already some blank bullets for you on the contrib page.

« older items