This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import zmq | |
context = zmq.Context() | |
footage_socket = context.socket(zmq.PUB) | |
footage_socket.bind("tcp://*:5555") | |
camera = cv2.VideoCapture(0) # init the camera |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.zeromq; | |
import org.zeromq.SocketType; | |
import org.zeromq.ZContext; | |
import org.zeromq.ZMQ; | |
import org.zeromq.ZMQ.Socket; | |
public class Subscriber { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This shows how to capture data using a pub-sub proxy | |
import time | |
from random import randint | |
from string import ascii_uppercase as uppercase | |
from threading import Thread, currentThread | |
import zmq | |
from zmq.devices import monitored_queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ZeroMQ response server in Python | |
# Binds REP socket to tcp://*:5555 | |
# Expects b"string" from client, replies with b"Ok" | |
import time | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.REP) | |
socket.bind("tcp://*:5555") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ZeroMQ basic client Python | |
# Connects REQ socket to tcp://localhost:5555 | |
# Sends "string" to server, expects "Ok" back | |
import zmq | |
from string import ascii_letters, digits | |
from random import choice | |
context = zmq.Context() | |
# Socket to talk to server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source venv/bin/activate | |
# Upgrade pip | |
pip install wheel | |
pip install --upgrade pip | |
# Update all python packages | |
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
import os | |
import json | |
import requests | |
from celery.task import task | |
from pushsafer import Client, init | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
# This will make sure the app is always imported when | |
# Django starts so that shared_task will use this app. | |
from .celery import app as celery_app | |
__all__ = ['celery_app',] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery.schedules import crontab | |
# CELERY | |
# http://docs.celeryproject.org/en/4.4.1/userguide/configuration.html | |
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') | |
CELERY_BROKER_URL = REDIS_URL | |
CELERY_RESULT_BACKEND = REDIS_URL | |
CELERY_ACCEPT_CONTENT = ['application/json'] | |
CELERY_TASK_SERIALIZER = 'json' | |
CELERY_RESULT_SERIALIZER = 'json' | |
CELERY_IGNORE_RESULT = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
import os | |
from celery import Celery | |
# Below sets the default Django settings module for the 'celery' app. | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_celery_site.settings') |