Skip to content

Instantly share code, notes, and snippets.

@jiaaro
jiaaro / magicsuper.py
Last active Dec 10, 2015
Magical, automatic super class caller in python (a terrible idea)
View magicsuper.py
import inspect
def magicsuper(*args, **kwargs):
frame = inspect.currentframe().f_back
first_arg_name = frame.f_code.co_varnames[0]
self = frame.f_locals[first_arg_name]
super_klass = super(self.__class__, self)
return getattr(super_klass, frame.f_code.co_name)(*args, **kwargs)
@jiaaro
jiaaro / simpleTarget.js
Last active Dec 16, 2015
Partially de-obfuscated simpleTarget() from nodewar.com
View simpleTarget.js
// nodewar.com library function…
// o.lib.targeting.simpleTarget(ship, pos)
//
// mostly deobfuscated/deminified
//
function simpleTarget(ship, pos) {
var i, r, h,
torque = 0,
thrust = 0,
dir = o.lib.targeting.dir(ship, pos);
@jiaaro
jiaaro / knn_solution.py
Created Jun 4, 2013
solution to the homework in "Machine Learning for Humans: K Nearest-Neighbor" at (http://www.jiaaro.com/KNN-for-humans/)
View knn_solution.py
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"],
View db.sh
# 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
@jiaaro
jiaaro / sub.js
Last active Dec 27, 2015
v1 of implementing xkcd substituions: http://xkcd.com/1288/
View sub.js
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");
@jiaaro
jiaaro / audioop.py
Last active Jan 2, 2016
add audioop.max() to pypy? twitter: @jiaaro - email: me@jiaaro.com
View audioop.py
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
@jiaaro
jiaaro / organism.py
Last active Jan 4, 2016
NOTE: organism.py belongs in a directory "breeder"
View organism.py
#!/usr/bin/env python
import ast
from os.path import isfile
from hashlib import md5
from random import randint, choice
from glob import glob
import re
# scratch area
"""
@jiaaro
jiaaro / investment_calculator.py
Last active Mar 16, 2016
Calculate the value of your investments and savings at some point in the future
View investment_calculator.py
class Investment(object):
def cash_invested_by_month(self, month):
raise NotImplementedError
def value_in_month(self, month):
raise NotImplementedError
class SingleInvestment(Investment):
def __init__(self, amount, monthly_interest_rate, month=0):
View keybase.md

Keybase proof

I hereby claim:

  • I am jiaaro on github.
  • I am jiaaro (https://keybase.io/jiaaro) on keybase.
  • I have a public key ASAmjWlR2gGlcJGuKzzPQ4UDqxXW0WeP-NDoJACLKWKo7go

To claim this, I am signing this object:

View App Revenue Output.md

If you've ever wondered what it's be like to "go indie" here is a script with some assumptions that might help you project your income.

Assumptions:

  • You will make a new app every month
  • Apps have a useful life of 3 years (after that they stop earning money)
  • Apps will earn $250 in their launch month
  • Apps will earn $100/mo at first (starting month 2), but that revenue will slowly decline (~50% each year)
  • As you make more apps your brand/mailing list will start to pay dividends (after 4 apps you'll see the numbers above double, after 8 they'll 3x, and so on)

So how would that work out?