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 result = {} | |
| _.each(input, function (key, value) { if (value !== false) this[key] = value; }, result); |
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
| SEGMENT_TABLE = { | |
| 1: (39.5, 40), | |
| 2: (40, 50), | |
| } | |
| def get_segment(position): | |
| for key, (lower, upper) in SEGMENT_TABLE.items(): | |
| if lower <= position < upper: | |
| return key |
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
| return unless Modernizr.svg | |
| class NavVisualization | |
| @links = [ | |
| source: "_root" | |
| target: "Home" | |
| thickness: 7 | |
| , | |
| source: "Home" |
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
| pwned |
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); |
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
| 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
| 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
| 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
| 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: |