hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

205,000 Lines of Ruby Code Donated in the Try Ruby Drive #

by why in inspect

You hear that sound? That subtle squeak which instantly reminds one of distant ducks quacking great spools of wood grain? Yeah, that one. That’s what it sounds like when the world gets together to code.

Portrait of Try Ruby.

Matz spilled the cat two days ago on his blog, as one of the many testers I employed to shake apart my new Try Ruby online tutorial. I ran this sucker by the #hoodwinkd crew, the project.ioni.sts and the #rubyist.org gang, Florian Gross, and even the illustrious Guy Decoux. A very capable lot, I thank them all.

So, 205,000 lines of Ruby code in two days. I’m watching all this code come in and finding myself very entertained. Here’s a few of my favorite moments:

 >> gem install rails

Approximately five people attempted to require "rails" or even render_text "w00t". But running gem install is just pricelessly wrong.

I also really like require 'tk'. I mean you really want to unfold that tent right in the middle of this beautiful prompt I’ve given you?

 >> system.out.println("hola")

Fifteen people like that. I am really tempted to spoof it. I can see these guys getting a happy teeth expression and going, “Wow, Ruby really is easy!”

 >> Kernel.fork { "hello" }

Lots of people got fork and puts mixed up.

 >> while true; puts 'Joe Junkpan' end

I love it. That’s going to hurt you a lot more than it hurts me. Don’t forget not to type Symbol.all_symbols.

 >> format c:
 >> cd c:\
 >> delete c:\

Oh no, my MP3s! My Usher collection! NO!

 >> wtf?
 >> hello?

About sixty people welcomed themselves to the interpreter by typing wtf. I should make it an alias for help.

From today at 4:43 PM:

 >> wtf
 >> wtf = wtf
 >> wtf==wtf
 >> wtf?
 >> time
said on 30 Nov 2005 at 01:15

`rm -rf` didn’t work either :|

said on 30 Nov 2005 at 01:15

not that it would work normally, but you get the general idea.

said on 30 Nov 2005 at 01:28

See, you should have tried `../../../../../../../../bin/rm -rf` like some of these other guys. It wouldn’t have worked either, but you never know when a parent directory is suddenly going to show a little leg.

said on 30 Nov 2005 at 01:28

Alas, it doesn’t work in Safari. The period key doesn’t render, either the regular one of the one on the numeric keypad. And yes, those keys do work regularly.

This is for Safari 2.0.2. With Firefox/Mac it works just fine.

said on 30 Nov 2005 at 01:38

I could really use help with Safari. I’m stabbing in the dark on that one.

said on 30 Nov 2005 at 02:26

I have to admit I added to a few of those odd pokes like fork. Though, you seem to have changed a few things so now I have to do this to access Kernel:

>> Obejct.ancestors.last
=> Kernel

The thing that got me to try it was the fact the method is still listed. I still need to try out set_trace_func to see if I can catch a binding but well… the idea is out now. You probably have patched all of those already but I am willing to poke at this new wonder more if you like.

said on 30 Nov 2005 at 03:49

Hrm, I just tried executing a simple puts statement in Safari and it crashed my browser!

said on 30 Nov 2005 at 04:40

Usher collection? Burst my bubble!

said on 30 Nov 2005 at 06:21

I suspected you would be looking. That’s why I greeted you ;)

said on 30 Nov 2005 at 06:58

Why: you really do need a PowerBook in your life. We could make it happen, you know. Just give the nod…

said on 30 Nov 2005 at 07:48

Presumably the fault lies in the onKeyDown method – are you sure these keyCodes are portable across browsers? Presumably the dot is being interpreted as a disallowed character (yes, this is not hard to work out : )

onKeyDown: function(e) { <br/> e = (e) ? e : ((event) ? event : null); <br/> if ( e && MouseApp.CodeKeys[e.keyCode] ) { <br/> if ( window.event && e.keyCode != 13 && e.keyCode != 8 ) { <br/> this.sendKeyPress(e); <br/> } this.blockEvent(e); <br/> return false; <br/> } <br/> return true; <br/> }, <br/> <br/> onKeyPress: function(e) { <br/> if ( window.event && e.keyCode != 13 && e.keyCode != 8 ) { <br/> e.charCode = e.keyCode; e.keyCode = null; <br/> } <br/> return this.sendKeyPress(e); <br/> }, <br/>

The up arrow gives an extra character at the end of the last used statement, which also renders that feature inoperable. If the code was available for download we could give it a try for you.

Doesn’t work in Opera either I’m afraid.

said on 30 Nov 2005 at 08:10

oh my god this is GORGEOUS :~

said on 30 Nov 2005 at 08:48

Oh, fine fine. Now people are filing their bug reports through the prompt.

“hey mr lucky stiff, the help # is not working properly. after I type books={} to begin the tutorial I’m back to ‘counting the letters’”

Fixed!

I really have no idea how to get Opera to cooperate. It’s shortcuts steal the show. Safari I’m sure is just a few subtle tweaks away.

said on 30 Nov 2005 at 09:06

This does so much rock, however in Firefox / Windows, the divide example 40 / 4 shows ‘40 /? 4’, and doesn’t return the right answer. Also when I get to print poem, it doesn’t go on.

Maybe I timed out on that last problem.

Congrats.

said on 30 Nov 2005 at 09:14

