Skip to content

Instantly share code, notes, and snippets.


Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
import urllib
import plantumlencoder
from IPython.core.magic import magics_class, cell_magic, Magics
from IPython.display import Image, SVG
class Plantuml(Magics):
fairchild / timed_subprocess.rb
Last active Mar 21, 2017
method to wrap a subprocess in a timeout
View timed_subprocess.rb
require 'timeout'
def timed_shell_command(cmd)
Timeout.timeout(SUBPROCESS_TIMEOUT) do
subprocess = IO.popen(cmd)
unless $?.success?
fairchild / mobile_data_creation_first.websequence
Created Mar 31, 2016
sync flow for data created on mobile first
View mobile_data_creation_first.websequence
title Create Data Mobile First
participant mobile as m
participant server as s
participant database as db
m -> m: create item {uuid}
m -> s: POST item {uuid}
s -> db: begin transaction
s -> db: SELECT id, uuid WHERE uuid={uuid} from write_log
View hammerspoon.cfg
local application = require "hs.application"
local tiling = require "hs.tiling"
local hotkey = require "hs.hotkey"
local Spotify = require "hs.spotify"
-- TODO: Move more stuff into these
-- custom scripts
require "sizeup"
require "triggers"
fairchild / .babelrc
Last active Dec 29, 2015
simple example of getting babel 6 running
View .babelrc
"presets": ["es2015"]
View exampleSelector.js
import { createSelector } from 'reselect';
import _ from 'lodash';
const contractDataSelector = state =>;
const currentContractIdSelector = state => state.contracts.currentId;
const contractSelectors = {
contracts() {
View annotation.json
"predictions": {
View gist:bbd03a071fe3e9d59712
id: 1,
name: "1",
number: 1,
lat: "34.179444444",
lng: "-119.140961111",
latlng: null,
planted_at: null,
uuid: "f97e61a0-6647-0132-d30b-5651f5fc0983",
rev: "19-1a2b076b1a5a756ff8fec30e8b4c2fd6",
fairchild /
Created Dec 13, 2014
example script to upgrade a heroku postgresql database
set -x
set -e
export APP_NAME=staging-webfarmforeman
heroku addons:add pgbackups --app $APP_NAME
heroku addons:add heroku-postgresql:hobby-basic --app $APP_NAME
heroku pg:wait --app $APP_NAME
import numpy as np, matplotlib.pyplot as plt
# ----------------------------------------------------------------
# simply draws a thin-lens at the provided location
# parameters:
# - z: location along the optical axis (in mm)
# - f: focal length (in mm, can be negative if div. lens)
# - diam: lens diameter in mm
# - lbl: label to identify the lens on the drawing
# ----------------------------------------------------------------