CodeCube: Docker-powered Runnable Gists
hmarr.comI'm currently building a platform for students to learn programming where you can join a "classroom" and watch the other students (or teachers) editors. My first idea was also to post the code to the server and then compile,run it and send the output back. The problem with this method is that there can't be any interactivity in your code, like it is with CodeCube. I think of such things like in C scanf(). So for now every user that joins gets a ubuntu linux box which is provided by docker. So I'm using term.js and pty.js which spawns this minimalistic box and connects /bin/bash via websocket to the client. The code the client writes in his editor can now have scanfs and other interactive functions and is compiled and executed in his own little shell.
This is actually something I'd quite like to do with CodeCube - it wouldn't be hard at all. Replace SSE with websockets, attach to the container's stdin as well as stdout, add something like term.js, and it'd work a treat.
This is such an excellent use of Docker (and golang) ! I really wish this was integrated into Github so that you could run Github gists in your browser.
How is it better than ideone.com?
For one, it's much faster. CodeCube also streams the output to the browser. Also, CodeCube is open source (https://github.com/hmarr/codecube).