Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
View plantumlmagic.py
import urllib
import plantumlencoder
from IPython.core.magic import magics_class, cell_magic, Magics
from IPython.display import Image, SVG
@magics_class
class Plantuml(Magics):
@cell_magic
@fairchild
fairchild / timed_subprocess.rb
Last active Mar 21, 2017
method to wrap a subprocess in a timeout
View timed_subprocess.rb
require 'timeout'
SUBPROCESS_TIMEOUT = 90
def timed_shell_command(cmd)
begin
Timeout.timeout(SUBPROCESS_TIMEOUT) do
subprocess = IO.popen(cmd)
Process.wait subprocess.pid
unless $?.success?
@fairchild
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
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 => state.contracts.data;
const currentContractIdSelector = state => state.contracts.currentId;
const contractSelectors = {
contracts() {
createSelector([contractDataSelector],
View annotation.json
{"photo":
{"id":"straw00267"},
"annotations":[
{
"x":19,
"y":20,
"w":50,
"h":50,
"predictions": {
"green":0.2,
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
fairchild / upgrade_heroku_pg.sh
Created Dec 13, 2014
example script to upgrade a heroku postgresql database
View upgrade_heroku_pg.sh
#!/bin/bash
set -x
set -e
export APP_NAME=staging-webfarmforeman
export NEW_DB_NAME=HEROKU_POSTGRESQL_JADE
heroku addons:add pgbackups --app $APP_NAME
heroku addons:add heroku-postgresql:hobby-basic --app $APP_NAME
heroku pg:wait --app $APP_NAME
View pyoptics.py
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
# ----------------------------------------------------------------
You can’t perform that action at this time.