This file contains hidden or 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
inverse = function (f, lower = -100, upper = 100) { | |
function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1] | |
} | |
cdf = function (f) { | |
function (upper) integrate(f, 0.01, upper).value | |
} | |
f = 0.453 * exp(-1.036x) * sinh(sqrt(2.29x)) |
This file contains hidden or 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
var _ = require('underscore'); | |
config = { | |
'compiled_cache_dir': '../css/tmp', | |
'processors': { | |
'js': 'java -jar YUICompressor.jar {input}', | |
'coffee': ['coffee -c {input} {output}', 'js'], | |
'less': ['lessc', 'css'] | |
}, |
This file contains hidden or 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
var exec = require('child_process').exec | |
, fs = require('fs'); | |
var escapeShell = function(cmd) { | |
return '"'+cmd.replace(/(["\s'$`\\])/g,'\\$1')+'"'; | |
}; |
This file contains hidden or 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
"processors": { | |
"coffee": {"cmd": "coffee -c {input}", "nextExt": "js"}, | |
"js": {"cmd": "cat", "nextExt": "js1"}, | |
"js1": {"cmd": "cat", "nextExt": "js2"}, | |
"js2": {"cmd": "cat", "nextExt": "js3"}, | |
"js3": {"cmd": "cat", "nextExt": "js4"}, | |
"js4": {"cmd": "cat", "nextExt": "js5"}, | |
"js5": {"cmd": "java -Xmx200m -Xms50m -Xincgc -jar testdir/yuicompressor-2.4.7.jar {input} -o {output}", "outputType": "js"} | |
} |
This file contains hidden or 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 NameDenormalizer(object): | |
def __init__(self, filename=None): | |
filename = filename or 'names1.1.csv' | |
lookup = collections.defaultdict(list) | |
with open(filename) as f: | |
reader = csv.reader(f) | |
for line in reader: | |
matches = set(line) | |
for match in matches: |
This file contains hidden or 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 math import sqrt | |
def confidence_bounds(ups, downs): | |
#stolen from reddit! | |
n = ups + downs | |
if n == 0: | |
return 0, 0 | |
z = 1.0 #1.0 = 85%, 1.6 = 95% | |
phat = float(ups) / n | |
confidence_positive = sqrt(phat+z*z/(2*n)-z*((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n) |
This file contains hidden or 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
def my_reverse(a) | |
if a.empty? | |
[] | |
else | |
last = a.pop() | |
[last] + my_reverse(a) | |
end | |
end | |
p my_reverse([1, 2, 3]) |
This file contains hidden or 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 String | |
def my_reverse | |
reversed = [] | |
self.each_char do |char| | |
reversed.unshift(char) | |
end | |
reversed.join('') | |
end | |
end |
This file contains hidden or 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 String | |
def incord(x) | |
(self.ord + x).chr | |
end | |
end | |
p 'a'.incord 2 |
This file contains hidden or 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
border-color: #29447E #29447E #1A356E; | |
color: white; | |
background-color: #5B74A8; | |
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#637BAD), to(#5872A7)); | |
background-image: -moz-linear-gradient(#637BAD, #5872A7); | |
background-image: -o-linear-gradient(#637BAD, #5872A7); | |
background-image: linear-gradient(#637BAD, #5872A7); |