Skip to content

Instantly share code, notes, and snippets.

@doowon
doowon / jupyter_systemd
Created July 22, 2016 20:14
A systemd script for jupyter
# After Ubuntu 16.04, Systemd becomes the default.
# It is simler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/usr/local/bin/jupyter notebook --no-browser --config=/home/jail/home/notebook/.jupyter/jupyter_notebook_config.py
@doowon
doowon / jupyter_notebook_noneditable_markdown.js
Created July 22, 2016 20:11
Never allow markdown cells to be editable.
// When a cell is clicked and the cell's mode is changed to the edit mode
// Then, this below event is called.
$([IPython.events]).on("edit_mode.Cell", function () {
if (IPython.notebook.get_selected_cell().cell_type == "markdown") {
IPython.notebook.execute_selected_cells();
}
});
@doowon
doowon / pythonexporter.py
Created July 22, 2016 05:00
nbconvert Python exporter example
import nbformat
from nbconvert import PythonExporter
exporter = PythonExporter()
(source, meta) = exporter.from_filename('something.ipynb')
# When NB object is used.
#with open('something.ipynb', 'r') as infile:
#nb = nbformat.reads(infile.read(), nbformat.NO_CONVERT)
#(source, meta) = exporter.from_notebook_node(nb)
@doowon
doowon / jupyter
Last active October 15, 2023 17:46 — forked from jmtatsch/jupyter
A service (init.d) script for jupyter
#! /bin/sh
### BEGIN INIT INFO
# Provides: jupyter
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start jupyter
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.