Skip to content

Instantly share code, notes, and snippets.

View jl's full-sized avatar

Joey Liaw jl

  • San Francisco, California
View GitHub Profile
@jl
jl / diffexit.py
Created December 12, 2014 01:22
python subprocess stdout iteration
"""diff output of multiple processes and exit as soon as one line is different
Note: we have to take care to not trigger any of Python's internal buffering mechanisms.
"""
import itertools
import subprocess
import sys
LINE_BUFFERED = 1
@jl
jl / chrome-profile-ux-fail.md
Last active August 29, 2015 14:15
restore user profile icons in Chrome

The new user profile menu in Chrome is terrible. Instead of easily-distinguishable icons, you now get a generic gray text button of the first name of your account, which is usually the same between work and personal accounts. The whole point is to easily see which profile you're currently using, and this isn't possible with the new UI. UX FAIL!

You need to cut and paste this link into Chrome.

  • chrome://flags/#enable-new-avatar-menu
    • DISABLE IT
@jl
jl / named.md
Last active October 10, 2015 20:19
Python 3 named parameters

Let's say you want to write a comparator function that takes two objects.

def is_newer(older, newer):
    return older.timestamp < newer.timestamp

def keep_newer(file1, file2):
    if is_newer(file1, file2):
        os.unlink(file1)
 else:
@jl
jl / tupletricks.py
Last active October 10, 2015 20:34
Neat things you can do with namedtuples
import collections
Thing = collections.namedtuple('Thing', 'x y z a b c')
def get_by_id(db, thing_id):
columns = ','.join(Thing._fields) # "x,y,z,a,b,c"
qry = 'SELECT {} FROM things WHERE id=?'.format(columns)
row = db.execute(qry, (thing_id,)).fetchone()
return Thing(*row) # construct by expanding arguments
@jl
jl / pkg-config-mac.md
Created February 20, 2016 05:40
Installing pkg-config from source on OS X
@jl
jl / HIMSS-2017.md
Created February 22, 2017 17:29
HIMSS Cloud Computing Forum Medicaid 2.0 Follow-up

On 2017-02-19 I had the honor of co-presenting with Jess Kahn at the HIMSS Cloud Computing Forum. We presented some slides about the learnings of building the next-generation Medicaid data warehouse on Amazon Web Services. I am not a Federal employee; I work at Nuna, subcontracted to QSSI to do this work.

Following are some quick thoughts and notes expanding on the presentation in

@jl
jl / gitgui.md
Last active August 28, 2018 00:40
git user interface productivity

gitk: visualize branches

gitk is useful for visualizing the history as a series of branching vertical lines, one commit per horizontal line:

# see history up to where I am
gitk

# see history on some other branch
gitk origin/master