How can I get a IPython NotebookApp to be started and still manage it from outside of a browser? - ipython

It is possible to start a notebook app within an ipython console by
from IPython.html import notebookapp
nbapp = notebookapp.NotebookApp()
nbapp.initialize()
nbapp.start()
This will simply open a browser with a dashboard from which is possible to create/delete and start/shutdown notebooks. However nbapp.start() hooks up to tornado http server and it is not possible to use the instance nbapp to manage the notebooks from the console.
Some level of management can be done before executing the method nbapp.start(), but I couldn't find a way to start a proper notebook(linked to a new ipython kernel) page which can be read and edited from a web browser.
By taking a look at the start method in NotebookApp class, it seems that all the magic is done by the following method call
ioloop.IOLoop.instance().start()
This is the link for what I am refering to.
https://github.com/ipython/ipython/blob/master/IPython/html/notebookapp.py#L824
ioloop is imported at the beginning of the file and I didn't quite understand what this actually do.
# Install the pyzmq ioloop. This has to be done before anything else from
# tornado is imported.
from zmq.eventloop import ioloop
ioloop.install()
I was wondering if there was a way to start the server just the way it is working now, and send requests to it, as it works on a click of a mouse on the dashboard.
Or even better, have full access to the nbapp instance to create and start notebooks in the server.
Hope someone can help me with that, I would love to better understand how the ipython notebook work at the back stage.
Cheers

Related

Vs Code Issue: no code output. how do i fix this?

I am very new to coding and am trying to write a practice script for webscraping in VS Code Editor. But every time i run the script i get this issue of there being no real output. Can you please advise on what the issue is? Note: the pink boxes are just covering my nameenter image description here
I tried running the code and expected webscraped data from the link. I have tried many different scripts and the same issue happens. So there must be something wrong with the whole system i think
VSCode is an excellent IDE. When you start a new project (or open a folder in VSCode), it does not come with any build tools or compilers etc. You have to manually configure them. You have to set up the environment using different toolchains. Here are some instructions for Python
This is not a problem with VSCode but I am going to answer your question.
You can't webscrape indeed.com with requests and beatiful soup because it has bot protection using cloudflare. If you take a closer look to the response it returns the 403 Forbidden status code instead of 200 OK. You can scrape using a headless browser using selenium.
Here's an example
First install selenium and webdriver_manager
pip install selenium webdriver_manager
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# Make sure you are not detected as HeadlessChrome, some sites will refuse access
options = ChromeOptions()
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = Chrome(options=options, service=Service(
ChromeDriverManager().install()))
# Make sure you are not detected as HeadlessChrome, some sites will refuse access
ua = driver.execute_script("return navigator.userAgent").replace(
"HeadlessChrome", "Chrome")
driver.execute_cdp_cmd("Network.setUserAgentOverride", {
"userAgent": ua})
driver.execute_script(
"Object.defineProperty(navigator,'webdriver',{get:()=>undefined});")
driver.get("https://www.indeed.com/companies/best-Agriculture-companies")
main = driver.find_element(By.ID, "main")

How to mark a jupyter lab document as trusted when building through mybinder.org so that all codecells are run automaticaly

I need all codecells in a jupyter lab document to run when opening it in binder. I've tried adding jupyter trust <filename> to the postbuild file but it does'nt work. Any tips are welcome.
When you say that it doesn’t work, does it at least show as trusted when you open the notebook? Because that approach is/was recommended way to set to trusted. Until the extension enabling example notebook was streamlined to only include an example that works in both the classic an JupyterLab interface, that was the way documented here. Here discusses how to check if trusted.
However, just setting trusted does not trigger the code to run when the notebook is launched.
Aside of coding extension that will run code like python-markdown, there is no simple way to trigger that in the Binderhub system at this time. When this question came up the other day in the binder gitter channel, I suggested a person could most likely make an empty notebook appear to have just been run by using a start config file to trigger execution of the notebook via nbconvert or papermill.
Alternatively, using Appmode as discussed here will execute all cells when run in app mode; however, the interface won’t be a notebook. Similarly, installing Voila and linking to the Voila render will run code in a notebook at launch. It will look like a web app interface and not a notebook though.

Angular Live Development Server api requests not found

really confused about this and don't know where to start.
Basically i have generated a new angular project with the "dotnet new angular" command.
Im using a fresh machine, node, npm etc etc are all up to date.
My issue is this template just does not work out of the box. When i run the application, all of the frontend will load however, any requests to the api's etc will 404 stating that it cannot find the url.
Message in Chrome console: "Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment..."
My application runs on a different port everytime I execute the "dotnet run" command. Is this supposed to be the case ? Whichever port is generated, this will be the problematic one.
I have to manually change to port 5001 for anything to function correctly (although this comes with annoying security prompts.)
I am using visual studio code for this project. The funny thing is, if i run this project via visual studio (not code) i get a consistent static port number that will function as intended (this also comes with annoying security prompts) so i have to assume its this random port number that vscode is generating ?
Im honestly not to familiar with this so I could be way off admittedly. Any help or advice would be appreaciated. I'd post code snippets if I knew where to start.
PS, I know that I can of course just not run it with VSCode and just stick to Visual Studio. I'd rather understand the issue than ignore it though.
Thanks, in advance.

How do I get a server up and running in WebStorm?

Because of cross domain issues I need to run my code (which is HTML & JS) via a server in WebStorm. None of the instructions I can find are simple and straight forward. Can someone give me an idiots' guide to doing this?
Alternatively, I have got Tomcat up and running in Eclipse, but I can't figure out how to import a non-java project into it. Again, instructions that a bear of little brain can follow would be appreciated.
WebStorm comes with a built-in static web server, listening on localhost:63342. All you need to do to run your code on it is right-clicking your .html file and choosing Run.
see also https://www.jetbrains.com/help/webstorm/2017.3/debugging-javascript-in-chrome.html, Debugging an application running on the built-in server

MassTransit first run

I'm trying out MassTransit. I wrote a small console application as showed in documentation (http://docs.masstransit-project.com/en/latest/configuration/quickstart.html).
What I first ran the app, it opened another console windows, and did something that looked like an installation proccess, or some kind of file copy. I remember seeing something done in the windows directory, but it was too fast to read and understand what exactly it did.
I couldn't find any information about it. I tried starting a new .NET project and running the same code - it did not repeat.
Does MassTransit install something on the system at first run? does someone knows what exactly happens on first tun?
Thanks
I've written a post explaining how to get a quick hello world Mass Transit application up and running.
It uses RabbitMQ, but the same principles apply to MSMQ.
http://nodogmablog.bryanhogan.net/2015/04/mass-transit-with-rabbitmq-hello-world/
If you included the call to the method VerifyMsmqConfiguration() as in the quick start, then MassTransit initates any required MSMQ component installation.
The required MSMQ components are Core, LocalStorage, and Multicast.