Skip to content

Instantly share code, notes, and snippets.

View Dansyuqri's full-sized avatar

Shooks Dansyuqri

View GitHub Profile
# single_pub_coro.py
# This is a reimplementation of the https://gist.github.com/Dansyuqri/3b533d0f11f3ddd53da34686434309d7 gist
# which allows for all functions to run asynchronously using coroutines.
import asyncio
import time
import zmq
from zmq.asyncio import Context
host = "127.0.0.1"
# multi_pub_coro.py
# This is a reimplementation of the https://gist.github.com/Dansyuqri/93b8df592946cf5ec2158aa10c13bbcc gist
# which allows for all functions to run asynnchronously using coroutines.
import asyncio
import time
import zmq
from zmq.asyncio import Context, Poller
host = "127.0.0.1"
@Dansyuqri
Dansyuqri / multi_pub.py
Last active April 12, 2020 10:01
Single Subscriber to Multiple Publishers
# multi_pub.py
import time
import zmq
from threading import Thread
host = "127.0.0.1"
port = "5001"
ctx = zmq.Context()
@Dansyuqri
Dansyuqri / multi_sub.py
Created April 12, 2020 08:09
Multiple Subscribers to One Publisher
# multi_sub.py
import zmq
from threading import Thread
host = "127.0.0.1"
port = "5001"
ctx = zmq.Context()
@Dansyuqri
Dansyuqri / simple_pub.py
Created March 8, 2020 08:32
Sending/receiving simple messages using PyZMQ
# simple_pub.py
import zmq
import time
host = "127.0.0.1"
port = "5001"
# Creates a socket instance
context = zmq.Context()
socket = context.socket(zmq.PUB)
@Dansyuqri
Dansyuqri / multipart_pub.py
Last active February 22, 2023 07:05
Sending/receiving multipart messages using PyZMQ
# multipart_pub.py
import zmq
import time
host = "127.0.0.1"
port = "5001"
# Creates a socket instance
context = zmq.Context()
socket = context.socket(zmq.PUB)
@Dansyuqri
Dansyuqri / fcc-tribute-page-w-test-suite.markdown
Created November 5, 2019 08:47
FCC Tribute Page w Test Suite

Keybase proof

I hereby claim:

  • I am dansyuqri on github.
  • I am dansyuqri (https://keybase.io/dansyuqri) on keybase.
  • I have a public key ASCyYhqIrmTFbPjWdXpVuQd0WHtAw62An70p4WS6BHTuygo

To claim this, I am signing this object:

@Dansyuqri
Dansyuqri / docker_install_ubuntu_1804.sh
Last active September 5, 2019 02:45
Installing docker for Ubuntu 18.04
#!/bin/bash
# Update existing list of packages
sudo apt update
# Install packages required to allow apt install over HTTPS
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Get official GPG key from Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@Dansyuqri
Dansyuqri / Faster row retrieval using pandas.md
Created July 13, 2019 05:56
Faster row retrieval using pandas

In pandas it is much faster to query a row independently of the headers and then using dict and zip to convert into header to column value mapping rather than using the in-built to_dict method.

import pandas as pd
import os, time

dataframe = pd.read_csv("data.csv", index_col=False)
start_time = time.time()
row = dataframe.loc[[25], list(dataframe)].to_dict("records")[0]
print("TIME: {}".format(time.time() - start_time))