bmedicke / quantum_cryptography

demonstration of quantum cryptography 🐈 🔐 , one-time pad communication via BB84. repo for our IT Security Master project
27 stars 10 forks source link

evaluate JupyterLab as alternative to Jupyter Notebook #19

Closed bmedicke closed 3 years ago

bmedicke commented 3 years ago
bmedicke commented 3 years ago

So far I can't get %matplotlib widget to work, it fails with: Error displaying widget: model not found

bmedicke commented 3 years ago

setup note for JupyterLab

So far I can't get %matplotlib widget to work, it fails with: Error displaying widget: model not found

fixed by: jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib

bmedicke commented 3 years ago

samples for AMQP and MQTT with docker: https://github.com/bmedicke?tab=repositories&q=mqtt+OR+amqp

bmedicke commented 3 years ago

MQTT with paho and mosquitto

receive in JupyterLab notebook via paho:

cell 1 (setup & connection)

server = "broker.emqx.io"

import paho.mqtt.client as mqtt

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("test")

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.connect(server, 1883, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.

cell 2 (keeps running)

client.loop_forever()

send via mosquitto:

mosquitto_pub -h broker.emqx.io  --topic 'test' --message 'test'

works great

Screenshot 2021-05-09 at 19 00 53

bmedicke commented 3 years ago

mosquitto aliases

alias sub="mosquitto_sub -u admin -P admin -v --topic 'lights/light1/lumen'"
alias pub="mosquitto_pub -u admin -P admin --topic 'lights/light1/lumen'"
alias long="mosquitto_pub -u admin -P admin -l --topic 'lights/light1/lumen'"
alias retain="mosquitto_pub -u admin -P admin -l --topic 'lights/light1/lumen' --retain"
alias will="mosquitto_pub -u admin -P admin --will-retain --will-topic 'lights/light1/lumen' --will-payload '0' -l --topic 'lights/light1/lumen'"
alias cl="mosquitto_pub -u admin -P admin --topic lights/light1/lumen --message '' --retain"