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
# Author: Nelle Varoquaux, Andrew Tulloch | |
# Uses the pool adjacent violators algorithm (PAVA), with the | |
# enhancement of searching for the longest decreasing subsequence to | |
# pool at each step. | |
import numpy as np | |
cimport numpy as np | |
cimport cython |
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
ACCESS_KEY='YOUR AMAZON API KEY' | |
SECRET='YOUR AMAZON SECRET' | |
BUCKET_NAME='database_backup_bucket' #note that you need to create this bucket first | |
from boto.s3.connection import S3Connection | |
from boto.s3.key import Key | |
def save_file_in_s3(filename): | |
conn = S3Connection(ACCESS_KEY, SECRET) | |
bucket = conn.get_bucket(BUCKET_NAME) |
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
# from: http://www.tornadoweb.org/documentation | |
# running-tornado-in-production | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { |
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
"""Quick and dirty benchmarking for readability functions. | |
""" | |
import re, time, os, json | |
from urllib import urlopen | |
from hn import grabContent | |
from lxml_readability import extract | |
import socket | |
socket.setdefaulttimeout(30) |
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
''' | |
@author Michael J Bommarito II | |
@contact michael.bommarito@gmail.com | |
@date Feb 21, 2011 | |
@license Simplified BSD, (C) 2011. | |
Plot the network of the first 1000 #cn220 tweets with igraph and cairo. | |
''' | |
import cairo |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Scale Graph</title> | |
</head> | |
<body> | |
<div id="demoContainer"> | |
<div id="option"> | |
<input name="updateButton" type="button" value="Update" onclick="updateData()" /> | |
</div> |
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
def online_mean_variance(iterable): | |
mN = 0 | |
mM = 0.0 | |
mS = 0.0 | |
for x in iterable: | |
mN += 1 | |
nextM = mM + (x - mM) / mN | |
mS += (x - mM) * (x - nextM) |
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
from scipy import linalg | |
import numpy as np | |
from scipy.spatial.distance import cosine | |
#Let's define the matrix | |
user_ids = np.array(['Amanda', 'Anna', 'Bruno', 'Ricardo']) | |
item_ids = np.array(['Back to The Future', 'Conan', | |
'Lord of the Rings', 'Star Wars']) | |
matrix = np.matrix([ |
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
def spearman_coefficient(X, Y): | |
""" | |
Considering the rows of X (and Y=X) as vectors, compute the | |
distance matrix between each pair of vectors. | |
Like Pearson Coefficient , but compares relative ranking of preference | |
values instead of preference values themselves. That is, each user's | |
preferences are sorted and then assign a rank as their preference value, | |
with 1 being assigned to the least preferred item. |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.2"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.27.2"></script> | |
<style> | |
.link { | |
fill: none; |
OlderNewer