News for hackers. Stuff that matters.
Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ... by pyre on Friday September 30, 2011 @11:44AM (#3057398)
Oops:

  > import subprocess
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/lib/python2.7/subprocess.py", line 429, in <module>
      import select
  ImportError: No module named select

Also:

  > os.name
  => 'posix'
  > os.uname()
  => ('Emscripten', 'emscripten', '1.0', '#1', 'x86-JS')
  > os.environ
  => {'LANG': 'en_US.UTF-8', 'PYTHONHOME': '/:/', 'PWD': '/',
  'USER': 'root', 'HOME': '/', 'PATH': '/', '_': './this.program'}
  > os.getcwd()
  => '/sandbox'
  > os.chdir('/')
  > os.getcwd()
  => '/'
  > os.popen2('ls -l')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/lib/python2.7/os.py", line 667, in popen2
      import subprocess
    File "/lib/python2.7/subprocess.py", line 429, in <module>
      import select
  ImportError: No module named select
  > os.popen('ls -l')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  OSError: [Errno 24] Too many open files
* I liked the 'x86-JS' as the architecture.

* I know about os.listdir() but I wanted the permissions.

* I automatically did a ^W to delete a word and closed the tab. I don't feel like opening it again or I would probably have more.

* I realize that since this is a CPython -> JS converter that the REPL is running in my browser and no on a server (AFAIK) so it's not like this attempting to hack someone's server, but I found it interesting to probe the environment.

Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ... by max99x on Friday September 30, 2011 @11:49AM (#3057418)
Thanks for trying it out.

* The ^W is fixable, but I'm not sure how I personally feel about hijacking fundamental browser shortcuts. We'll look into it though.

* Regarding the environment, in general, multi-threading and multi-processing (and anything that depends on them) are not supported, since Emscripten translates the code to JS rather than emulating a machine.

* The Emscripten virtual filesystem has a simple single-user permission model and the libc functions for accessing/modifying the permissions are supported. So technically you could get the permissions through os.access. Not as convenient as ls, of course, but doable.

Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ... by pyre on Friday September 30, 2011 @07:53PM (#3058946)
I will note that when copying the text out of the interpreter, the prompt (>) doesn't copy (I assume that you may be using a CSS :after or :before decorator, though I didn't look). Sometimes even the newline itself didn't copy. For that post I had to cleanup all of the text so that it would display properly. This may be an issue you want to look at if you want to support people copy/pasting stuff that they are working on out of the console (or you may just want to add a button that generates a Github gist or pastebin entry and displays a link to it).
Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ... by max99x on Friday September 30, 2011 @08:07PM (#3058975)
The prompt label is an image, hence it's not copyable. We experimented a bit with various copy-friendly approaches, but couldn't find anything that was cross-browser and did not damage the look/layout we were going for. To share a session, click the save button on the top right - it'll generate a shareable link with the editor content and the whole REPL session in replayable form.