updated live.codenode.org to be running of a v8 engine on the latex branch

8 views
Skip to first unread message

James Casbon

unread,
Nov 16, 2010, 4:41:01 AM11/16/10
to codenod...@googlegroups.com
Hi Codenode,

When we relaunched the live.codenode.org service a while back, it was
running python engines. Unfortunately, python is very hard to lock
down and therefore a few people came up with valid ways of hacking
into the server. I had been aware that this was possible but hoped
that we could attract people to deal with that problem.
Unfortunately, no-one wanted to grasp the nettle, so I couldn't really
continue running off pure python. My second attempt was to run off
picloud which worked OK but was subject to massive latency which could
range from seconds to minutes. I tried using picloud real time
compute units, but they are priced in blocks of ten which is not
appropriate for a low use service.

I therefore resurrected a v8 engine, which works through the pyv8
bindings. This is much more likely to be secure, since in v8 you can
only see things that have been specifically injected into the context.
Unfortunately, there are not that many javascript libraries for doing
interesting programming (if you know of any do let me know so I can
add them to the context). However, pyv8 allows you to inject python
objects into the context and I have used this to inject R code. So we
now have the unholy alliance of javascript based R, bound by python.
It does work, but the two major pains are named arguments and the use
of +,-,/,* etc. Named arguments can work through providing a {} as
the last positional arguments, but I have to provide methods such as
add,mul,div,sub to get add two vectors/

At the moment, I have exposed base, stats, datasets and ggplot from R
so you can do this:
"""
var plot = ggplot.ggplot(datasets.mtcars);
plot = ggplot.add(plot, ggplot.aes_string({'x': 'hp', 'y': 'mpg',
'colour': 'hp', 'size': 'wt'}));
plot = ggplot.add(plot, ggplot.geom_point());
print(plot);
"""
and get a nice image of the relationship between horsepower and mpg.
(notice we have to use ggplot.add instead of '+' to add the plot
components).

I am also running live off my latex branch. If you enter this into a cell:
"""
Some maths
==========

some inline maths \( e^{i\pi} + 1 = 0 \) and then a block equation
$$ \sum_{i=1}^n {n \choose i } \frac{1}{x^{i}} $$
"""
And then you need to change the cell type to markdown by right
clicking. Evaluate and you should see the markdown header and the
maths rendered in latex.

There are a *lot* of issues with the javascript (especially saving
loading with latex in); but I just wanted to get this out there. My
next task would be to change the DOM model of the cells from a tree to
a list, which would really simplify a lot of the frontend code and
help eliminate a lot of these issues.

James

Reply all
Reply to author
Forward
0 new messages