Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
@wesm
wesm / gist:1079577
Created July 13, 2011 01:50
Summarizing an Interactive Brokers activity statement
"""
A little script for summarizing my Interactive Broker statements
"""
from pandas import *
from pandas.util.testing import set_trace as st
import numpy as np
from BeautifulSoup import BeautifulSoup
@m1m0r1
m1m0r1 / tweetclass.py
Created July 25, 2011 20:48
Text classification using Twitter, MeCab, TokyoCabinet and nltk.
#!/usr/bin/env python2.6
# coding: utf-8
# Twitter
import twitter
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN_KEY = ''
ACCESS_TOKEN_SECRET = ''
@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)
@mbostock
mbostock / .block
Last active January 31, 2025 21:03
Mobile Patent Suits
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/mobile-patent-suits
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([
@gwik
gwik / geventmongo.py
Created August 31, 2011 18:17
PyMongo >=2.0 pool for gevent
# Copyright 2011 10gen
#
# Modified by Antonin Amand <[email protected]> to work with gevent.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@pcardune
pcardune / .gitignore
Created September 5, 2011 04:55
Facebook command-line client helper
.fb_access_token
.fbconsole.py
@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.
@marcelcaraciolo
marcelcaraciolo / spearman.py
Created September 12, 2011 02:21
spearman coefficient
import datetime
import sys
import random
def _rank_dists(ranks1, ranks2):
"""Finds the difference between the values in ranks1 and ranks2 for keys
present in both dicts. If the arguments are not dicts, they are converted
from (key, rank) sequences.
"""
@psychemedia
psychemedia / nytArticleTagNet.py
Created October 13, 2011 07:56
Generate tag graphs from article searches via New York Times Article API
# Script to generate a co-occurring tag graph from news articles via Guardian Platform API
# This is a quick hack script - just get things done... Needs refactoring/tidying...
import simplejson,urllib,csv,sys
from itertools import combinations
# D3.js json generator from https://bitbucket.org/hagberg/networkx-d3
import d3