Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Mike DePalatis mivade

👋
View GitHub Profile
View gist:75ca4ba5464ea2a31f3efa40a6269349
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDlHCZTJSJlNB+kBY7Cz63MLxJwEfjbOs1f+FPdRBIcuPTCWqNR79AG25H6o33SXvvAIJaXDL+uldpTDHtCs5llV4wZlq2aD11A9YWGc/Y/so8D8Ii87YnNThbf6DzlHODMV9NRD96QJ1iyZ8JHMPh8B0+wvgfTX7hjeci8XDAo2cVJrmsARRRW03r4xqjHVWH1M2C7b+hpkuKM7676md9u+ZGCK8s6sPw0H9bjpK88NFc7gps9Ia6/luq6joBmATIM9tMcN7IUHbX/O16wnTaFTpieYHVRWZI5+dmcZUGZfXh/PwsJY8Ca2CbtwCNfhmgq20GlOdjHONtHa/wAO1zr mvd@octans
View tornado_webargs_files.py
"""Example of how to use webargs with Tornado to read form data which includes file uploads."""
from dataclasses import dataclass, field
from typing import List, Optional
from marshmallow_dataclass import class_schema
from marshmallow.fields import Raw
from tornado.ioloop import IOLoop
from tornado.web import Application, RequestHandler
@mivade
mivade / zmq_auth.py
Last active Apr 25, 2021
ZeroMQ Curve authentication demo
View zmq_auth.py
"""Simple demonstration of using ZMQ's Curve authentication.
This demo is adapted from the examples given in the `PyZMQ repository`__. Key
differences include:
* Using ``setsockopt`` to set Curve parameters instead of setting attributes
directly (help out your IDE!)
* Integration with ``asyncio``
__ https://github.com/zeromq/pyzmq/tree/master/examples
@mivade
mivade / aiowatch.py
Created Oct 26, 2018
Using watchdog with asyncio
View aiowatch.py
import asyncio
from pathlib import Path
from typing import Optional
from watchdog.events import FileSystemEvent, FileSystemEventHandler
from watchdog.observers import Observer
class _EventHandler(FileSystemEventHandler):
def __init__(self, queue: asyncio.Queue, loop: asyncio.BaseEventLoop,
View h5recarray.py
import codecs
import json
from typing import Union
import h5py
import numpy as np
import pandas as pd
vlen = np.vectorize(len)
vencode = np.vectorize(codecs.encode)
View metaclass.py
class Manager(object):
classes = set()
class Meta(type):
def __new__(cls, name, bases, d):
print("name:", name, "\nbases:", bases, "\ndict: ", d)
if name is not "Base":
Manager.classes.add(d['data'])
return type.__new__(cls, name, bases, d)
@mivade
mivade / ipc_compare.py
Last active Jan 15, 2022
Interprocess communication speed comparisons
View ipc_compare.py
from multiprocessing import Event, Process, Queue
import time
import zmq
class BaseActor(Process):
ready = Event()
def handle(self, msg):
print("dt =", time.time() - msg['timestamp'])
@mivade
mivade / schedule_coroutines.py
Created May 7, 2018
Running coroutines without explicitly awaiting
View schedule_coroutines.py
import asyncio
from threading import Event, Thread
class EventLoopThread(Thread):
def __init__(self):
super().__init__()
self.loop = None
self.ready = Event()
@mivade
mivade / multiline_lambdas.py
Last active Jan 15, 2018
Multiline lambdas and why you'd want to use them
View multiline_lambdas.py
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class MainWindow(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowTitle('Multiline lambdas')
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: