[ create a new paste ] login | about
What it is
codepad.org is an online compiler/interpreter, and a simple collaboration tool. It's a pastebin that executes code for you. You paste your code, and codepad runs it and gives you a short URL you can use to share it. Paste the URL into chat or email to get help or to show someone how to do something. Or just try things out when you don't have an interpreter handy. It works well on many phones.

codepad was written (and still is being written!) by Steven Hazel. Please contact me at sah@codepad.org if you have any problems or feature requests. I'll add new languages if they're frequently requested (or if I just like them).

Note: codepad works like a compiler or interpreter, not like the read-eval-print loop of an interactive interpreter prompt. If you want to print the value of an expression, you need to use your language's print command. If your language requires a "main" function, your program won't work in codepad without one.

How it works
Code execution is handled by a supervisor based on geordi. The strategy is to run everything under ptrace, with many system calls disallowed or ignored. Compilers and final executables are both executed in a chroot jail, with strict resource limits. The supervisor is written in Haskell.

The web site is written in Python, using Pylons and SQLAlchemy.

Can you break it?
You're welcome to try. Let me know if you have any success!
Paranoia
When your app is remote code execution, you have to expect security problems. Rather than rely on just the chroot and ptrace supervisor, I've taken some additional precautions:
Following
Follow me on twitter: @sahazel.

Lately I spend most of my time on my Selenium testing company, Sauce Labs. If you're testing your web app with Selenium, you should check it out.

I also have a blog at www.hackerdashery.com where I'll be posting updates about codepad, along with other random observations and ideas about software and startups.

Contributions
In the process of adding Tcl support, I wrote a Pygments lexer for Tcl. You can get it in the latest version of Pygments, or here: TclLexer.py.
Compiler and interpreter versions
Here are the compilers and interpreters codepad uses to execute code:

C: gcc 4.1.2
flags: -O -fmessage-length=0 -fno-merge-constants -fstrict-aliasing -fstack-protector-all

C++: g++ 4.1.2
flags: -O -std=c++98 -pedantic-errors -Wfatal-errors -Werror -Wall -Wextra -Wno-missing-field-initializers -Wwrite-strings -Wno-deprecated -Wno-unused -Wno-non-virtual-dtor -Wno-variadic-macros -fmessage-length=0 -ftemplate-depth-128 -fno-merge-constants -fno-nonansi-builtins -fno-gnu-keywords -fno-elide-constructors -fstrict-aliasing -fstack-protector-all -Winvalid-pch

D: Digital Mars D Compiler v1.026

Haskell: Hugs, September 2006
flags: -98

Lua: Lua 5.1.3

OCaml: Objective Caml version 3.10.1

PHP: PHP 5.2.5

Perl: Perl v5.8.0

Python: Python 2.5.1

Ruby: Ruby 1.8.6

Scheme: MzScheme v372 [cgc]

Tcl: tclsh 8.4.16

Copyright Contact Information

If you are the copyright owner of a paste and feel it has been uploaded without your permission, you may file a DMCA Complaint via email to sah@codepad.org