Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cottrell's full-sized avatar
💭
whooosh

David Cottrell cottrell

💭
whooosh
View GitHub Profile
@GaelVaroquaux
GaelVaroquaux / mutual_info.py
Last active June 18, 2023 12:25
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
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.
@georgexsh
georgexsh / goto.py
Created September 18, 2017 07:47
python goto with system trace function
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
@tkaemming
tkaemming / autocache.py
Created April 20, 2012 20:06
self-versioning and argument-hashing cache decorator for python (django/flask)
#!/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
"""
@takluyver
takluyver / 2to3_nb.py
Last active November 5, 2021 02:45
Run 2to3 on IPython notebooks
#!/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
@drgarcia1986
drgarcia1986 / tornado_asyncio.py
Last active August 7, 2021 15:57
Tornado and Asyncio Mixed example
# -*- coding: utf-8 -*-
import asyncio
import re
import asyncio_redis
import tornado.concurrent
import tornado.httpclient
import tornado.web
import tornado.platform.asyncio
@alexbw
alexbw / kalman.py
Created February 20, 2012 03:32
Kalman Filter in Python
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)
@courtarro
courtarro / server.py
Last active January 20, 2016 06:42
Simple Tornado-based webserver for Python
#!/usr/bin/env python
import threading
import time
import tornado.ioloop
import tornado.web
LISTEN_PORT = 8000
class FancyStaticFileHandler(tornado.web.StaticFileHandler):