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
object NumberUtils { | |
private def numberUnderThousandToEnglish(number: Int) = { | |
val hundreds = number / 100 | |
val tensAndOnes = number % 100 | |
val tens = tensAndOnes / 10 | |
val ones = number % 10 | |
val hundredsStr = if (hundreds > 0) Some(numNames(hundreds) + " hundred") else None | |
val restStr = numNames.get(tensAndOnes).map(s => List(Some(s))).getOrElse( |
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
" Vundle. | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/Vundle.vim' | |
Plugin 'bling/vim-airline' |
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
# Requires Hirb and Ruby 2.0+. | |
# The format for data is [[ test_positive, condition_positive ]], where each entry is a data point. | |
def correlate(data, test_event: 'Test', condition_event: 'Truth') | |
counts = data.group_by(&:itself).map { |bucket, v| [ bucket, v.length ] }.to_h | |
table = [ | |
[ counts[[true, true]] || 0, counts[[true, false]] || 0 ], | |
[ counts[[false, true]] || 0, counts[[false, false]] || 0 ] | |
] | |
all_test_positive = table[0][0] + table[0][1] | |
all_test_negative = table[1][0] + table[1][1] |
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
module AutoTimestamp | |
def query_callback(rows, options) | |
rows.each do |r| | |
r.each do |k, v| | |
if v.is_a?(Integer) | |
dates = [ Time.at(v), Time.at(v / 1000) ] | |
plausible_date = dates.find { |d| | |
d >= Time.now - 10.years && d <= Time.now + 10.years | |
} |
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
" Paste this into your .vimrc. | |
" It's very janky but hopefully easy to tweak for your own purposes. | |
" If you want to make this into a real plugin, be my guest. | |
" To use, put this in your .vimrc: | |
" call unite#custom#source('<source name>', 'sorters', 'sorter_burkematcher') | |
python << endpython | |
import vim | |
import subprocess |
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
'use strict'; | |
const _ = require('lodash'); | |
const moment = require('moment'); | |
function cliff(months, cliffMonths, totalMonths) { | |
return (months < cliffMonths) ? 0 : Math.min(1, months / totalMonths); | |
}; | |
module.exports = { |
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 gzip | |
import hashlib | |
import os | |
import StringIO | |
import sys | |
import urllib | |
import getpass | |
from xml.etree import ElementTree |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 AmplitudeEvent < ActiveRecord::Base | |
end |