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
(function(fe){typeof define=="function"&&define.amd?define(fe):fe()})(function(){"use strict";var Yd=Object.defineProperty;var Gd=(fe,A,Qe)=>A in fe?Yd(fe,A,{enumerable:!0,configurable:!0,writable:!0,value:Qe}):fe[A]=Qe;var Ue=(fe,A,Qe)=>Gd(fe,typeof A!="symbol"?A+"":A,Qe);var fe,A,Qe,$o,et,Fo,Bo,Uo,Wo,gn,yn,bn,Vo,xt={},Ho=[],ja=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ct=Array.isArray;function Se(e,t){for(var n in t)e[n]=t[n];return e}function wn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function H(e,t,n){var o,r,i,a={};for(i in t)i=="key"?o=t[i]:i=="ref"?r=t[i]:a[i]=t[i];if(arguments.length>2&&(a.children=arguments.length>3?fe.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)a[i]===void 0&&(a[i]=e.defaultProps[i]);return St(e,a,o,r,null)}function St(e,t,n,o,r){var i={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Qe,__i:-1,__u:0};return r==null&&A.vnode!=null&&A.vnode(i),i}function zo(){r |
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
#!/usr/bin/env python | |
""" | |
Usage: Put this script in any /bin folder in the PATH and run | |
snakecase "Hello World (123).csv" | |
OR | |
Download this snippet and run | |
python snakecase "Hello World (123).csv" | |
Output: hello_world_123.csv | |
""" |
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
import re, itertools | |
def similarish(string1, string2): | |
""" | |
Find if two different strings (names) are similar enough to make it a single person's name. | |
Input | |
string1 : a person's full/partial name | |
string2 : same person's full/partial name or different formatting from name1 | |
Output | |
Boolean |
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
// http://stackoverflow.com/questions/9160001/how-to-profile-methods-in-scala | |
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime() | |
println("Elapsed time: " + (t1 - t0) + "ns") | |
result | |
} |
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 hashlib import md5 | |
from multiprocessing import Pool | |
from time import time | |
""" | |
A quick and dirty CPU benchmarking in python | |
Calculates md5 for a text multiple times in | |
multiple processes to push CPU to its limits. | |
""" |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
power_dict = [ | |
"⁰", | |
"¹", | |
"²", | |
"³", | |
"⁴", | |
"⁵", |
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
import numpy as np | |
import numpy.random as npr | |
import pylab | |
def bootstrap(data, num_samples, statistic, alpha): | |
"""Returns bootstrap estimate of 100.0*(1-alpha) CI for statistic.""" | |
n = len(data) | |
idx = npr.randint(0, n, (num_samples, n)) | |
samples = data[idx] |
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
class Data: | |
def __init__(self, dictionary): | |
for k, v in dictionary.items(): | |
setattr(self, k, v) | |
o = Data({'a': 1, 'b': 2}) | |
o.a |
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
import csv | |
import itertools | |
from collections import Counter, defaultdict | |
import json | |
import re | |
""" | |
get Blockbuster Database dataset from http://www.crowdflower.com/data-for-everyone | |
""" | |
f = open("top_ten_movies_per_year_DFE.csv") | |
r = csv.DictReader(f) |
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
#add this to your urls file | |
url(r'^version/$', 'api.views.code_version', name='code_version'), |
NewerOlder