This is an incredible piece of work, I’ve got to hand it to you! I’ve only noticed one typo so far.

You stated the following in Summary #4:

Blocks. Chunks of code which can be tacked 
on to many methods. Here's the code you 
used to build a scorecard: 

books.each { |title, rate| ratings[rate] += 1 }

When the actual bit oh code that was used was:


books.values.each { |rate| ratings[rate] += 1 }

I’ll let you know if I find anything else!

Jordan.

said on 30 Nov 2005 at 09:19

by golly, that thing is hard to bamboozle. Clever, you.

said on 30 Nov 2005 at 09:42

When I try to run it locally I get all caps in Safari. But it looks like the problem could be with the keypress event. In Safari keyCode is different in onkeypress (46) and onkeydown (190). That seems weird to me, but I’m not very experienced with keyboard events in javascript.

said on 30 Nov 2005 at 09:54

So it was all an evil plot to let you make fun of my code? First Duke Cunnigham and now why. One by one, all my idols crumble.

said on 30 Nov 2005 at 10:27

Poor jeem, it’s just that you make me so happy. Sleep, my child, no more math homework tonight.

said on 30 Nov 2005 at 10:33

Briliant as ever ;)

...and sometimes more so!

said on 30 Nov 2005 at 10:44

how many of those lines involved the phrase “hello world”? (I personally know of a least one :)

said on 30 Nov 2005 at 10:54

How about a “bug” function? Then you wouldn’t have to read the logs to find out “hey mr lucky stiff the help ain’t working”...

said on 30 Nov 2005 at 11:12

I played with this yesterday, but was a good boy and didn’t try anything evil. I did take a look at the source for the page to try and figure out some of the magic. But I didn’t delve deeply into the included .js files, because IANAJSH (I Am Not A JavaScript Hacker.)

But for fun:


irb(main):001:0> class System
irb(main):002:1> def self.out
irb(main):003:2>     unless @o
irb(main):004:3>       @o=Object.new
irb(main):005:3>       def @o.println(s)
irb(main):006:4>  puts s
irb(main):007:4>       end
irb(main):008:3>     end
irb(main):009:2>     @o
irb(main):010:2>   end
irb(main):011:1> end
=> nil
irb(main):012:0> System.out.println("Look ma, it's Java!")
Look ma, it's Java!
said on 30 Nov 2005 at 12:37

This is extremely cool. Web-based irb for people with broken computers (“what?! no irb command?!”).

Have you considered making “ri” available from the tutorial prompt?

said on 30 Nov 2005 at 14:13

I decided to spread the word further. hopefully the ruby communtiy will gain a healthy amount of swedes in the near future.

said on 30 Nov 2005 at 14:19

When I use my surname (jürgen) help 1 is not working. The character ü somehow prevents the tutorial to proceed to the next step. I have to rely on “Jimmy” instead.

said on 30 Nov 2005 at 14:35

Suggestion: an all UTF -8 version would be nice.

said on 30 Nov 2005 at 14:39

I think we’re now at a point in history where the actual user interfaces are going to look cooler than the ones in movies.

I’m tempted to make a Bling style for tryruby

said on 30 Nov 2005 at 15:04

Yes, Danno. I’ve also wondered what people could do with Greasemonkey/MouseHole in terms of saving scripts and sharing scripts and so on.

said on 30 Nov 2005 at 16:07

On the 40.reverse page, “fourty” should be “forty”.

said on 30 Nov 2005 at 16:14

So Why, how did you manage to get scooped by O’Reilly and others in announcing this?

said on 30 Nov 2005 at 16:43

Nice work as always Mr. Why. One typo: “(Also known as: an empty dictionary.” Missing close parenthesis. Everything after that sentence was parenthetical and I just couldn’t take it seriously.

said on 30 Nov 2005 at 16:50

Also, I accidentally triggered a tutorial hop while mucking around. What about a “back” command to go back a page?

said on 01 Dec 2005 at 00:49

Great job, Why – I’ll nave all the Ruby n00bs at work hitting your site tomorrow morning

said on 01 Dec 2005 at 10:11

I see, so us Opera lepers can just crawl back to our lo-tech hole and die, can we, while you all enjoy the benefits of Ruby on the intarweb?

In firefox, though: Why, it’s sublime :]

said on 01 Dec 2005 at 10:57

The dead-keys in my keyboard ( like ~, `, ”, , ’, ^, the ones I heve to type space before because they are use to accentuate some letters in Portuguese) does’nt work in the shell. Just now that I was going to demonstrate some people how this Ruby language is cool, but wacky ...

said on 01 Dec 2005 at 15:29

Great stuff. :D Is there a Ruby equivilent to python’s ‘import this’?

said on 01 Dec 2005 at 16:58

DeanG: not knowing what import does in python, but “require”, I suppose.

said on 13 Dec 2005 at 23:16

Damn. Wow. Amazing.

I have the following demands:

1) Release to the ruby world the magic behind this fantastic toy.

2) Prod people to make a new generation of programming tutorials (yay interaction!) for various ruby topics (regular expressions! crazy string manipulation!).

3) Doubly prod people to make interactive programming games with this. I certainly would love to make a few ruby games with this kind of distribution/interface mechanism.

said on 20 Dec 2005 at 09:49

You might want to inform people using your service that you are recording everything they type. Are you recording IP addresses too?

Comments are closed for this entry.