Socat and ssh Tips for Jupyter Notebooks
by tomgdow
The Jupyter Notebook Project
The interactive computational environment of the Jupyter Notebook,  (where JuPyteR is a portmanteau of Julia, Python and R) now encompasses over 40 languages, including Ruby.
Only Julia, Python and Ruby are considered here.
For References, see here
Allow Public Access to a Jupyter Notebook running Remotely
A Jupyter notebook (Julia, Python or Ruby) may be accessed publicly using socat as follows:
Start the jupyter notebook on the remote server
jupyter notebook
» ... Jupyter Notebook is running at:http://localhost:9999/   *(abridged)
On the remote server, in a separate terminal window, execute:
socat TCP-LISTEN:8090,fork TCP:localhost:9999
Now all notebooks running under the Jupyter system will be publicly available at:
The Jupyter system may be password-protected
The default port for Jupyter on the current system is 9999. The port number in the socat command may need to be modified accordingly.
To start the Jupyter system on a different port, for example port 3000:
jupyter notebook --port=3000
Netcat may be used to check that all is well with the socat command
netcat -z -v localhost 8090  
» Connection to localhost 8090 port [tcp/*] succeeded!
Alternative Method with ssh Tunnel
The alternative method given here for allowing public access to a Ruby-on-Rails application  may also be applied to a Jupyter notebook
Securely Access a Jupyter Notebook Running Remotely with ssh
A Jupyter notebook running under localhost on a remote server may be securely accessed from a local machine as follows:
Start the Jupyter System on the remote server (port 9999)
jupyter notebook
On the local machine execute:
 ssh -N -f -L localhost:4000:localhost:9999 janedow@johndow.com
The Jupyter system will now be accessible from a local machine at:
A password will be required for ssh access to the remote machine.
janedow@johndow.com  are the user credentials on the server.
The default port for Jupyter on the current system is 9999. 
Log for the Creation of an iRuby Notebook on a Remote Server
An iRuby notebook running under the Jupyter system was created on a Digital Ocean Droplet with Ubuntu as OS
Some preliminaries. (remote server command line)
uname -ro; jupyter --version;python --version; ruby --version; julia --version;
» 3.13.0-57-generic GNU/Linux
» 4.0.6
» Python 2.7.11 :: Anaconda 2.5.0 (64-bit)
» ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
» julia version 0.4.5
The iRuby Jupyter notebook was created as follows:
# On the remote server
jupyter notebook
socat TCP-LISTEN:8090,fork TCP:localhost:9999  # (new terminal window)
# From any browser
# Create a new iRuby notebook (using pull-down menu) 
# The final result was something like the following:
iRuby Notebook running remotely on the Jupyter System
The full version of the above notebook, in non-interactive notebook viewer format, is available here as a github gist.
janedow@johndow.com  are the user credentials on the remote machine
Both the Jupyter  and iRuby will need to be installed on the remove server. Here, Jupyter (including iPython) was intalled using Anaconda (with Python 2.x).
The iRuby gem was installed from here
In order to create notbooks in Julia, this language must also be installed remotely.
An example of an iPython notebook, in notebook viewer format, is given here
An example of a Julia notebook, again in viewer format, may be found here
Local access over ssh
# On the remote system
juypter notebook 
# On the local machine:
ssh -N -f -L localhost:4000:localhost:9999 janedow@johndow.com
» janedow@johndow.com's password:
» C:\WINDOWS\system32>
# From browser on local machne
Share an Jupyter Notebook with Notebook Viewer
The 'raw' form of a Jupyter notebook is in JSON format,  and a link to a github gist or a pastebin gist of the JSON data  may be used at nbviewer.jupyter.org to create a publicly accessible form of the notebook
The viewer form of the notebook does not allow cell evaluation, but is otherwise fully interactive, and is in many cases ideal for sharing information.
A shared notebook may be created as follows (presented as log)
# The file 'tomgdowtips.ipynb' was opened in a text editor (Notepad++) and used to create a github gist(copy and paste)
# At nbviewer.jupyter.org, the gist id (b0d2f416858dec005b8966cba682932) was pasted into the input box, making the notebook available at nbviewer.jupyter.org/gist/tomGdow/b0d2f416858dec005b8966cba682932a
# As an alternative method, a pastebin gist was created and the link to the raw form of the data  (http://pastebin.com/raw/YDpavGU2) used as above to make the notebook publicly available at nbviewer.jupyter.org/url/pastebin.com/raw/YDpavGU2
Bezanson, J., Karpinskiy, S., Shah, V. B., & Edelman, A. (2012)  Julia: A Fast Dynamic Language for Technical Computing. Available at: http://arxiv.org/abs/1209.5145v1  [pdf]
Bezanson, J., Edelman, A., Karpinski, S. & Shah, V. B. (2014) Julia: A Fresh Approach to Numerical Computing. Available at: https://arxiv.org/abs/1411.1607 [pdf]
Shah, V. B. (2015). Get To Know JuliaLang - Guest Talk by Co-Inventor Viral Shah. Available at [video]: https://www.youtube.com/watch?v=OC3hsct63Ok
JuliaLang (2015) The Julia Language: A fresh approach  to technical computing. Available at (github repository): https://github.com/JuliaLang/julia