
Show HN: Nodebook – Multi-Lang Web REPL on Docker - netgusto
https://github.com/netgusto/nodebook
======
netgusto
I came up with Nodebook while training for coding interviews.

I wrote this because I wanted to work in the kind of environment used for
these interviews, namely an editor in a browser, and I needed a quick way to
browse and run my snippets when preparing. That, and procrastination.

There's also the possibility to watch code and run it in the shell directly,
without browser UI.

I use it these days when I need to do quick experiments or POC. I think it can
be of many other uses.

~~~
pjmlp
It looks nice, thanks for sharing it.

------
fenollp
From a quick look this looks like a subset of what
[https://repl.it/](https://repl.it/) provides (which is fine!).

Any features / wild ideas you feel deserve more attention than a quick look?

~~~
netgusto
It does indeed look like repl.it!

I'd say the main feature is owning the code you write (on your filesystem)
which allows your scm on top of it.

Also, the cli mode (watch and run), which does not expose a web ui, and is
nice in combination with tmux and vim.

If I ever get the chance to do it:

* Markdown file support

* Integration in vscode as a code runner

* Use Monaco (potentially with code insights) instead of Code Mirror

------
mattsfrey
It would go a long way to package this such that somebody on a mac can just
download it and run, or install with brew. Also after disabling security,
chmoding +x, and attempting several patterns on the command line I could not
get this to run, each time spitting various errors i.e. "Could not find
notebooks in .: Error while looking for notebooks: skip this directory",
"Could not find notebooks in /Users/mfrey: Error while looking for notebooks:
open /Users/mfrey/Library/Application Support/CallHistoryDB: operation not
permitted" etc.. maybe I'm just an idiot but at this point of dysfunction in a
program I'm experimenting with for kicks, my capacity to continue futzing with
it is exhausted, just FYI.

~~~
talkingtab
As a long time mac user, I suggest getting access to a Linux machine and even
learning how to use it if necessary. If you use the mac terminal its not all
that hard. Options are:

\- get a DigitalOcean or other cheap VPN. $5 or less/month with easy ssh
access. Be sure to set up ufw just for fun.

\- have an old mac? install Ubuntu 19.10 and be surprised at how fast and
usable it is. My 2011 Macbook pro is amazing with an external monitor.

\- buy a cheap machine. I would suggest a Pi 4 with 4GB and have one, but
since the architecture is ARM it sometimes is a hassle. Maybe someone has a
suggestion for a low cost linux server box.

edit: I forgot the main point- if you want to play around with a lot of cool
stuff, like this, much of it is linux by default so having a linux box is
perhaps a good long term solution. I use brew, but for me these are better
solutions.

~~~
em500
Or install multipass, which installs ubuntu containers inside a ubuntu kvm on
your Mac: [https://multipass.run/](https://multipass.run/)

------
joshstrange
Hmm, this is very interesting. Currently I use CodeRunner on my mac to do this
kind of one-offs but I rarely save them. It's mainly an easily way for me to
test out a theory on how some code will behave in an isolated environment. I
would be interested in this if it could run itself inside a docker container
as well so I could easily throw it on my NAS. I guess I could just run it in a
VM but...

~~~
netgusto
> if it could run itself inside a docker container

It could be done by running the snippet containers in the same docker host as
the one running nodebook (by exposing the host's docker socket to the nodebook
container). Is this what you have in mind?

~~~
joshstrange
Yes, I was thinking docker-in-docker was probably the answer to that. Or a
single docker container with all runtimes installed in it so you didn't have
to deal with the DiD overhead. Hell, I could probably just throw it into a
docker with just node/php/java (since that is my main use-case) and call it a
day.

------
asah
I'm curious about security... On one hand it's running inside a container?
OTOH, there's no key/password required for clients to connect i.e. any local
software can connect?

For remote access, perhaps an SSH tunnel?

~~~
netgusto
The api listens on 127.0.0.1 by default; so yes, local software can connect
(see [1]).

File pathes for read/writes and execution are not imperatively ordered by the
client, but done declaratively based on the notebook ID.

When the toolschains are in docker, the code runs in disposable containers.

It would be possible to add creds (for instance, with creds stored in
~/.nodebook.conf); do you think it's mandatory?

The cli mode (--cli) does not expose a port, but watches notebooks and outputs
them in the terminal (works nicely with $YOUR_EDITOR)

\--edit--

I guess running this on a remote server through SSH tunnel would workyes, but
I think it's safer and easier to version control the notebooks and run them
locally.

[1] [https://github.com/netgusto/nodebook#%EF%B8%8F-a-bit-of-
warn...](https://github.com/netgusto/nodebook#%EF%B8%8F-a-bit-of-
warning-%EF%B8%8F)

~~~
mbreese
One mechanism I’ve seen (Jupyter) is to print out a token when the listening
service (Webserver) starts. Then this is the credential needed to login to the
web GUI. The token is randomly generated at runtime and unique to each time
the server restarts.

It would be expected that you’re running this on a computer you already
control access to (remote server that you access with an SSH tunnel or a
personal workstation). In this case, the token approach is a nice medium
between full user accounts and ease of use while still providing some
security.

~~~
netgusto
Oh yes I see, it’s indeed a nice in between. I will do that, like it! Thank
you.

