News for hackers. Stuff that matters.
Re:Codepad.org, a pastebin that executes code by wastedbrains on Wednesday March 05, 2008 @09:31AM (#129693)
I could see this being incredibly useful, there has been tons of code pasting, but it will make things a lot cleaner and simpler being able to check out fully functioning code while discussing the problem with someone.

Now all it needs is an embeddable widget and this would take over coding blogs and forums.

Re:Codepad.org, a pastebin that executes code by raju on Tuesday March 04, 2008 @09:47PM (#129417)
Very, very nice. Love it. I agree with paulgb, this is something I never thought I would ever find useful, but I can already see myself sharing code snippets with others.

I might be getting greedy, but how about syntax highlighting? Although CodePad is really cool. Bravo! Keep up the great work...

Re:Codepad.org, a pastebin that executes code by jey on Wednesday March 05, 2008 @12:05AM (#129475)
There are several pastebins with syntax highlighting: http://rafb.net/paste http://pastie.caboo.se http://pastebin.com/
Re:Codepad.org, a pastebin that executes code by thomasfl on Wednesday March 05, 2008 @04:02AM (#129576)
Codepad have syntax highligthing. At least for ruby http://codepad.org/i30lM3MM
Re:Codepad.org, a pastebin that executes code by bouncingsoul on Tuesday March 04, 2008 @09:18PM (#129398)
Suggestion: Since it's intended for code you should explicitly declare a monospaced font for the textarea. Safari uses a sans serif by default.
Re:Codepad.org, a pastebin that executes code by sah on Tuesday March 04, 2008 @09:30PM (#129405)
Will do. Thanks for pointing this out.
Re:Codepad.org, a pastebin that executes code by slackerIII on Tuesday March 04, 2008 @06:57PM (#129305)
Very cool stuff. How are you keeping the backend secure?

You should put up a page of the most popular code samples :) And of course, let people vote them up and down.

Re:Codepad.org, a pastebin that executes code by sah on Tuesday March 04, 2008 @07:18PM (#129319)
The basic strategy is to run untrusted code (including compilers) under ptrace to disallow a bunch of system calls. It's also chroot jailed, and subject to resource limits and a timeout. There are more details at http://codepad.org/about

Popular code samples are a good idea! I'll add that to the to-do list.

Re:Codepad.org, a pastebin that executes code by slackerIII on Tuesday March 04, 2008 @07:25PM (#129326)
Ah, thanks -- the about link is not so obvious with a really wide screen browser.

Since I think every single person is going to try to do something naughty to your system, a list of the most creative attempts to hack it would be cool too.

Re:Codepad.org, a pastebin that executes code by michaelneale on Tuesday March 04, 2008 @11:01PM (#129448)
Not a bad research idea.
Re:Codepad.org, a pastebin that executes code by bootload on Tuesday March 04, 2008 @11:11PM (#129455)
"... Codepad.org, a pastebin that executes code ..."

Very nice. Tried "import this" & "hello world in c". There is a poll over on arclanguage that asks if users want this type of functionality (hosted arc repl). I was surprised that more didn't want this type of feature to hack with Arc ~ "A hosted repl" : http://arclanguage.org/item?id=4070

Re:Codepad.org, a pastebin that executes code by vlad on Tuesday March 04, 2008 @09:53PM (#129420)
Really cool. I thought of something related yesterday, which would be a place where people could submit code to get comments and feedback from the community about how they would have coded something differently. It would be useful for both newbies, business people, experienced programmers, web programmers, and people who've known COBOL for 20 years and want to learn about new languages. And, for each program, someone could submit code that does the same thing in a different language, especially web languages. This is really awesome and would facilitate this very easily! A good way to learn the proper way to do something, especially with web languages that may change every major version, is by asking questions of experts in an IRC chat, and then watch them argue amongst each other about the best way to implement something. This would solve that problem by letting people browse, search, or reference a particular post or example or add on to it. I'm thinking of a wiki/social news/forum/code execution app.
Re:Codepad.org, a pastebin that executes code by staticshock on Tuesday March 04, 2008 @10:07PM (#129425)
the individual components of what you're talking about basically exist:

http://refactormycode.com/ - comments on people's code, discussions about refactoring

http://rosettacode.org/ - common pieces of code implemented in different languages

Re:Codepad.org, a pastebin that executes code by paulgb on Tuesday March 04, 2008 @06:35PM (#129284)
Cool. This is one of those things I didn't know I needed, but give it a week and I won't be able to live without it ;).
Re:Codepad.org, a pastebin that executes code by mixmax on Tuesday March 04, 2008 @10:52PM (#129443)
Welcome to hacker news.

Hope you stick around :-)

Re:Codepad.org, a pastebin that executes code by mikecotton on Tuesday March 04, 2008 @06:20PM (#129265)
This is sweet. So useful for getting help with code or showing someone how to do something.
Re:Codepad.org, a pastebin that executes code by derefr on Tuesday March 04, 2008 @09:47PM (#129418)
I somewhat implemented this idea before (but just with Ruby, so obviously a much smaller project.) At the time, one of my biggest to-dos was AJAX support, to allow two people (i.e. a teacher and student) to play with a piece of code together as if they were on the same machine, with either person being able to hit "re-run" at any time and both seeing the updated output. Then I started getting into the details of trying to create a shared interactive debugger, and it started to get out of my range of ability ;).

One suggestion for this, though, copied from something I did in my little project: provide another field (optional, perhaps hidden by default) for batch STDIN, so it doesn't crash on the sample here (a simple Ruby call to gets): http://codepad.org/xz0E5olm

Re:Codepad.org, a pastebin that executes code by tokipin on Wednesday March 05, 2008 @08:44AM (#129670)
Lua would be a nice and easy addition. in particular WoW uses it for its UI mods
Re:Codepad.org, a pastebin that executes code by tlrobinson on Wednesday March 05, 2008 @11:46PM (#130324)
How about some JavaScript support. Here's I'll help:

    document.write(eval(inputString));
Of course that lacks any sort of security measures...
Re:Codepad.org, a pastebin that executes code by thorax on Tuesday March 04, 2008 @10:07PM (#129424)
This reminds me a bit of that site Utility Mill, but, of course, that one is for long-term versioned Python code.

Nice work.

Re:Codepad.org, a pastebin that executes code by ghiotion on Tuesday March 04, 2008 @08:40PM (#129372)
No lisp? No arc? ;)

Seriously, that's really cool. I want to break it now.

Re:Codepad.org, a pastebin that executes code by sah on Tuesday March 04, 2008 @08:43PM (#129376)
It has scheme! (PLT, too, so I guess arc would be easy to add.)
Re:Codepad.org, a pastebin that executes code by andreyf on Wednesday March 05, 2008 @03:05PM (#129937)
Why not include a prettier editor?

http://www.cdolivet.net/editarea/

Or maybe open an API so that other people can extend it?

Re:Codepad.org, a pastebin that executes code by johnrob on Tuesday March 04, 2008 @08:19PM (#129354)
Timeout is working: http://codepad.org/nQQKVWfa
Re:Codepad.org, a pastebin that executes code by cnu on Thursday March 06, 2008 @01:47PM (#130721)
Re:Codepad.org, a pastebin that executes code by henning on Tuesday March 04, 2008 @06:58PM (#129307)
Darn, my code snippet to call system("rm -rf /") was met with some nonsense about forking disallowed.
Re:Codepad.org, a pastebin that executes code by sah on Tuesday March 04, 2008 @07:22PM (#129325)
Well, you could always skip forking: http://codepad.org/BThbEnMn
Re:Codepad.org, a pastebin that executes code by gcv on Wednesday March 05, 2008 @10:45AM (#129721)
So was mine with while(fork()); :)

Seriously, very very cool app!

Re:Codepad.org, a pastebin that executes code by andr on Tuesday March 04, 2008 @08:30PM (#129362)
I tried to write an infinite loop in C, but couldn't remember what I had to include. FAIL.
Re:Codepad.org, a pastebin that executes code by sah on Tuesday March 04, 2008 @08:42PM (#129374)
Re:Codepad.org, a pastebin that executes code by alus on Tuesday March 04, 2008 @06:45PM (#129297)
Re:Codepad.org, a pastebin that executes code by kilowatt on Tuesday March 04, 2008 @07:17PM (#129318)
you're doing it wrong

http://codepad.org/0COPIsn9

Re:Codepad.org, a pastebin that executes code by albertcardona on Tuesday March 04, 2008 @11:54PM (#129471)
http://codepad.org/H2wMdxsA

Didn't know this one about python. Thanks kilowatt.

By the way I can't "paste and run": Error 500 Internal Server Error. Looks like the site is popular as it gets (well deserved).

Re:Codepad.org, a pastebin that executes code by pageman on Wednesday March 05, 2008 @02:55PM (#129926)
Re:Codepad.org, a pastebin that executes code by pageman on Wednesday March 05, 2008 @02:54PM (#129924)
Re:Codepad.org, a pastebin that executes code by simianstyle on Wednesday March 05, 2008 @12:24AM (#129487)
Will there be any PHP support?
Re:Codepad.org, a pastebin that executes code by christefano on Wednesday March 05, 2008 @01:04AM (#129502)
If there were it would mean the end of codepad.org. Think of the security implications of allowing anyone to run PHP on their server.
Re:Codepad.org, a pastebin that executes code by rcoder on Wednesday March 05, 2008 @03:08PM (#129940)
Think of the security implications of allowing anyone to run any language on their server. It doesn't matter if it's PHP, Ruby, or C++, since they all allow shell and filesystem access, unbounded recursion, and all the other goodies that make sandboxing interesting.

The trick would be to run PHP as a command-line scripting language, just like the others.

Re:Codepad.org, a pastebin that executes code by davidw on Wednesday March 05, 2008 @11:38AM (#129749)
Afaik, the only (reasonably common) languages with good sandboxes are Tcl and Java. Like they said above, they're the ones building the sandbox, not the language.
Re:Codepad.org, a pastebin that executes code by LogicHoleFlaw on Wednesday March 05, 2008 @03:55PM (#129992)
Lua has excellent support for building sandboxes for untrusted user code.
Re:Codepad.org, a pastebin that executes code by davidw on Wednesday March 05, 2008 @04:54PM (#130039)
Interesting - but what do you mean 'building' sandboxes?
Re:Codepad.org, a pastebin that executes code by tokipin on Thursday March 06, 2008 @07:34AM (#130497)
i'm not exactly sure what he's talking about, but there's 2 things Lua has here. one is that the language is functional, so you can replace, alter, or remove the dangerous functions. the other is that you can specify the variable 'environment' of a function with a table (Lua's hash.) so you can construct its environment in an 'opt-in' basis and know for sure everything you're allowing the function to do is safe. and of course these things would be meaningless if built-in functions didn't behave like user functions
Re:Codepad.org, a pastebin that executes code by jamongkad on Thursday March 06, 2008 @10:57AM (#130594)
Upmodded and done for Lua.
Re:Codepad.org, a pastebin that executes code by immad on Wednesday March 05, 2008 @03:12PM (#129947)
You can map down a few languages to JVM executable bytecode, can't you?
Re:Codepad.org, a pastebin that executes code by aaroniba on Wednesday March 05, 2008 @08:08PM (#130173)
In what way does Java provide sandboxing of untrusted code?
Re:Codepad.org, a pastebin that executes code by wallflower on Wednesday March 05, 2008 @08:46PM (#130202)
Untrusted Java web start applications and Java applets can't do anything that could harm the real operating system. We had to buy and keep on renewing an expensive code-signing cert so our app could save a local file. Every once in a while, a security researcher claims to have gotten untrusted bytecode to run outside the boundaries of the sandbox.
Re:Codepad.org, a pastebin that executes code by jamongkad on Thursday March 06, 2008 @10:59AM (#130601)
Oh just quit it. You and I both know that PHP can be made to run safely in this type of environment.
Re:Codepad.org, a pastebin that executes code by tlrobinson on Wednesday March 05, 2008 @11:41PM (#130318)
I would be more worried about C... which this already runs (apparently securely)
Re:Codepad.org, a pastebin that executes code by jamongkad on Thursday March 06, 2008 @10:58AM (#130596)
Here here! why isn't there any PHP support?
Re:Codepad.org, a pastebin that executes code by sah on Thursday March 06, 2008 @11:13AM (#130609)
PHP is one of the most requested languages. Support is on the way, probably sometime in the next couple weeks.
Re:Codepad.org, a pastebin that executes code by tokipin on Wednesday March 05, 2008 @02:28PM (#129900)
a timer might be nice for comparing algorithms and languages
Re:Codepad.org, a pastebin that executes code by pageman on Wednesday March 05, 2008 @02:48PM (#129921)
I agree. Especially if you're solving and comparing projecteuler.net problems/solutions :)
Re:Codepad.org, a pastebin that executes code by jsmcgd on Wednesday March 05, 2008 @06:05AM (#129621)
Really cool. Well done!
Re:Codepad.org, a pastebin that executes code by newt0311 on Wednesday March 05, 2008 @01:15AM (#129509)
Awesome. Future suggestion (for python), add in some external modules like scipy. Then it would be possible to send examples of some of the more obscure modules. Really nice app.
Re:Codepad.org, a pastebin that executes code by miratom on Thursday March 06, 2008 @03:43PM (#130809)
c/c++ is broken. Doesn't support this:

int x = 4; x++; printf("x: %d\n",x);

How can you say you support c/c++ when you don't support ++?

Re:Codepad.org, a pastebin that executes code by sah on Thursday March 06, 2008 @10:08PM (#131017)
Re:Codepad.org, a pastebin that executes code by rms on Tuesday March 04, 2008 @08:34PM (#129369)
Upvoted!