Skip to content

Instantly share code, notes, and snippets.

View mivade's full-sized avatar
👋

Mike DePalatis mivade

👋
View GitHub Profile
@mivade
mivade / #zmqcpp-raw-README.md
Last active April 12, 2017 01:33
Sending raw bytes over ZMQ sockets with C++

Demo of sending raw bytes over ZMQ sockets with C++.

This assumes you are using miniconda and have installed cppzmq:

conda install -c conda-forge cppzmq
@mivade
mivade / randport.py
Created May 12, 2017 17:49
Binding to random ports for IPC
"""Examples of how to bind a socket to a random port and have that port number
accessible to other processes. Useful for interprocess communications.
"""
import time
import socket
from socket import AF_INET, SOCK_STREAM
from multiprocessing import Process, Queue, Event
from contextlib import contextmanager

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:

@mivade
mivade / coroutinify.py
Created August 3, 2015 17:53
Adapting blocking calls to Tornado coroutines with run_on_executor decorators
import random
import time
from tornado import gen
from tornado.concurrent import run_on_executor, futures
from tornado.ioloop import IOLoop
class TaskRunner(object):
def __init__(self, loop=None):
self.executor = futures.ThreadPoolExecutor(4)
self.loop = loop or IOLoop.instance()
@mivade
mivade / bokehnado.py
Created October 25, 2015 12:34
Update Bokeh plots without using the bokeh-server
"""Demonstration of using Tornado to send updates to a Bokeh plot
without using the bokeh-server.
"""
import json
import numpy.random as npr
from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.web import Application, RequestHandler
@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')
@mivade
mivade / admonitions.js
Created December 7, 2014 14:29
Colored admonitions in Pelican with pelican-bootstrap3
/*
Simple jQuery calls to replace RST admonitions with Bootstrap
alerts.
This is intended to work with the pelican-bootstrap3 Pelican theme,
but may also work with others.
This script is public domain.
*/
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)

Testing using Pygal to render plots server-side and embed them in a web page via a <canvas>.

@mivade
mivade / hg_importing.md
Last active March 6, 2019 20:00
How to import history from one Mercurial repository into another

Importing a Mercurial repository's full history into another repository

Convert the soon-to-be child repository

With the Mercurial convert extention, you can rename branches, move, and filter files. As an example, say we have a repo with only the default branch which is to be imported into a super-repository.

For starters, we will want all our files in the child repo to be in a subdirectory of the parent repo and not include the child's