Skip to content

Instantly share code, notes, and snippets.

@jobliz
jobliz / iris_petal.py
Created June 10, 2012 01:53
Iris dataset (petal size) scatterplot done in matplotlib
import matplotlib
import matplotlib.pyplot as plt
# Iris petal length/width scatterplot (greatest class correlation)
# Dataset: http://archive.ics.uci.edu/ml/datasets/Iris
# Output: https://imgur.com/9TWhn
def data():
lists = [line.strip().split(",") for line in open('flowerdata.txt', 'r').readlines()]
return [map(float, l[:4]) for l in lists], [l[-1] for l in lists]
@jobliz
jobliz / TwitterSearchActor1.py
Created May 10, 2012 03:30
A crude implementation of the actor model to thread the twitter public search usage with python and redis publish/subscribe.
import time
import redis
import urllib
import threading
import simplejson
class Generator(threading.Thread):
def __init__(self, generator, output_channel, _redis=None):
threading.Thread.__init__(self)
self.generator = generator
@jobliz
jobliz / RedisPythonPubSub1.py
Created May 4, 2012 17:58
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)