Skip to content

Instantly share code, notes, and snippets.

View timothymugayi's full-sized avatar
🎯
Focusing

Timothy Mugayi timothymugayi

🎯
Focusing
View GitHub Profile
@timothymugayi
timothymugayi / tqdm_subprocess.py
Created December 10, 2019 16:41
Tqdm elapsed time with python subprocesses
import sys
import subprocess
from tqdm import tqdm
def create_test_bash_script():
"""
Create a bash script that generates numbers 1 to 1000000
This is just for illustration purpose to simulate a long running bash command
import os
import math
import dask.dataframe as dd
import numpy as np
import pandas as pd
from dask.distributed import Client
client = Client('tcp://scheduler:8786')
$ serverless invoke --function currentTime --log --profile localstack --stage local
Serverless: config.options_stage: local
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: ${opt:stage, 'local'}
Serverless: config.stage: local
Serverless: Using serverless-localstack
Serverless: Reconfiguring service apigateway to use http://localhost:4567
Serverless: Reconfiguring service cloudformation to use http://localhost:4581
Serverless: Reconfiguring service cloudwatch to use http://localhost:4582
Serverless: Reconfiguring service lambda to use http://localhost:4574
service: simple-http-endpoint
frameworkVersion: ">=1.2.0 <2.0.0"
plugins:
- serverless-localstack
# - serverless-python-requirements
provider:
name: aws
import os
import json
import uuid
import boto3
# Inside docker use docker dns name localstack
# os.environ['LOCALSTACK_SQS_ENDPOINT_URL'] = 'http://localstack:4576'
# If your connecting to the localstack outside docker use host dns
# each aws service has its own endpoint url ensure boto3 client is configured accordingly
#!/usr/bin/env bash
printf "Configuring localstack components..."
readonly LOCALSTACK_S3_URL=http://localstack:4572
readonly LOCALSTACK_SQS_URL=http://localstack:4576
sleep 5;
set -x
version: "3.7"
services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack}"
image: localstack/localstack
hostname: localstack
networks:
- localstack-net
ports:
- "4566-4599:4566-4599"
import cv2
import zmq
import numpy as np
port = "5555"
context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
footage_socket.connect("tcp://localhost:%s" % port)
footage_socket.setsockopt_string(zmq.SUBSCRIBE, np.unicode(''))
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
package com.zeromq;
import org.zeromq.SocketType;
import org.zeromq.ZContext;
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Socket;
public class Subscriber {