{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Resources\n", "My multi-kernel jupyter docker image: https://hub.docker.com/r/fzinfz/anaconda3/\n", "\n", "Opinionated stacks: https://github.com/jupyter/docker-stacks \n", "multi-user Hub: https://github.com/jupyterhub/jupyterhub \n", "\n", "Run python online \n", "http://repl.it/languages/Python \n", "http://repl.it/languages/Python3 \n", "(Noteļ¼š http://repl.it can run nearly any language) \n", "\n", "News: \n", "[As of July 2016 the Anaconda Build system is deprecated](https://docs.continuum.io/anaconda-cloud/build)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Server Setup\n", "http://jupyter-notebook.readthedocs.io/en/latest/public_server.html " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "jupyter notebook --generate-config\n", "\n", "vi ~/.jupyter/jupyter_notebook_config.py # c.NotebookApp.password\n", "\n", "jupyter console # start the ZMQ-based console\n", "jupyter console --existing # If no argument specified, guess most recent" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# conda env" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "anaconda login\n", "anaconda whoami\n", "conda create --name=py27 python=2.7\n", "conda create --name py35 --clone root\n", "conda remove --name py35 --all\n", "conda env export > py35.yml\n", "conda env create -f py35.yml\n", "\n", "conda env upload --file=py35.yml\n", "\n", "conda info\n", "\n", "conda env list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# ipykernel \n", "http://ipython.readthedocs.io/en/stable/install/kernel_install.html" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "jupyter-kernelspec list" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "python3 -m pip install ipykernel\n", "python3 -m ipykernel install --user\n", "\n", "python2 -m pip install ipykernel\n", "python2 -m ipykernel install --user" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# virtualenv" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "yum install python34-setuptools\n", "easy_install-3.4 pip\n", "\n", "virtualenv ENV \n", "cd ENV \n", "source ./bin/activate \n", "deactivate" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# nbconvert" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "pandoc deb: https://github.com/jgm/pandoc/releases/ \n", "`jupyter nbconvert --to rst notebook*.ipynb`\n", "\n", "http://nbsphinx.readthedocs.io/en/readthedocs-theme/usage.html#HTML-Themes\n", "\n", "`pip install sphinx_rtd_theme`\n", "\n", "In your conf.py file:\n", "```\n", "import sphinx_rtd_theme\n", "html_theme = \"sphinx_rtd_theme\"\n", "html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Copyright (c) Jupyter Development Team.\n", "from jupyter_core.paths import jupyter_data_dir\n", "import subprocess\n", "import os\n", "import errno\n", "import stat\n", "\n", "PEM_FILE = os.path.join(jupyter_data_dir(), 'notebook.pem')\n", "\n", "c = get_config()\n", "c.NotebookApp.ip = os.getenv('INTERFACE', '') or '*'\n", "c.NotebookApp.port = int(os.getenv('PORT', '') or 8888)\n", "c.NotebookApp.open_browser = False\n", "\n", "# Set a certificate if USE_HTTPS is set to any value\n", "if 'USE_HTTPS' in os.environ:\n", " if not os.path.isfile(PEM_FILE):\n", " # Ensure PEM_FILE directory exists\n", " dir_name = os.path.dirname(PEM_FILE)\n", " try:\n", " os.makedirs(dir_name)\n", " except OSError as exc: # Python >2.5\n", " if exc.errno == errno.EEXIST and os.path.isdir(dir_name):\n", " pass\n", " else: raise\n", " # Generate a certificate if one doesn't exist on disk\n", " subprocess.check_call(['openssl', 'req', '-new', \n", " '-newkey', 'rsa:2048', '-days', '365', '-nodes', '-x509',\n", " '-subj', '/C=XX/ST=XX/L=XX/O=generated/CN=generated',\n", " '-keyout', PEM_FILE, '-out', PEM_FILE])\n", " # Restrict access to PEM_FILE\n", " os.chmod(PEM_FILE, stat.S_IRUSR | stat.S_IWUSR)\n", " c.NotebookApp.certfile = PEM_FILE\n", "\n", "# Set a password if PASSWORD is set\n", "if 'PASSWORD' in os.environ:\n", " from IPython.lib import passwd\n", " c.NotebookApp.password = passwd(os.environ['PASSWORD'])\n", " del os.environ['PASSWORD']" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "# Configuration file for jupyter-notebook.\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# Configurable configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# LoggingConfigurable configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# A parent class for Configurables that log.\r\n", "# \r\n", "# Subclasses have a log trait, and the default behavior is to get the logger\r\n", "# from the currently running Application.\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# SingletonConfigurable configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# A configurable that only allows one instance.\r\n", "# \r\n", "# This class is for classes that should only have one instance of itself or\r\n", "# *any* subclass. To create and retrieve such a class use the\r\n", "# :meth:`SingletonConfigurable.instance` method.\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# Application configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# This is an application.\r\n", "\r\n", "# The date format used by logging formatters for %(asctime)s\r\n", "# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'\r\n", "\r\n", "# The Logging format template\r\n", "# c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'\r\n", "\r\n", "# Set the log level by value or name.\r\n", "# c.Application.log_level = 30\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# JupyterApp configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Base class for Jupyter applications\r\n", "\r\n", "# Answer yes to any prompts.\r\n", "# c.JupyterApp.answer_yes = False\r\n", "\r\n", "# Full path of a config file.\r\n", "# c.JupyterApp.config_file = ''\r\n", "\r\n", "# Specify a config file to load.\r\n", "# c.JupyterApp.config_file_name = ''\r\n", "\r\n", "# Generate default config file.\r\n", "# c.JupyterApp.generate_config = False\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# NotebookApp configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Set the Access-Control-Allow-Credentials: true header\r\n", "# c.NotebookApp.allow_credentials = False\r\n", "\r\n", "# Set the Access-Control-Allow-Origin header\r\n", "# \r\n", "# Use '*' to allow any origin to access your server.\r\n", "# \r\n", "# Takes precedence over allow_origin_pat.\r\n", "# c.NotebookApp.allow_origin = ''\r\n", "\r\n", "# Use a regular expression for the Access-Control-Allow-Origin header\r\n", "# \r\n", "# Requests from an origin matching the expression will get replies with:\r\n", "# \r\n", "# Access-Control-Allow-Origin: origin\r\n", "# \r\n", "# where `origin` is the origin of the request.\r\n", "# \r\n", "# Ignored if allow_origin is set.\r\n", "# c.NotebookApp.allow_origin_pat = ''\r\n", "\r\n", "# DEPRECATED use base_url\r\n", "# c.NotebookApp.base_project_url = '/'\r\n", "\r\n", "# The base URL for the notebook server.\r\n", "# \r\n", "# Leading and trailing slashes can be omitted, and will automatically be added.\r\n", "# c.NotebookApp.base_url = '/'\r\n", "\r\n", "# Specify what command to use to invoke a web browser when opening the notebook.\r\n", "# If not specified, the default browser will be determined by the `webbrowser`\r\n", "# standard library module, which allows setting of the BROWSER environment\r\n", "# variable to override it.\r\n", "# c.NotebookApp.browser = ''\r\n", "\r\n", "# The full path to an SSL/TLS certificate file.\r\n", "# c.NotebookApp.certfile = '/root/la1.tracert.win/cert.pem'\r\n", "\r\n", "# The full path to a certificate authority certifificate for SSL/TLS client\r\n", "# authentication.\r\n", "# c.NotebookApp.client_ca = ''\r\n", "\r\n", "# The config manager class to use\r\n", "# c.NotebookApp.config_manager_class = 'notebook.services.config.manager.ConfigManager'\r\n", "\r\n", "# The notebook manager class to use.\r\n", "# c.NotebookApp.contents_manager_class = 'notebook.services.contents.filemanager.FileContentsManager'\r\n", "\r\n", "# Extra keyword arguments to pass to `set_secure_cookie`. See tornado's\r\n", "# set_secure_cookie docs for details.\r\n", "# c.NotebookApp.cookie_options = {}\r\n", "\r\n", "# The random bytes used to secure cookies. By default this is a new random\r\n", "# number every time you start the Notebook. Set it to a value in a config file\r\n", "# to enable logins to persist across server sessions.\r\n", "# \r\n", "# Note: Cookie secrets should be kept private, do not share config files with\r\n", "# cookie_secret stored in plaintext (you can read the value from a file).\r\n", "# c.NotebookApp.cookie_secret = b''\r\n", "\r\n", "# The file where the cookie secret is stored.\r\n", "# c.NotebookApp.cookie_secret_file = ''\r\n", "\r\n", "# The default URL to redirect to from `/`\r\n", "# c.NotebookApp.default_url = '/tree'\r\n", "\r\n", "# Whether to enable MathJax for typesetting math/TeX\r\n", "# \r\n", "# MathJax is the javascript library Jupyter uses to render math/LaTeX. It is\r\n", "# very large, so you may want to disable it if you have a slow internet\r\n", "# connection, or for offline use of the notebook.\r\n", "# \r\n", "# When disabled, equations etc. will appear as their untransformed TeX source.\r\n", "# c.NotebookApp.enable_mathjax = True\r\n", "\r\n", "# extra paths to look for Javascript notebook extensions\r\n", "# c.NotebookApp.extra_nbextensions_path = []\r\n", "\r\n", "# Extra paths to search for serving static files.\r\n", "# \r\n", "# This allows adding javascript/css to be available from the notebook server\r\n", "# machine, or overriding individual files in the IPython\r\n", "# c.NotebookApp.extra_static_paths = []\r\n", "\r\n", "# Extra paths to search for serving jinja templates.\r\n", "# \r\n", "# Can be used to override templates from notebook.templates.\r\n", "# c.NotebookApp.extra_template_paths = []\r\n", "\r\n", "# \r\n", "# c.NotebookApp.file_to_run = ''\r\n", "\r\n", "# Use minified JS file or not, mainly use during dev to avoid JS recompilation\r\n", "# c.NotebookApp.ignore_minified_js = False\r\n", "\r\n", "# (bytes/sec) Maximum rate at which messages can be sent on iopub before they\r\n", "# are limited.\r\n", "# c.NotebookApp.iopub_data_rate_limit = 0\r\n", "\r\n", "# (msg/sec) Maximum rate at which messages can be sent on iopub before they are\r\n", "# limited.\r\n", "# c.NotebookApp.iopub_msg_rate_limit = 0\r\n", "\r\n", "# The IP address the notebook server will listen on.\r\n", "c.NotebookApp.ip = '*'\r\n", "\r\n", "# Supply extra arguments that will be passed to Jinja environment.\r\n", "# c.NotebookApp.jinja_environment_options = {}\r\n", "\r\n", "# Extra variables to supply to jinja templates when rendering.\r\n", "# c.NotebookApp.jinja_template_vars = {}\r\n", "\r\n", "# The kernel manager class to use.\r\n", "# c.NotebookApp.kernel_manager_class = 'notebook.services.kernels.kernelmanager.MappingKernelManager'\r\n", "\r\n", "# The kernel spec manager class to use. Should be a subclass of\r\n", "# `jupyter_client.kernelspec.KernelSpecManager`.\r\n", "# \r\n", "# The Api of KernelSpecManager is provisional and might change without warning\r\n", "# between this version of Jupyter and the next stable one.\r\n", "# c.NotebookApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager'\r\n", "\r\n", "# The full path to a private key file for usage with SSL/TLS.\r\n", "# c.NotebookApp.keyfile = ''\r\n", "\r\n", "# The login handler class to use.\r\n", "# c.NotebookApp.login_handler_class = 'notebook.auth.login.LoginHandler'\r\n", "\r\n", "# The logout handler class to use.\r\n", "# c.NotebookApp.logout_handler_class = 'notebook.auth.logout.LogoutHandler'\r\n", "\r\n", "# The url for MathJax.js.\r\n", "# c.NotebookApp.mathjax_url = ''\r\n", "\r\n", "# Dict of Python modules to load as notebook server extensions.Entry values can\r\n", "# be used to enable and disable the loading ofthe extensions.\r\n", "# c.NotebookApp.nbserver_extensions = {}\r\n", "\r\n", "# The directory to use for notebooks and kernels.\r\n", "# c.NotebookApp.notebook_dir = ''\r\n", "\r\n", "# Whether to open in a browser after starting. The specific browser used is\r\n", "# platform dependent and determined by the python standard library `webbrowser`\r\n", "# module, unless it is overridden using the --browser (NotebookApp.browser)\r\n", "# configuration option.\r\n", "c.NotebookApp.open_browser = False \r\n", "\r\n", "# Hashed password to use for web authentication.\r\n", "# \r\n", "# To generate, type in a python/IPython shell:\r\n", "# \r\n", "# from notebook.auth import passwd; passwd()\r\n", "# \r\n", "# The string should be of the form type:salt:hashed-password.\r\n", "# c.NotebookApp.password = ''\r\n", "c.NotebookApp.password = u'sha1:7b4e52f968e6:0c3232c8408fa2e9ec5f3a202181bbd5956e9c83'\r\n", "\r\n", "# The port the notebook server will listen on.\r\n", "# c.NotebookApp.port = 8888\r\n", "\r\n", "# The number of additional ports to try if the specified port is not available.\r\n", "# c.NotebookApp.port_retries = 50\r\n", "\r\n", "# DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.\r\n", "# c.NotebookApp.pylab = 'disabled'\r\n", "\r\n", "# (sec) Time window used to check the message and data rate limits.\r\n", "# c.NotebookApp.rate_limit_window = 1.0\r\n", "\r\n", "# Reraise exceptions encountered loading server extensions?\r\n", "# c.NotebookApp.reraise_server_extension_failures = False\r\n", "\r\n", "# DEPRECATED use the nbserver_extensions dict instead\r\n", "# c.NotebookApp.server_extensions = []\r\n", "\r\n", "# The session manager class to use.\r\n", "# c.NotebookApp.session_manager_class = 'notebook.services.sessions.sessionmanager.SessionManager'\r\n", "\r\n", "# Supply SSL options for the tornado HTTPServer. See the tornado docs for\r\n", "# details.\r\n", "# c.NotebookApp.ssl_options = {}\r\n", "\r\n", "# Supply overrides for the tornado.web.Application that the Jupyter notebook\r\n", "# uses.\r\n", "# c.NotebookApp.tornado_settings = {}\r\n", "\r\n", "# Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-\r\n", "# For headerssent by the upstream reverse proxy. Necessary if the proxy handles\r\n", "# SSL\r\n", "# c.NotebookApp.trust_xheaders = False\r\n", "\r\n", "# DEPRECATED, use tornado_settings\r\n", "# c.NotebookApp.webapp_settings = {}\r\n", "\r\n", "# The base URL for websockets, if it differs from the HTTP server (hint: it\r\n", "# almost certainly doesn't).\r\n", "# \r\n", "# Should be in the form of an HTTP origin: ws[s]://hostname[:port]\r\n", "# c.NotebookApp.websocket_url = ''\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# ConnectionFileMixin configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Mixin for configurable classes that work with connection files\r\n", "\r\n", "# JSON file in which to store connection info [default: kernel-.json]\r\n", "# \r\n", "# This file will contain the IP, ports, and authentication key needed to connect\r\n", "# clients to this kernel. By default, this file will be created in the security\r\n", "# dir of the current profile, but can be specified by absolute path.\r\n", "# c.ConnectionFileMixin.connection_file = ''\r\n", "\r\n", "# set the control (ROUTER) port [default: random]\r\n", "# c.ConnectionFileMixin.control_port = 0\r\n", "\r\n", "# set the heartbeat port [default: random]\r\n", "# c.ConnectionFileMixin.hb_port = 0\r\n", "\r\n", "# set the iopub (PUB) port [default: random]\r\n", "# c.ConnectionFileMixin.iopub_port = 0\r\n", "\r\n", "# Set the kernel's IP address [default localhost]. If the IP address is\r\n", "# something other than localhost, then Consoles on other machines will be able\r\n", "# to connect to the Kernel, so be careful!\r\n", "# c.ConnectionFileMixin.ip = ''\r\n", "\r\n", "# set the shell (ROUTER) port [default: random]\r\n", "# c.ConnectionFileMixin.shell_port = 0\r\n", "\r\n", "# set the stdin (ROUTER) port [default: random]\r\n", "# c.ConnectionFileMixin.stdin_port = 0\r\n", "\r\n", "# \r\n", "# c.ConnectionFileMixin.transport = 'tcp'\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# KernelManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Manages a single kernel in a subprocess on this host.\r\n", "# \r\n", "# This version starts kernels with Popen.\r\n", "\r\n", "# Should we autorestart the kernel if it dies.\r\n", "# c.KernelManager.autorestart = True\r\n", "\r\n", "# DEPRECATED: Use kernel_name instead.\r\n", "# \r\n", "# The Popen Command to launch the kernel. Override this if you have a custom\r\n", "# kernel. If kernel_cmd is specified in a configuration file, Jupyter does not\r\n", "# pass any arguments to the kernel, because it cannot make any assumptions about\r\n", "# the arguments that the kernel understands. In particular, this means that the\r\n", "# kernel does not receive the option --debug if it given on the Jupyter command\r\n", "# line.\r\n", "# c.KernelManager.kernel_cmd = []\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# Session configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Object for handling serialization and sending of messages.\r\n", "# \r\n", "# The Session object handles building messages and sending them with ZMQ sockets\r\n", "# or ZMQStream objects. Objects can communicate with each other over the\r\n", "# network via Session objects, and only need to work with the dict-based IPython\r\n", "# message spec. The Session will handle serialization/deserialization, security,\r\n", "# and metadata.\r\n", "# \r\n", "# Sessions support configurable serialization via packer/unpacker traits, and\r\n", "# signing with HMAC digests via the key/keyfile traits.\r\n", "# \r\n", "# Parameters ----------\r\n", "# \r\n", "# debug : bool\r\n", "# whether to trigger extra debugging statements\r\n", "# packer/unpacker : str : 'json', 'pickle' or import_string\r\n", "# importstrings for methods to serialize message parts. If just\r\n", "# 'json' or 'pickle', predefined JSON and pickle packers will be used.\r\n", "# Otherwise, the entire importstring must be used.\r\n", "# \r\n", "# The functions must accept at least valid JSON input, and output *bytes*.\r\n", "# \r\n", "# For example, to use msgpack:\r\n", "# packer = 'msgpack.packb', unpacker='msgpack.unpackb'\r\n", "# pack/unpack : callables\r\n", "# You can also set the pack/unpack callables for serialization directly.\r\n", "# session : bytes\r\n", "# the ID of this Session object. The default is to generate a new UUID.\r\n", "# username : unicode\r\n", "# username added to message headers. The default is to ask the OS.\r\n", "# key : bytes\r\n", "# The key used to initialize an HMAC signature. If unset, messages\r\n", "# will not be signed or checked.\r\n", "# keyfile : filepath\r\n", "# The file containing a key. If this is set, `key` will be initialized\r\n", "# to the contents of the file.\r\n", "\r\n", "# Threshold (in bytes) beyond which an object's buffer should be extracted to\r\n", "# avoid pickling.\r\n", "# c.Session.buffer_threshold = 1024\r\n", "\r\n", "# Whether to check PID to protect against calls after fork.\r\n", "# \r\n", "# This check can be disabled if fork-safety is handled elsewhere.\r\n", "# c.Session.check_pid = True\r\n", "\r\n", "# Threshold (in bytes) beyond which a buffer should be sent without copying.\r\n", "# c.Session.copy_threshold = 65536\r\n", "\r\n", "# Debug output in the Session\r\n", "# c.Session.debug = False\r\n", "\r\n", "# The maximum number of digests to remember.\r\n", "# \r\n", "# The digest history will be culled when it exceeds this value.\r\n", "# c.Session.digest_history_size = 65536\r\n", "\r\n", "# The maximum number of items for a container to be introspected for custom\r\n", "# serialization. Containers larger than this are pickled outright.\r\n", "# c.Session.item_threshold = 64\r\n", "\r\n", "# execution key, for signing messages.\r\n", "# c.Session.key = b''\r\n", "\r\n", "# path to file containing execution key.\r\n", "# c.Session.keyfile = ''\r\n", "\r\n", "# Metadata dictionary, which serves as the default top-level metadata dict for\r\n", "# each message.\r\n", "# c.Session.metadata = {}\r\n", "\r\n", "# The name of the packer for serializing messages. Should be one of 'json',\r\n", "# 'pickle', or an import name for a custom callable serializer.\r\n", "# c.Session.packer = 'json'\r\n", "\r\n", "# The UUID identifying this session.\r\n", "# c.Session.session = ''\r\n", "\r\n", "# The digest scheme used to construct the message signatures. Must have the form\r\n", "# 'hmac-HASH'.\r\n", "# c.Session.signature_scheme = 'hmac-sha256'\r\n", "\r\n", "# The name of the unpacker for unserializing messages. Only used with custom\r\n", "# functions for `packer`.\r\n", "# c.Session.unpacker = 'json'\r\n", "\r\n", "# Username for the Session. Default is your system username.\r\n", "# c.Session.username = 'root'\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# MultiKernelManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# A class for managing multiple kernels.\r\n", "\r\n", "# The name of the default kernel to start\r\n", "# c.MultiKernelManager.default_kernel_name = 'python3'\r\n", "\r\n", "# The kernel manager class. This is configurable to allow subclassing of the\r\n", "# KernelManager for customized behavior.\r\n", "# c.MultiKernelManager.kernel_manager_class = 'jupyter_client.ioloop.IOLoopKernelManager'\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# MappingKernelManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# A KernelManager that handles notebook mapping and HTTP error handling\r\n", "\r\n", "# \r\n", "# c.MappingKernelManager.root_dir = ''\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# ContentsManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Base class for serving files and directories.\r\n", "# \r\n", "# This serves any text or binary file, as well as directories, with special\r\n", "# handling for JSON notebook documents.\r\n", "# \r\n", "# Most APIs take a path argument, which is always an API-style unicode path, and\r\n", "# always refers to a directory.\r\n", "# \r\n", "# - unicode, not url-escaped\r\n", "# - '/'-separated\r\n", "# - leading and trailing '/' will be stripped\r\n", "# - if unspecified, path defaults to '',\r\n", "# indicating the root path.\r\n", "\r\n", "# \r\n", "# c.ContentsManager.checkpoints = None\r\n", "\r\n", "# \r\n", "# c.ContentsManager.checkpoints_class = 'notebook.services.contents.checkpoints.Checkpoints'\r\n", "\r\n", "# \r\n", "# c.ContentsManager.checkpoints_kwargs = {}\r\n", "\r\n", "# Glob patterns to hide in file and directory listings.\r\n", "# c.ContentsManager.hide_globs = ['__pycache__', '*.pyc', '*.pyo', '.DS_Store', '*.so', '*.dylib', '*~']\r\n", "\r\n", "# Python callable or importstring thereof\r\n", "# \r\n", "# To be called on a contents model prior to save.\r\n", "# \r\n", "# This can be used to process the structure, such as removing notebook outputs\r\n", "# or other side effects that should not be saved.\r\n", "# \r\n", "# It will be called as (all arguments passed by keyword)::\r\n", "# \r\n", "# hook(path=path, model=model, contents_manager=self)\r\n", "# \r\n", "# - model: the model to be saved. Includes file contents.\r\n", "# Modifying this dict will affect the file that is stored.\r\n", "# - path: the API path of the save destination\r\n", "# - contents_manager: this ContentsManager instance\r\n", "# c.ContentsManager.pre_save_hook = None\r\n", "\r\n", "# The base name used when creating untitled directories.\r\n", "# c.ContentsManager.untitled_directory = 'Untitled Folder'\r\n", "\r\n", "# The base name used when creating untitled files.\r\n", "# c.ContentsManager.untitled_file = 'untitled'\r\n", "\r\n", "# The base name used when creating untitled notebooks.\r\n", "# c.ContentsManager.untitled_notebook = 'Untitled'\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# FileManagerMixin configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Mixin for ContentsAPI classes that interact with the filesystem.\r\n", "# \r\n", "# Provides facilities for reading, writing, and copying both notebooks and\r\n", "# generic files.\r\n", "# \r\n", "# Shared by FileContentsManager and FileCheckpoints.\r\n", "# \r\n", "# Note ---- Classes using this mixin must provide the following attributes:\r\n", "# \r\n", "# root_dir : unicode\r\n", "# A directory against against which API-style paths are to be resolved.\r\n", "# \r\n", "# log : logging.Logger\r\n", "\r\n", "# By default notebooks are saved on disk on a temporary file and then if\r\n", "# succefully written, it replaces the old ones. This procedure, namely\r\n", "# 'atomic_writing', causes some bugs on file system whitout operation order\r\n", "# enforcement (like some networked fs). If set to False, the new notebook is\r\n", "# written directly on the old one which could fail (eg: full filesystem or quota\r\n", "# )\r\n", "# c.FileManagerMixin.use_atomic_writing = True\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# FileContentsManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# Python callable or importstring thereof\r\n", "# \r\n", "# to be called on the path of a file just saved.\r\n", "# \r\n", "# This can be used to process the file on disk, such as converting the notebook\r\n", "# to a script or HTML via nbconvert.\r\n", "# \r\n", "# It will be called as (all arguments passed by keyword)::\r\n", "# \r\n", "# hook(os_path=os_path, model=model, contents_manager=instance)\r\n", "# \r\n", "# - path: the filesystem path to the file just written - model: the model\r\n", "# representing the file - contents_manager: this ContentsManager instance\r\n", "# c.FileContentsManager.post_save_hook = None\r\n", "\r\n", "# \r\n", "# c.FileContentsManager.root_dir = ''\r\n", "\r\n", "# DEPRECATED, use post_save_hook. Will be removed in Notebook 5.0\r\n", "# c.FileContentsManager.save_script = False\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# NotebookNotary configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# A class for computing and verifying notebook signatures.\r\n", "\r\n", "# The hashing algorithm used to sign notebooks.\r\n", "# c.NotebookNotary.algorithm = 'sha256'\r\n", "\r\n", "# The number of notebook signatures to cache. When the number of signatures\r\n", "# exceeds this value, the oldest 25% of signatures will be culled.\r\n", "# c.NotebookNotary.cache_size = 65535\r\n", "\r\n", "# The sqlite file in which to store notebook signatures. By default, this will\r\n", "# be in your Jupyter runtime directory. You can set it to ':memory:' to disable\r\n", "# sqlite writing to the filesystem.\r\n", "# c.NotebookNotary.db_file = ''\r\n", "\r\n", "# The secret key with which notebooks are signed.\r\n", "# c.NotebookNotary.secret = b''\r\n", "\r\n", "# The file where the secret key is stored.\r\n", "# c.NotebookNotary.secret_file = ''\r\n", "\r\n", "#------------------------------------------------------------------------------\r\n", "# KernelSpecManager configuration\r\n", "#------------------------------------------------------------------------------\r\n", "\r\n", "# If there is no Python kernelspec registered and the IPython kernel is\r\n", "# available, ensure it is added to the spec list.\r\n", "# c.KernelSpecManager.ensure_native_kernel = True\r\n", "\r\n", "# The kernel spec class. This is configurable to allow subclassing of the\r\n", "# KernelSpecManager for customized behavior.\r\n", "# c.KernelSpecManager.kernel_spec_class = 'jupyter_client.kernelspec.KernelSpec'\r\n", "\r\n", "# Whitelist of allowed kernel names.\r\n", "# \r\n", "# By default, all installed kernels are allowed.\r\n", "# c.KernelSpecManager.whitelist = set()\r\n" ] } ], "source": [ "cat ~/.jupyter/jupyter_notebook_config.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "---\n", "\n", "# Manually HTTPS + Password setup\n", "```\n", "echo 'password: jupyterpwd'\n", "echo pwd=sha1:189ab089e50b:56e8bf072e6a2df681337bb631c6d5206dd5bd59 > jupyter_env.conf\n", "export cert_folder=/path/to/https/certificates/\n", "docker run --name nb -p 443:8888 --env-file jupyter_env.conf -v $cert_folder:/root/cert/ -v ~:/root/host -it fzinfz/anaconda3 /bin/bash\n", "```\n", "### run jupyter in container\n", "```\n", "jupyter notebook --ip=* --NotebookApp.password=$pwd --certfile=/root/cert/cert1.pem --keyfile=/root/cert/privkey1.pem\n", "```\n", "detach: CTRL-p + CTRL-q\n", "### generate your own password\n", "```\n", "from notebook.auth.security import *\n", "passwd('jupyterpwd')\n", "passwd_check('sha1:189ab089e50b:56e8bf072e6a2df681337bb631c6d5206dd5bd59','jupyterpwd')\n", "```" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 0 }