Run jupyter notebook in incognito window - ipython

On executing the command jupyter notebook, notebook opens on Mozilla Firefox.
How to open notebook on incognito mode of Mozilla Firefox from command line?

In your config add the following to set the default browser to a private firefox (adapted from here and parameters from there):
jupyter_notebook_config.py
[...]
## Specify what command to use to invoke a web browser when opening the notebook.
# If not specified, the default browser will be determined by the `webbrowser`
# standard library module, which allows setting of the BROWSER environment
# variable to override it.
import webbrowser
webbrowser.register('private_firefox', None, webbrowser.get('"' + 'path/to/firefox' +'" -private %s'))
c.NotebookApp.browser = 'private_firefox'
[...]
where path/to/firefox would be something like one of these
/usr/bin/firefox for Linux (see here)
/Applications/Firefox.app/Contents/MacOS/firefox for macOS (see this)
C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe for Windows (as described here)
note:
Other browsers like Chrome ("...\\chrome.exe" --incognitoas in the source) would work analogously, I suppose. I have not tested others. Feel free to comment, if there are any hurdles.

Typically Jupyer opens on http://localhost:8888 all you need to do is copy that url and open it yourself in an incognito Firefox session.

On Safari, if the focus is on an incognito window, the notebook will open automatically in it.

Related

Live Server does not open in Chrome on Windows 11 and WSL2

I am working in WSL2 on Windows 11 trying to run an index.js file with Live Server. Whenever I open Live Server it seems that I can only do so when I use Microsoft Edge. This seems to add another layer of problems because the JavaScript does not seem to be working as I would expect. For example, if I click a button element I don't see any animations to signify a "click".
I have checked that "liveServer.settings.CustomBrowser": "chrome" is indeed reflectin Chrome in the VS Code settings, but when this is the case there are no windows that pop up at all. The only thing that I see trigger is a notification that tells me that the server is active on Port 5000, just no window popping up to demonstrate that. Ideally I would like to try and open Live Server with Chrome, but if this isn't possible in Windows 11 then is there a way to make JavaScript behave in Microsoft Edge?
I've the same configuration and the same issue. I've raised the issue #2445 in Github.
A workaround solution is to call directly your chrome program installed under windows to your liveserver setting.
check that chrome is well installed on W10 or W11. You can test it by opening a command line and running "start chrome", then chrome browser must open.
look for chrome' installed directory. You can use this command to find it: sudo find /mnt/c/ -type f -iname chrome.exe 2>&1 | grep -v "Permission denied". For me this it's here:mnt/c/Program Files/Google/Chrome/Application.chrome.exe.
Now change liveserver setting on your settings.json file:
{
"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe --remote-debugging-port=9222",
}
Now chrome should start when you run liverserver.
Hope this help

How do I use Safari as my browser for debugging when using Visual Studio Code running an Angular app?

I have an Angular app (.Net Core backend). I can create configurations in the launch.json file and debug with Firefox, Chrome, Edge, etc. But I don't see any option for Safari!
QUESTION - How do I create a configuration for Safari to use instead of Chrome when launching the debugger? When I click 'add configuration' in launch.json, which option do I select for Safari? Do I need a separate extension?
I found some links for you:
https://stackoverflow.com/a/51738121
https://stackoverflow.com/a/66942204
Set the BROWSER environment variable before executing the start command may help.
This environment variable is documented here: https://create-react-app.dev/docs/advanced-configuration/
By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a browser to override this behavior, or set it to none to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to npm start will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the .js extension.

VS Code with WSL now opens the browser.sh file instead of launching the browser

The problem: when running a React project (i.e. npm run start) with WSL from the terminal in VS Code, the file "browser.sh" is opened in a new window. The browser is no longer launched.
This is a new behavior with version 1.52. The release notes indicate that they now add the system variable "BROWSER" and use it to launch the browser. In my case it is set to /home/dan/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin/helpers/browser.sh
The browser.sh file is a shell script created by VS Code. It exists and has executable permissions (-rwxr-xr-x).
The workaround: Type unset BROWSER every time a terminal is opened inside VS Code.
The desired solution: Convince VS Code to run the shell script or to launch the default browser directly.

How to open a file in vscode under wsl using the vscode:// url?

I would like to open a file in vscode under WSL (Windows Subsystem Linux) using the vscode:// url.
You can do it with a normal file in the usual filesystem vscode://file/c:/myProject/package.json
It is clearly explained in the documentation
I would like to open a file which is located in WSL, so to have something like this
vscode://file/home/user/myProject/package.json
But It does not work !
It does not work to use the complete path in windows as it does not start the WSL vscode
vscode://file/C:\Users\john\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gqsdeaz4\LocalState\rootfs/home/user/myProject/package.json
You can use the following scheme vscode://file//wsl$/Ubuntu-18.04
In your case it will be vscode://file//wsl$/Ubuntu-18.04/home/user/myProject/package.json
But unfortunately file is opened in a new window.
Please see https://github.com/microsoft/vscode/issues/99691
To open a remote window, don't use file but vscode-remote.
Please try vscode://vscode-remote/wsl+distro+name/path/to/file
Source: Opening VS Code with URLs doesn't work with \wsl$ urls

start ipython notebook with a particular (not default) firefox profile

When I launch ipython notebook, I want it to launch firefox but using a particular firefox profile, which is not my default firefox profile.
In my ipython profile, I have
c.NotebookApp.browser = u'/usr/bin/firefox'
and that makes sure that ipython notebook chooses firefox. However, it chooses the default firefox profile, or else the most recently used firefox profile.
From my linux terminal, I can launch my preferred ipython specific firefox profile (named ipython) like this
firefox -P --no-remote ipython
However, doing
c.NotebookApp.browser = u'/usr/bin/firefox -P --no-remote ipython'
does not work at all (ipython doesn't open firefox at all, and skips to the another browswer'), nor does starting ipython notebook like so
ipython notebook --browser 'firefox -P --no-remote ipython'
which leads to and OSError exception.
Does anyone know of a way to launch firefox with the preferred profile?
A little ugly but maybe better than nothing. I put the following into a shell script to launch firefox and ipython separately but at the same time i.e.
firefox -P ipython -no-remote
ipython notebook --no-browser
You will need to refresh the browser.
My solution uses a script to start firefox with the requested profile and makes Jupyter call it.
Create a script in e.g. /usr/local/bin/firefox-notebook with the following content:
!/bin/env sh
firefox -P notebook $#
Instruct Jupyter to use that script as a browser by adding the following in your jupyter_notebook_config.py:
import webbrowser
browser = webbrowser.Mozilla('firefox-notebook')
webbrowser.register('firefox-notebook', None, browser)
c.NotebookApp.browser = 'firefox-notebook'
You can simply add c.NotebookApp.browser = 'firefox -P notebook --new-window %s' to ~/.jupyter/jupyter_notebook_config.py. (You missed the %s. It will be replaced by the URL at which jupyter is served.)