hoodwink.d enhanced


Rubyless Ruby #

by why in inspect

Pardon the absence. I’m adventuring along the coast this month. (Rails 1.0 is out, wowwa!) Still, the scripts are flowing freely.

For example, here’s a Ruby prompt which only requires sh and curl. See, it’s a Try Ruby hack. I know this would have been ten times cooler to write in Python. But I don’t want people installing Python, I really don’t!

 wget="wget -q -O -" 
 sess="$($wget "$tryurl!INIT!IRB!")" 
 if [ -z "$sess" ] ; then
    wget="curl -s" 
    sess="$($wget "$tryurl!INIT!IRB!")" 

 # heshugly url encoding
 urlx() {
    echo "$*" |
    awk 'BEGIN { split("1 2 3 4 5 6 7 8 9 A B C D E F", het, " ");het[0] = 0
    for (i = 1; i <= 255; ++i) ord[ sprintf ("%c", i) "" ] = i + 0;}{
    enx = "";for (i = 1; i <= length($0); ++i ) {c = substr ($0, i, 1);val = ord[c]
    if (val >= 97 && val <= 122){enx = enx c}else if (val >= 65 && val <= 90){
    enx = enx c}else if (val >= 48 && val <= 57){enx = enx c}else if (val >= 45 && 
    val <= 46){enx = enx c}else if (c == " "){enx = enx "+"}else if (val < 128) {
    lo = val % 16;hi = int(val / 16);enx = enx "%" het[hi] het[lo];}else{byte = \
    192 + val/64;lo = byte % 16;hi = int(byte / 16);enx = enx "%" het[hi] het[lo];
    byte = 128 + val%64;lo = byte % 16;hi = int(byte / 16)
    enx = enx "%" het[hi] het[lo]}}print enx}'

 # the prompt!
 echo "Interactive Ruby ready." 
 echo -n ">> " 
 while read cmd
    resp=""; ps=">>" 
    if [ -n "$cmd" ] ; then
        resp="$($wget --header "Cookie: _session_id=$sess" "$tryurl$(urlx "$cmd")")" 
        if [ -n "$resp" ] ; then
            echo $resp
    echo -n "$ps " 

Now if you want to play with hacking the Try Ruby prompt from the commandline, you don’t even hafta download the script. It’s easy as:

 sh -c "$(curl -s http://tryruby.hobix.com/try.sh)" 

I get email from guys who think this online Ruby interpreter is quite a risky business and I’m totally aware that a brilliant cracker will definitely break everything very soon. So I’m glad for the civility so far and I’m very okay with the risk. Now, enough. Please play.

Okay, now updated to check for wget first. Also, no home directory is required now.

said on 13 Dec 2005 at 21:41

I’m adventuring along the coast this month.

Aha! a clue!

East coast or West coast? (I’m guessing West)

said on 13 Dec 2005 at 21:51

What if he’s taken a European Holiday?

For all we know, he could be out there, right now, pining about Ruby on the Fjords.

said on 13 Dec 2005 at 21:55

Ahh, the magic of Unix command-line tools combined with some Ruby goodness. Love it!

said on 13 Dec 2005 at 22:11

Stop stealing my ideas! I was gonna make this! Now what am I going to do?!

said on 13 Dec 2005 at 22:49

You may want to use curl instead of wget. Some nix distros, such as say, OS X , don’t come with wget.

said on 13 Dec 2005 at 23:05

Your site was linked on /. as a plus 5… your Ruby site is excellent and appreciated (probably soon to be slashdotted).

I’ve forwarded the site to three of my other friends; you are to be commended, sir.

said on 13 Dec 2005 at 23:19

But what if I don’t have curl? I only have wget…

said on 13 Dec 2005 at 23:47

Moments later:

 sh -c "$(wget -q -O - http://tryruby.hobix.com/try.sh)" 
said on 14 Dec 2005 at 00:11

Simply brilliant!

said on 14 Dec 2005 at 09:20

<|:{: I read somewhere that he lives in the DC area.

But maybe you’re actively stalking him and were trying to determine his whereabouts at the moment. In which case I’ll spring his latest work, wherein you can run

sh -c "$(curl -s http://whygps.hobix.com/stalkme.rb)"

and have a Google Maps view of his current coordinates converted into ASCII art. Refer to the documentation for key shortcuts to steer his car. Please be careful with the forward/reverse keys, though, we want to go easy on his transmission.

said on 14 Dec 2005 at 09:43

I get email from guys who think this online Ruby interpreter is quite a risky business and I’m totally aware that a brilliant cracker will definitely break everything very soon.

if we care for such bad people too much, we become bad people ourselves. call me a hippie, but I think such lovely, naively open things as Try Ruby are the answer to all bad things in this world. you know, like war and terrorism and SQL injections.

said on 14 Dec 2005 at 10:36

As long as he isn’t running e-commerce applications and off-shore (I don’t know, for UK companies?) data centres on the same server…

said on 14 Dec 2005 at 13:39

Platte: Actually, It has been suggested that _why the lucky stiff is not a single individual, but is actually a persona made up of several individuals all acting in concert (sort of like a band). The proponents of this theory suggest that there is no way that one person can do all of the things that _why does (and now we find out that he actually goes on vacation too! Is there any end to the amazing feats?). Of those who hold to this theory, the most widely held belief is that _why is actually composed of three individuals – this is based on the fact that there are 3 letters in ‘why’ and each letter could be the first letter of each individual’s first name: thus you might have: Willie, Harry and Young (well, the last guy uses his last name, apparently and maybe the middle guy uses his middle name). If these believers are right, then why could live in DC and LA and EU all at the same time – ‘he’ almost would never be sleeping.

However, I for one am skeptical of claims that _why is a trinity of some sort. I think it is within the realm of possibility that why is one gifted individual who consumes large amounts of caffeine and thus doesn’t sleep much.

said on 14 Dec 2005 at 14:32

I’m best enjoyed with a slice of Glowing Cheddar.

said on 14 Dec 2005 at 16:48

I believe the current consensus is that _why is a Ruby hacker from the future, sent back in time by an aging Matz to perform an obscure and terrible mission in the world of today.

His home is the road, travelling with his trusty band The Thirsty Cups whose instruments double as laser weapons. They move from city to city, playing gigs whilst covertly battling the forces of darkness and boring programming languages.

His occasional absences can be therefore easily explained in terms of extended undercover missions, periodic trips to the future for new orders from Matz, and end-of-season cliffhangers.

said on 14 Dec 2005 at 18:23

I’m going to try disabling the blog and just running comments for a while. You guys supplant every post—what is it you’re building in here??

Believe me, despite locations, no matter where I am, I’m in the position of an injured crane over a shiny fliplid with a video screen. It’s a real letdown.

Comments are closed for this entry.