Skip to content

Instantly share code, notes, and snippets.

@dlithio
dlithio / flask_geventwebsocket_example.py
Created August 24, 2016 02:58 — forked from lrvick/flask_geventwebsocket_example.py
Simple Websocket echo client/server with Flask and gevent / gevent-websocket
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
import numpy as np
import matplotlib as mpl
mpl.use('pgf')
def figsize(scale):
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean # height in inches
@dlithio
dlithio / ipynb_output_filter.py
Created August 29, 2015 15:00 — forked from waylonflinn/ipynb_output_filter.py
Make ipython notebook files place nice with git. Remove output from notebooks when doing diffs and commits.
#! /usr/bin/env python
# this script filters output from ipython notebooks, for use in git repos
# http://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control
#
# put this file in a `bin` directory in your home directory, then run:
#
# echo -e "*.ipynb \t filter=dropoutput_ipynb" >> ~/.gitattributes
# git config --global core.attributesfile ~/.gitattributes
# git config --global filter.dropoutput_ipynb.clean ~/bin/ipynb_output_filter.py
# git config --global filter.dropoutput_ipynb.smudge cat