Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
@gustavla
gustavla / gist:9499068
Created March 12, 2014 01:45
_isotonic.pyx
# 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
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)
@irr
irr / gist:466742
Created July 7, 2010 14:11
running-tornado-in-production
# 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 {
@kwellman
kwellman / gist:632478
Created October 18, 2010 16:00
readability_benchmarks.py
"""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)
@mjbommar
mjbommar / plotCN220Network3D.py
Created February 21, 2011 17:39
Plot the network of the first 1000 #cn220 tweets with igraph and cairo.
'''
@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
@ivanteoh
ivanteoh / index.html
Created July 11, 2011 00:19
Scale graph using D3.js
<!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>
@mblondel
mblondel / online_variance.py
Created August 2, 2011 11:03
Sample variance in a single pass
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)
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([
@marcelcaraciolo
marcelcaraciolo / spearman.py
Created September 12, 2011 01:48
spearman coefficient
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.
@anotherjavadude
anotherjavadude / index.html
Created October 25, 2011 11:37
Most simple d3.js tree
<!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;