Is there any way of scrubbing notebooks pre-save? - visual-studio-code

I work with sensitive data and need my notebook to scrub the outputs of cells before saving. I know that this is possible in Jupyter notebooks, but is this also possible in VScode Jupyter?
Here's the link to the example in the Jupyter docs, where a scrub_output_pre_save function is written and inserted into the jupyter_notebook_config.py-file.
Thanks!

Related

PyPlot figure not shown in VS Code Jupyter "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure."

I run Julia inside Jupyter notebook within the Microsoft Visual Studio Code IDE.
When I try to make a PyPlot plot, the figure is not shown at and instead I am seeing the following message:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
The figure will be shown when a PyPlot.display_figs() line will be added at the end of the cell code (note that the display_figs method is not exported so it needs be prepended with PyPlot).
Note that I observe this happening from time to time on some VS Code installation so I publish here this workaround so other people can easily google it.

What is the best way to turn IPython Notebooks on Github to a blog?

I've some IPython notebooks which I maintain at GitHub. I would like to turn them into a blog. I would like to have a discussion area at the end of the notebooks so that readers can comment. I do not want users to be able to execute the codes directly on the site (it is enough if they can see the notebooks), if they want to execute, they can copy the codes and run on their own computers. If possible I do not want a separate copy of the notebooks, I would like to have a single copy for ease of maintenance. What is the best way (preferably a free way) to achieve this?
Thanks
Hamel Husain recently posted to the Jupyter discourse forum a very full-featured Jupyter blogging system hosted on GitHub Pages called fastpages. It seems well documented and state-of-the-art. It allows a comments section, see here.
It seems you want to export a static version of the notebooks? You can use a tool like nbconvert which according to its documentation:
allows you to convert a Jupyter .ipynb notebook document file into another static format including HTML, LaTeX, PDF, Markdown, reStructuredText, and more. nbconvert can also add productivity to your workflow when used to execute notebooks programmatically.
You can export in your desired format and add the remaining markup for commenting or other functionality.

VCS for Jupyter Notebooks in PyCharm

I'm wondering how to make PyCharm's VCS (i.e. Git) work with Jupyter Notebook files.
Changing even 1 loc results in 3 modifications detected during commit:
Sorry if it's a duplicate, but I haven't found anything similar.
Well, I wouldn't say that the current support of Jupyter Notebook files versioning doesn't work at all. You can see it on your own screenshot that your changes are detected.
We don't parse all of the changes to detect only the source code changes.
And even if we did, many people actually want to track the output because, for example, in data science, the results are not always reproducible and you may want to keep track of the output as well as src.
Although it can be enhanced with the implementation of the following functionality https://youtrack.jetbrains.com/issue/PY-20132 that would allow committing all of the changes, but see only changes of source code, so feel free to upvote and leave comments.
I use Pycharm Community edition. I love the way Pycharm integrates with git and its VCS shows the diffs visually. However, for jupyter notebook files, the diff is difficult to track visually. Running a cell introduces various changes.
Notebook files normally diff like text files. I use a simple method to enhance the visual quality. I created a new file type Settings>Editor>File Types for *.ipynb files. I enable matching for all types of brackets. I add few keywords,
Keyword 1:
"outputs"
"source"
Keyword 2:
"code"
"markdown"
This highlighted format shows up in the Pycharm VCS and enables us to easily locate changes in code and markdown cells and outputs. An example of this effect is shown in this screenshot. Now, we don't need to worry about changes in the execution count or meta data.

Convert iPython Notebook to copy-proof format (e.g. png)

I have a rather long iPython Notebook that I want my students to reproduce in class. I don't just want to give them a pdf or notebook file as they would just copy the text, which defeats the purpose...
Is there a way for me to convert the notebook into a huge png, or copy protected format (e.g. with right click forbidden)?
You can just make a fullsize screenshot of the notebook in the browser.
For Chrome it is possible with extensions or with builtin developer tools. Guide
Newer Firefox versions has it here

R-markdown .Rmd or knitr markdown in Jupyter

Is there a way to use .Rmd files directly in Jupyter? In other words, is there a way to get jupyter to render a file like this: https://github.com/yihui/knitr-examples/blob/master/023-engine-python.Rmd?
I love jupyter, but also like the simplicity of the .Rmd syntax.
You could use ipymd, which enables saving notebooks as Markdown documents instead of in Jupyter Notebook format. I don't know enough about knitr to say if there is feature-by-feature compatibility, but it seems like a good start.
Notedown is another possibility.
I created a fork of ipymd which allows to open .Rmd files directly in jupyter notebook.
As opposed to plain markdown, it also supports storing images in a separate .nb.html file.