- ages are in years
- contribution, and savings are in dollars
- avg_annual_return is a ratio, so 1.07 is a 7% annual return
let's say I'm 25 years old, I am going to contribute $2000/yr in bonds (~5% return), and I've already invested $5700 in bonds
| from django.db import connection | |
| def hs_str(s): | |
| s = unicode(s) | |
| return s.replace('"', r'\"') | |
| def dict_to_hstore(d): | |
| hs_data = [u'"{0}" => "{1}"'.format(hs_str(k), hs_str(v)) for (k, v) in data.items()] | |
| hs_data = u",".join(hs_data) | |
| return "u'{0}'::hstore".format(hs_data) |
| #!/usr/bin/env bash | |
| set -eo pipefail | |
| NODE_VERSION=$(curl --silent --get https://semver.io/node/stable) | |
| NODE_BASENAME=node-v${NODE_VERSION}-linux-x64 | |
| NODE_ARCHIVE="http://nodejs.org/dist/v${NODE_VERSION}/${NODE_BASENAME}.tar.gz" | |
| # make a temp directory | |
| tempdir="$( mktemp -t node_XXXX )" | |
| rm -rf $tempdir |
| alert('adsf') |
| import warnings | |
| import random | |
| if random.random() > 0.999: | |
| warnings.warn("Hi marco, nice day today, eh?") |
| import struct | |
| import math | |
| from ctypes import create_string_buffer | |
| class error(Exception): | |
| pass | |
| # this module redefines the names of some builtins that are used | |
| max_ = max |
| function replace(txt) { | |
| txt = txt.replace(/witnesses/gi, "dudes I know"); | |
| txt = txt.replace(/allegedly/gi, "kinda probably"); | |
| txt = txt.replace(/new study/gi, "tumblr post"); | |
| txt = txt.replace(/rebuild/gi, "avenge"); | |
| txt = txt.replace(/space/gi, "spaaace"); | |
| txt = txt.replace(/google glass/gi, "virtual boy"); | |
| txt = txt.replace(/smartphone/gi, "pokédex"); | |
| txt = txt.replace(/electric/gi, "atomic"); | |
| txt = txt.replace(/senator/gi, "elf-lord"); |
| # add new database to addons before running this | |
| # fill in the blank | |
| # eg. DBNAME=HEROKU_POSTGRESQL_ROSE <- new Database | |
| DBNAME=HEROKU_POSTGRESQL_ROSE | |
| heroku maintenance:on | |
| heroku scale web=0 | |
| heroku pgbackups:capture --expire |
| function getJSON(url, cb) { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open("GET", url, true); | |
| xhr.onreadystatechange = function() { | |
| if (xhr.status != 200 || xhr.readyState != 4) return; | |
| cb(JSON.parse(xhr.responseText)); | |
| } | |
| xhr.send(); | |
| }; |
| from collections import Counter | |
| K = 3 | |
| dataset = [ | |
| # weight, color, # seeds, type | |
| [303, 3, 1, "banana"], | |
| [370, 1, 2, "apple"], | |
| [298, 3, 1, "banana"], | |
| [277, 3, 1, "banana"], | |
| [377, 4, 2, "apple"], |