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
# different functions that can be passed in | |
# (num_divisors is used by default) | |
uniq_factors = lambda x: len([p for p,n in factor(x)]) | |
count_factors = lambda x: sum(n for p,n in factor(x)) | |
num_divisors = lambda x: len(divisors(x)) | |
def plot_divisors(height=100, fun=num_divisors): | |
width = 2*height | |
m = matrix(height, width) | |
l = width / 2 |
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
httpProxy = require 'http-proxy' # npm install http-proxy | |
server = httpProxy.createServer (req, res, proxy) -> | |
if req.headers['host'] == PUBLIC_IP | |
# react to a request sent from the malicious beacon giving | |
# the user's current location | |
{query} = url.parse(req.url) | |
{location} = querystring.parse(query) | |
if location | |
console.log "Tracked location: #{location}" |
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> | |
<!-- By Jan Wrobel (http://mixedbit.org) --> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>Random walk</title> | |
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> |
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 sklearn import preprocessing, pipeline | |
label_enc = preprocessing.LabelEncoder() | |
pipe = pipeline.Pipeline([('enc', label_enc)]) | |
X = ['foo', 'bar', 'baz'] | |
label_enc.fit(X) # works | |
pipe.fit(X) # fails w/ output below |
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
''' | |
Convert Yelp Academic Dataset from JSON to CSV | |
Requires Pandas (https://pypi.python.org/pypi/pandas) | |
By Paul Butler, No Rights Reserved | |
''' | |
import json | |
import pandas as pd |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 IPython.kernel import KernelManager | |
from time import sleep | |
def racecondition(): | |
km = KernelManager() | |
km.start_kernel() | |
kc = km.client() | |
kc.start_channels() |
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.stats import beta | |
def binom_interval(success, total, confint=0.95): | |
quantile = (1 - confint) / 2. | |
lower = beta.ppf(quantile, success, total - success + 1) | |
upper = beta.ppf(1 - quantile, success + 1, total - success) | |
return (lower, upper) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 os.path import getsize | |
from progressbar import ProgressBar | |
class ProgOpen(object): | |
def __init__(self, filename): | |
self.filename = filename | |
def __iter__(self): | |
return self |
OlderNewer