The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rubyless Ruby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Rubyless Ruby Posted: Dec 13, 2005 7:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Rubyless Ruby
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

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!

 #!/bin/sh
 tryurl="http://tryruby.hobix.com/irb?cmd=" 
 wget="curl -s -b $HOME/.tryruby -c $HOME/.tryruby" 
 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
 do
    resp=""; ps=">>" 
    if [ -n "$cmd" ] ; then
        resp="$($wget "$tryurl$(urlx "$cmd")")" 
        ps=".." 
        if [ -n "$resp" ] ; then
            echo $resp
            ps=">>" 
        fi
    fi
    echo -n "$ps " 
 done

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.

Read: Rubyless Ruby

Topic: Is Resier4 a Bust? Previous Topic   Next Topic Topic: Returning to Firefox

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use