Jupyterlab active scroll bars for long results - jupyter-notebook

I'm using Jupyterlab for my datascience studies. Everything is Ok with this new tool, but some process as GridSearchCV has long logs and this results pollutes the notebook. There is a way to active scroll bars to avoid this like in traditional Jupyter notebooks?

You have a few options:
Right click on cell's output -> "Enable Scrolling for Outputs". This will limit output view's height and enable scrolling, like in the classic notebook.
Right click on cell's output -> "Create New Output View". This will create a separate scrollable view and dock it to the bottom of the screen. You can then collapse the view in the main window so it doesn't clutter the notebook.

there is an automatic way to do this. First, you must install the addon "Stylus" (available on both Chrome and Firefox). This addon allows you to write custom CSS on websites.
Next, go to your JupyterLab page at localhost:8888/lab and click on the Stylus icon in the top right, and click "Write style for this URL"
Under the URL, i changed localhost to localhost:8888/lab. Then, I copied in this script by user Buckle2000 from Github (https://github.com/jupyterlab/jupyterlab/issues/4028#issuecomment-446820575)
.jp-OutputArea-child {
max-height: 15em;
}
.jp-OutputArea-child .jp-OutputArea-output {
overflow: auto;
}
Then click the Save button, and you should be good to go. I believe you can change the number 15 to make it activate for different heights. It should look like this:

If you are not interested in the output, you can use cell magic capture. It captures cell output and doesn't display them.

Related

Preventing markdown cells from un-rendering (Jupyter): showEditorForReadOnlyMarkdow

following this post and the issues tab regarding this problem I have found that to make a cell that is set to "editable":false not be able to be un-rendered I need to set showEditorForReadOnlyMarkdown to false.
It is not clear to me how to actualy do this, and how to make it permanant.
This is what I have tried so far:
I have found that throught Jupyter-Lab I can go to settings->advanced settings editor->JSON Settings Editor and change this setting, but the change is permanant only for My Jupyter-Lab environment -- opening up the notebook elsewhere will not save this setting.
Setting "showEditorForReadOnlyMarkdown":false in the cell or notebook metadata via a local jupyter notebook doesnt do anything.
Ultimatley, as the notebooks I am making are for learning purposes, I would like all cells that are uneditable to be permanantly rendered as to minimize issues and/or confusion.
Any help will be appreciated. Thank you.
For any others looking for the currently available per-Jupyter-lab setting that Iddo mentions above, to do it through the GUI it's "Settings" -> "JSON Settings Editor" (icon at top-right of initial Settings tab), then it's found in "Notebook" near the bottom (this is in JupyterLab 3.6.0). I couldn't edit it in place, not sure if that was just me, but could add to the User Preferences box on the right, e.g.:
{
"showEditorForReadOnlyMarkdown" : false
}
One way it can be done programmatically is by creating/modifying this overrides json file to hold:
{
"#jupyterlab/notebook-extension:tracker": {
"showEditorForReadOnlyMarkdown" : false
}
}
(This not an answer to the question, but I can't "comment" due to not having enough reputation points, so had to put this here as an "Answer" ¯\_(ツ)_/¯)

How to collapse a Java code cell (made in Jupyter Notebook) on a website with Jekyll blog posts?

I have a blogging website using fastpages, which allows me to create Jekyll posts, along with posts created with Jupyter Notebook.
I'm creating a Jupyter Notebook post in VS Code that is using the Java kernel and want to hide a Java code cell.
The fastpages README says that you can hide a code cell with #collapse at the top of the code cell, while its blog website says that you can use #collapse-hide.
I tried both of these options on my code cell, but when I run them, it says illegal character: '#'
I think the issue might be that #collapse-hide might only work for Python cells, but I'm pretty lost when searching for the problem.
The Jupyter Notebook documentation says that you can hide code cells with
{
"tags": [
"hide-input",
]
}
but I do not know where to put this metadata in.
On that page, there is also a link to a cell tags guide. I tried Step 1 (by clicking View -> Cell Toolbar -> Tags), but after clicking the Tabs button, I do not know what to do. I also tried going to View -> Cell Toolbar -> Edit Metadata, but when I paste the metadata above, it says Could not save invalid JSON
(by the way, I am using Jupyter Notebook on my localhost now, not VS Code)
I tried removing the curly braces from the metadata (because I think the curly braces would be for if I only paste the metadata and there isn't the other stuff (like "vscode": {...?), but the same error occurs.
I don't know how to code in JSON, I would just like to be able to hide my code cell on my website, like this:
I do not even know if I am heading in the right direction. Basically, I would like to know: how can I hide my Java code cell?

Jupyter notebook markdown without mouse click

For markdown there is a shortcut like typing a number(1,2,3,4..) in command mode (Esc) and then giving an Enter
The thing is that your cursor gets before the "###" (if you used 3) where you also need to click the End key to be able to write.
Is there a way to overcome the last action as it is very annoying.
What you already have is a one click solution, which is going to be hard to beat. The only improvement I can think of is to override the functionality that's inserting the markdown headings for you. You could extend it to also place the cell in edit mode and move the cursor to the end. This would be placed in your custom.js file, which you place here: ~/.jupyter/custom/custom.js.

Hide the cell tag panel in Jupyter Notebook

Jupyter notebook has a new feature of cell tags since version 5.0 as described in the changelog.
I activated the cell tags going to View > Cell Toolbar as described on their page.
How can I deactivate this little panel on the cells?
Pressing the same button again doesn't help.
Do the same process but this time just click None
If last answer did not help, you also can edit .ipynb file code. in Jupyter - Home-running- stop your file, after that go to the explorer- click right bottom on your_file.ipynb open with notebook(just like .txt) - scroll down, find raw with "celltoolbar": "None", and delete this and save file, after run file in jupyter.

Customize Applescript app icon

I have created my AppleScript, tested it, saved it as an .app and it works.
Now, how do I set a custom icon for it?
I have done a bit of googling and tried a few different things but cannot get it to work. The app is mainly for me and maybe some people I know to make workflows easier so having a nice little icon makes a huge difference.
Can anyone help with this please?
Basically you need an .icns icon file.
Open your application with right-click > Show Package Contents
Navigate to Contents > Resources
Delete applet.icns
Drag the custom icon file into the Resources folder
Rename the icon file in Resources to applet.icns
To update the icon appearance open and re-save the applet in Script Editor.
This is how I do it:
In Finder, select your icon file.
Get Info (CMD-I) on the file.
Click the icon in the top left corner of the Get Info window.
Copy it via CMD-C.
Now Get Info on your AppleScript file.
Click the icon in the top left corner of the Get Info window.
Paste the icon using CMD-V.
The AppleScript icon should be replaced by the icon copied from the icon file.
A screen recording demonstrating this process can be viewed at this answer from AskDifferent.
Just building into #pipwerks answers: You can also use Drag&Drop!
(Optional) Create your icon online from any image on https://iconverticons.com/online/ and download de .icns file for your icon.
Get Info (CMD-I) on you AppleScript file.
Now Drag&Drop your .icns file into the small icon in the top left corner.
It works and now it's ready to add it to the dock or wherever you want.
On newer systems if the above methods do not work there is another solution.
In Script Editor, after opening our script (.app), choose View -> Show Bundle Contents from the menu (or press cmd +0).
In the panel that will expand on the right (Bundle Info) in the Resources section, right-click the applet.icns file and select delete from the drop-down menu.
Our new icon file with the same name applet.icns drag and drop into the window Resources where you just deleted it.
Save application and voila :-D
Here's another way on newer systems, I'm using macOS 12.1.
Open the new icon image file in Preview and choose File > Export...
Hold down the Option key while selecting "Format" and see a whole bunch of new choices including ICNS.
Save it, drop it in your Resources folder, and you're good to go.

Resources