Skip to content

Instantly share code, notes, and snippets.

View mivade's full-sized avatar
👋

Mike DePalatis mivade

👋
View GitHub Profile
@mivade
mivade / tmux.md
Created October 16, 2015 11:43
tmux notes

tmux notes

Reattaching when verisons don't match

$ tmux attach
protocol version mismatch (client 7, server 6)

#$^#^# what now?? Aha...
@mivade
mivade / #tornado-websocket-pubsub.rst
Last active July 5, 2019 05:48
Using Tornado websockets for the publish/subscribe pattern
@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

@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 / .gitignore
Last active February 5, 2022 15:11
Distributed Monte Carlo calculation of pi using Celery
__pycache__
*.pyc
*.ipynb
.ipynb_checkpoints
*.json
*~
@mivade
mivade / tornadosse.py
Last active February 8, 2024 02:17
Tornado server-sent events
"""Demonstration of server-sent events with Tornado. To see the
stream, you can either point your browser to ``http://localhost:8080``
or use ``curl`` like so::
$ curl http://localhost:8080/events
"""
import signal
from tornado import web, gen
@mivade
mivade / tornadobg.py
Last active March 17, 2020 02:07
Background tasks with tornado and concurrent.futures
"""A simple demonstration of running background tasks with Tornado.
Here I am using a basic TCP server which handles streams and keeps
them open while asynchronously performing a fake task in the
background. In order to test it, simply telnet to localhost port 8080
and start typing things to see that the server receives the messages.
The advantage to running on an executor instead of conventional
threads is that we can more easily shut it down by stopping the
tornado IO loop.
@mivade
mivade / pyqtornado.py
Last active April 11, 2016 03:18
PyQt with Tornado
"""Demonstration of combining the Qt and Tornado event loops."""
from PyQt4 import QtGui, QtCore
from tornado.ioloop import IOLoop
from tornado import gen
from tornado.httpclient import AsyncHTTPClient
URL = "https://www.random.org/integers/?num=1&min=100&max=999&col=1&base=10&format=plain&rnd=new"
class MainWindow(QtGui.QMainWindow):
@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.
*/
@mivade
mivade / sphinx.rst
Created September 23, 2014 07:43
Sphinx notes

Sphinx notes

Standard extensions

Usually, the numpydoc format is the easiest to use and read for docstrings. In order to make things Just Work, use the following in conf.py: