Skip to content

Instantly share code, notes, and snippets.

View rafidka's full-sized avatar

Rafid K. rafidka

View GitHub Profile
@rafidka
rafidka / start-remote-jupyter-notebook.sh
Last active December 26, 2019 23:53
Execute a script on a remote machine that starts a Jupyter notebook, and then bind the local port to it. See https://gist.github.com/rafidka/a764fa910428141bfc00aeea087af3a5
cat jupyter.sh
SERVER=myserver.com # you need to update to your server DNS or IP address.
ssh $SERVER '~/jupyter/start.sh'
ssh -N -f -L localhost:9001:localhost:9001 rafidka.aka.corp.amazon.com
open http://localhost:9001
@rafidka
rafidka / start-jupyter-notebook.sh
Last active December 26, 2019 23:54
Run Jupyter notebook as a background process, redirecting stdout and stderr to files
echo Check whether Jupyter Notebook is already running...
# You need to update the path in this line to point to where your jupyter-notebook lives.
ps aux | grep '/home/rafidka/.pyenv/versions/3.6.8/bin/jupyter-notebook' | grep -vq grep
if [ $? -eq 1 ]; then
echo 'Jupyter Notebook is NOT running; starting it in a background process...'
curr_path=`pwd`
mkdir -p notes
cd notes
jupyter notebook --no-browser --port=9001 > $curr_path/stdout.txt 2>$curr_path/stderr.txt &
cd $curr_path
Date.parseWcfDate = function(str) {
var regex = str.match(/\/Date\(([0-9]+)([-+])([0-9]+)\)\//);
var millisecs = parseInt(regex[1]);
var offset = parseFloat(regex[2] + regex[3]) / 100;
var utcMillsecs = millisecs + offset * 3600 * 1000;
return new Date(utcMillsecs);
};