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 / gist:f31b5eeac16f8b6649907fa00243d9c2
Created May 4, 2020 09:15
Bash function to set terminal title. Put it in .bashrc
function set-title(){
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}
@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)