Skip to content

Instantly share code, notes, and snippets.

View albertsun's full-sized avatar

Albert Sun albertsun

View GitHub Profile
@albertsun
albertsun / calculate_pareto_median.py
Created September 27, 2011 18:18
Pareto Interpolation
# http://en.wikipedia.org/wiki/Pareto_interpolation
# Example Pareto interpolation to calculate household median income.
# Assumes that incomedata is a list of 17 elements containing table B19001 from the United States ACS 5-year summary file
from math import log
def calculate_median(incomedata):
bucket_tops = [10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 60000, 75000, 100000, 125000, 150000, 200000]
total = incomedata[0]
for i in range(2,18):
@albertsun
albertsun / linebreaks_wp.py
Created August 21, 2011 05:44
Python port of WordPress's wpautop filter
import re
from django import template
from django.utils.functional import allow_lazy
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe, SafeData
from django.utils.encoding import force_unicode
from django.utils.html import escape
from django.utils.text import normalize_newlines
register = template.Library()
Month Day URL
1 1 http://www.nytimes.com/2017/01/01/arts/michel-deon-novelist-who-tapped-the-french-experience-dies-at-97.html
1 1 http://www.nytimes.com/2017/01/01/arts/television/william-christopher-father-mulcahy-on-mash-dies-at-84.html
1 1 http://www.nytimes.com/2017/01/01/us/huston-smith-author-of-the-worlds-religions-dies-at-97.html
1 2 http://www.nytimes.com/2017/01/02/books/joyce-appleby-historian-of-capitalism-and-american-identity-is-dead-at-87.html
1 2 http://www.nytimes.com/2017/01/02/arts/design/john-berger-provocative-art-critic-dies-at-90.html
1 2 http://www.nytimes.com/2017/01/02/world/middleeast/hilarion-capucci-archbishop-jailed-for-aiding-palestinian-militants-dies-at-94.html
1 3 http://www.nytimes.com/2017/01/03/business/anthony-b-atkinson-economist-who-pioneered-study-of-inequality-dies-at-72.html
1 3 http://www.nytimes.com/2017/01/03/sports/skiing/jean-vuarnet-a-downhill-skiing-innovator-dies-at-83.html
1 4 http://www.nytimes.com/2017/01/04/us/sister-frances-ann-carr-one-of-the-last-thre
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
lol = log --graph --decorate --pretty=oneline --abbrev-commit --all
dfb = log --left-right --graph --cherry-pick --oneline
{
"schema_version": 1,
"name": "RSS Full Text Scrape to Stevedore",
"description": "Follows an RSS feed and visits every feed item to save the full text into Stevedore",
"source_url": "https://mighty-retreat-48764.herokuapp.com/scenarios/7/export",
"guid": "1dcba6751110ed460f0a83273953535e",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#5bc0de",
"exported_at": "2016-04-18T22:41:41Z",
"agents": [
terraform apply .tfplan
aws_instance.k8s-prd-worker-b.0: Creating...
ami: "" => "ami-1a642670"
availability_zone: "" => "<computed>"
ebs_block_device.#: "" => "<computed>"
ephemeral_block_device.#: "" => "<computed>"
instance_state: "" => "<computed>"
instance_type: "" => "m4.2xlarge"
key_name: "" => "everything"
placement_group: "" => "<computed>"
@albertsun
albertsun / killstickies.js
Created January 14, 2014 18:57
Save this snippet of javascript as a bookmarklet to kill any fixed top or sidebars on a web page.
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.firstElementChild.appendChild(c)}})(window,document,"1.10.2",function($,L){$('*').filter(function(){return%20$(this).css("position")==='fixed';}).remove();});

Data, Narratives and Uncertainty

Ideas for 2014

Dots

December has been a contemplative month, and January is going to be hectic.

I don't believe in setting goals or making resolutions for the New Year. Usually I just let the New Year pass by. But there are ideas circulating in my head that I know I want to spend more time figuring out in 2014 — these ideas are half-baked but I don't want to forget them.

One idea I'm grappling with is the relationship between data and narrative and how to communicate uncertainty.

@albertsun
albertsun / .gitconfig
Created October 3, 2013 20:39
git aliases
[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit --all
dfb = log --left-right --graph --cherry-pick --oneline
@albertsun
albertsun / gist:1934619
Created February 28, 2012 19:37
brew install -v postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2
File already downloaded in /Users/204377/Library/Caches/Homebrew
/usr/bin/tar xf /Users/204377/Library/Caches/Homebrew/postgresql-9.1.3.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.3 --datadir=/usr/local/Cellar/postgresql/9.1.3/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.3/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.3 --datadir=/usr/local/Cellar/postgresql/9.1.3/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.3/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
checking build system type... x86_64-appl