Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
whooosh

David Cottrell cottrell

💭
whooosh
View GitHub Profile
@courtarro
courtarro / server.py
Last active Jan 20, 2016
Simple Tornado-based webserver for Python
View server.py
#!/usr/bin/env python
import threading
import time
import tornado.ioloop
import tornado.web
LISTEN_PORT = 8000
class FancyStaticFileHandler(tornado.web.StaticFileHandler):
@takluyver
takluyver / 2to3_nb.py
Last active Oct 9, 2020
Run 2to3 on IPython notebooks
View 2to3_nb.py
#!/usr/bin/env python3
"""
To run: python3 nb2to3.py notebook-or-directory
"""
# Authors: Thomas Kluyver, Fernando Perez
# See: https://gist.github.com/takluyver/c8839593c615bb2f6e80
import argparse
import pathlib
from nbformat import read, write
@alexbw
alexbw / kalman.py
Created Feb 20, 2012
Kalman Filter in Python
View kalman.py
class Kalman:
"""
USAGE:
# e.g., tracking an (x,y) point over time
k = Kalman(state_dim = 6, obs_dim = 2)
# when you get a new observation —
someNewPoint = np.r_[1,2]
k.update(someNewPoint)
@tkaemming
tkaemming / autocache.py
Created Apr 20, 2012
self-versioning and argument-hashing cache decorator for python (django/flask)
View autocache.py
#!/usr/bin/env python
"""
Self-versioning and argument-hashing cache decorator for deterministic functions.
Designed to be extensible and API-compliant with Django and Flask cache backends.
For examples and caveats, see the bottom of the file.
Ted Kaemming: https://github.com/tkaemming
Mike Tigas: https://github.com/mtigas
"""
@drgarcia1986
drgarcia1986 / tornado_asyncio.py
Last active Aug 7, 2021
Tornado and Asyncio Mixed example
View tornado_asyncio.py
# -*- coding: utf-8 -*-
import asyncio
import re
import asyncio_redis
import tornado.concurrent
import tornado.httpclient
import tornado.web
import tornado.platform.asyncio
@georgexsh
georgexsh / goto.py
Created Sep 18, 2017
python goto with system trace function
View goto.py
import sys
def j(lineno):
frame = sys._getframe().f_back
called_from = frame
def hook(frame, event, arg):
if event == 'line' and frame == called_from:
try:
frame.f_lineno = lineno
@GaelVaroquaux
GaelVaroquaux / mutual_info.py
Last active Oct 7, 2021
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
View mutual_info.py
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
This code is maintained at https://github.com/mutualinfo/mutual_info
Please download the latest code there, to have improvements and
bug fixes.