Skip to content

Instantly share code, notes, and snippets.

@nebw
nebw / arXiv popularity scoring.ipynb
Created September 6, 2015 12:07
Popularity scoring for arXiv publications
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Jquick7490MLA:force jquick$ mkvirtualenv force
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.5.1', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.6/site-packages/virtualenv.py", line 558, in main
prompt=options.prompt)
File "/Library/Python/2.6/site-packages/virtualenv.py", line 647, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.6/site-packages/virtualenv.py", line 771, in install_python
copy_required_modules(home_dir)
@j2labs
j2labs / gist:898488
Created April 1, 2011 17:10
JSON vs cPickle in Python 2.7
#!/usr/bin/env python
# Average runs looks like this:
# $ ./serialization.py
# Starting json...
# done: 5.75292301178
# Starting simplejson...
# done: 6.66689586639
# Starting cjson...
# done: 2.09307098389
@mdengler
mdengler / garch.py
Created April 18, 2012 04:38
garch in python, from Peter von Tessin
#!/usr/bin/env python
# Trivial GARCH implementation in python
#
# From Peter Tessin's http://www.petertessin.com/TimeSeries.pdf
#
@jcreixell
jcreixell / gdoc.py
Created May 15, 2012 09:39
Google Doc pandas integration
import gspread
from pandas import *
import logging
class GDocError(Exception):
def __init__(self, value):
self.parameter = value
def __str__(self):
@gka
gka / birth-transposed-2.csv
Created May 19, 2012 14:34
Daily Births Per Month in Germany, normalized by birth per day over the full year.
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 14 columns, instead of 11. in line 6.
Year,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Total
1950,3091.48387097,3266.96428571,3325.90322581,3187.86666667,3160.58064516,3078.7,2958.09677419,2885.80645161,3056.83333333,2943.70967742,2912.8,2864.74193548,3059.45479452
1951,3029.5483871,3181.71428571,3210.74193548,3142.96666667,3196.41935484,3087.1,3017.0,2929.35483871,3022.56666667,2884.61290323,2806.4,2878.16129032,3031.17808219
1952,3072.0,3223.24137931,3268.4516129,3181.03333333,3115.93548387,2994.03333333,2973.5483871,2865.29032258,3070.0,2807.74193548,2860.5,2814.5483871,3027.62739726
1953,3052.90322581,3175.96428571,3248.19354839,3163.06666667,3142.83870968,3039.6,2975.5483871,2856.61290323,3061.5,2774.12903226,2679.63333333,2846.16129032,3000.07945205
1954,3074.06451613,3238.64285714,3172.93548387,3180.3,3243.35483871,3096.2,3021.51612903,2930.4516129,3054.9,2781.06451613,2848.86666667,2862.19354839,3040.39178082
1955,3058.03225806,3235.96428571,3286.93548387,3178.4,3151.77419355,3104.63333333,2988.51612903,2933.41935484,3064.06666667,287
@mbostock
mbostock / .block
Last active December 6, 2016 11:39
Streamgraph
license: gpl-3.0
@flashingpumpkin
flashingpumpkin / coroutine.py
Created March 1, 2012 16:55
Decorator for coroutine usage.
def coroutine(func):
"""
A decorator that turns a function with normal input into a coroutine.
This decorator takes care of priming the coroutine, doing the looping and
handling the closing.
The first argument of any decorated function is what was received when
data was sent to the coroutine via the ``.send`` method. All the other
``*args`` and ``**kwargs`` are what was passed to the decorated function
when instantiating the coroutine.
@kohlmeier
kohlmeier / ka_bnet_numpy.py
Created March 26, 2012 21:59
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@kohlmeier
kohlmeier / ka_bnet_pandas.py
Created March 26, 2012 22:32
Bayes net example (Pandas version)
#!/usr/bin/env python
from pandas import DataFrame, Series
import numpy as np
import math
import random
import copy
NaN_Flag = -1 # pandas uses np.nan, but that coerces ints to floats :(