Skip to content

Instantly share code, notes, and snippets.

View parente's full-sized avatar
🦡

Peter Parente parente

🦡
View GitHub Profile
@parente
parente / README.md
Last active November 30, 2022 04:44
Jupyter Tidbit: Kernels for text files in JupyterLab

Summary

You can associate a Console panel and kernel with a text editor in JupyterLab, and use it to execute selected code, RStudio style.

  1. Create or open a text source file in JupyterLab.
  2. Right click in the text editor panel.
  3. Click Create Console for Editor.
  4. Select a kernel matched to the programming language you want to execute in the file.
  5. Notice the Console panel that appears.
  6. Highlight one or more lines back in the text editor you'd like to run.
@parente
parente / README.md
Last active September 12, 2021 14:40
Jupyter Tidbit: Launch Notebook on Binder without leaving your browser

Summary

You can launch a temporary Jupyter Notebook server in the cloud with any pip or conda packaged libraries preinstalled using the GitHub Gist and Binder web UIs.

  1. Visit https://gist.github.com/.
  2. Click New Gist in the top right
  3. Enter requirements.txt as the filename (or environment.yaml if you prefer conda).
  4. Add libraries you wish to use in your notebook server (e.g., pandas, altair).
  5. Click Create Public Gist.
  6. Visit https://mybinder.org/.
@parente
parente / README.md
Last active December 26, 2023 14:31
Jupyter Tidbit: Use nbconvert to clear notebook outputs

Summary

nbconvert has a preprocessor that clears cell outputs from notebook files, leaving cell inputs intact.

Example

The following shell command reads my_input_notebook.ipynb, removes its cell outputs, prints the cleaned notebook to stdout, and redirects that output to a new notebook file named my_output_notebook.ipynb.

jupyter nbconvert my_input_notebook.ipynb --to notebook --ClearOutputPreprocessor.enabled=True --stdout > my_output_notebook.ipynb
@parente
parente / README.md
Last active August 23, 2018 13:16
Jupyter Tidbit: %run your ipynb file

Summary

The %run magic provided by IPython not only supports the execution of regular Python scripts, it also runs Jupyter Notebook files (.ipynb).

Example

Binder

The run_demo.ipynb notebook below uses %run to execute all of the cells in reusable_stuff.ipynb. Once it does, both globals defined in reusable_stuff are available in run_demo for use.

@parente
parente / README.md
Last active August 21, 2018 20:33
Null Binder

Binder

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.