Try Ruby, the Batch File
May
9th
21:40
I love this! Raggi has reduced Try Ruby into a 682 byte batch file for Windows.
@echo tryurl="http://tryruby.hobix.com/irb?cmd=";function wget(url,hdrs){var http=WScript.CreateObject("Microsoft.XMLHTTP");http.open("GET",url,false);for(var k in hdrs){http.setRequestHeader(k,hdrs[k]);};http.send("");return http.responseText;}sess=wget(tryurl+escape("!INIT!IRB!"),{});WScript.Echo("Interactive Ruby ready. (send ^D to exit)");WScript.StdOut.Write(">> ");WScript.StdIn.Read(0);while(true){cmd=WScript.StdIn.ReadLine();resp="";ps=">> ";if(cmd=="\004")break;if(cmd){resp=wget(tryurl+escape(cmd).replace('+','%2B'),{'Cookie': '_session_id='+sess});ps="..";if(resp){WScript.StdOut.Write(resp);ps=">>";}}WScript.StdOut.Write(ps+" ");}>t.js @cscript//Nologo t.js&del t.js
Toss try.bat and try.sh on a USB stick and you’ve got a cross-platform Ruby console in just a few K. Next up: the DS Lite??
acrylic
A small patch for
try.sh
:patches
There’s been some updates–two bug fixes both affecting the escaping of the “+”. The first was a mistake I made not paying attention to the escaping of the % character.
The second was a bug in the original .js source, where ‘+’ needs to be replaced by ‘/\+/g’ in order to support statements with more than one ‘+’ operator.
Some limited more details here: ruby for windows in under 700 bytes
patches double post
Did I mention it’s down to 640 bytes? ;-)
Comments are closed for this entry.