Skip to content

Instantly share code, notes, and snippets.

View mivade's full-sized avatar
👋

Mike DePalatis mivade

👋
View GitHub Profile
@mivade
mivade / docker-wsl-ubuntu.md
Created May 4, 2023 14:53
Installing Docker in Ubuntu on WSL

Installing Docker in Ubuntu on WSL

Install upstream Docker

Follow the instructions here

Start the service and troubleshoot problems

sudo service docker start
@mivade
mivade / Set-Up-PowerShell-for-Python.md
Last active October 10, 2022 17:02 — forked from andrew-rietz/Set-Up-PowerShell-for-Python.md
Set Up PowerShell for Python

1. Install Scoop
Scoop is a command-line installer for Windows -- it's like Homebrew for Windows. It installs programs from the command line with a minimal amount of friction. More info about scoop is available here: https://gist.github.com/andrew-rietz/66e4ebcf96f85b6618b078ebe00104b1
To install, open PowerShell and execute the following command:

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

2. Use Scoop to install some awesome helper applications
We'll use Scoop to install a couple applications: posh-git and starship. Posh-git adds a lot of the convenience features you get in git bash directly into PowerShell (autocompletion, etc.). We'll also install starship.rs: a customizeable prompt for many of the common shells (Bash, Fish, Zsh, PowerShell).

"""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 December 30, 2023 12:57
ZeroMQ Curve authentication demo
"""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 October 26, 2018 17:00
Using watchdog with asyncio
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,
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)
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 January 15, 2022 21:14
Interprocess communication speed comparisons
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 12:52
Running coroutines without explicitly awaiting
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 January 15, 2018 16:54
Multiline lambdas and why you'd want to use them
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')