This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Snippet to list Python installation/packaging related version information. | |
Execute it with the Python executable you want to inspect. | |
Usage example with curl/wget tricks straight from this github gist | |
(optionally replace `python` at the end with the desired alternative): | |
curl -s https://gist.githubusercontent.com/soxofaan/cc4986cc507cb10f962d/raw/python-version-dump.py | python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import logging | |
class TimingLogger(object): | |
""" | |
Simple timer context manager to log the time spent in the context | |
to given logger (logging api). | |
Usage example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set -x | |
# set -e | |
sessionname=ipython-notebook | |
if screen -list | grep $sessionname ; then | |
echo "Screen session $sessionname is already running." | |
echo "not doing anything" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The original code at http://tungwaiyip.info/2012/Collaborative%20Filtering.html | |
# does not seem to work on my setup (python 2.7.2, numpy 1.6.1, pandas 0.13.1) | |
# The version below works for me. | |
import numpy as np; | |
import pandas as pd; | |
rating = pd.read_csv('movie_rating.csv') | |
rp = rating.pivot_table(cols=['critic'], rows=['title'], values='rating') | |
rating_toby = rp['Toby'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import subprocess | |
import random | |
import time | |
import threading | |
import Queue | |
class AsynchronousFileReader(threading.Thread): | |
''' | |
Helper class to implement asynchronous reading of a file |
NewerOlder