Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
@fairchild
fairchild / fogtest.rb
Created February 28, 2014 02:16
simple check if fog is working wtih cloud endpoint
require 'fog'
auth_url = ENV['OS_AUTH_URL']
username = ENV['OS_USERNAME']
password = ENV['OS_PASSWORD']
tenant = ENV['OS_TENANT_NAME'] # String
compute_client ||= ::Fog::Compute.new(:provider => :openstack,
:openstack_api_key => password ,
:openstack_username => username ,
@fairchild
fairchild / m2x-simple-example.js
Last active August 29, 2015 13:58
super simple m2x api example
<!doctype html>
<html>
<head>
</head>
<body>
<form id='m2xform' action="#">
<input name='m2xApiKey' placeholder='m2x api key' value='3fef5d69c3a7eab559b733ba854baef1' >
</form>
<pre id='m2xexample'>m2x</pre>
Merb.logger.info("Compiling routes...")
Merb::Router.prepare do |r|
# RESTful routes
r.resources :songs
# This is the default route for /:controller/:action/:id
# This is fine for most cases. If you're heavily using resource-based
# routes, you may want to comment/remove this line to prevent
@fairchild
fairchild / designer.html
Created August 10, 2014 07:07
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
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
# ----------------------------------------------------------------
@fairchild
fairchild / upgrade_heroku_pg.sh
Created December 13, 2014 00:26
example script to upgrade a heroku postgresql database
#!/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
{
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",
{"photo":
{"id":"straw00267"},
"annotations":[
{
"x":19,
"y":20,
"w":50,
"h":50,
"predictions": {
"green":0.2,
@fairchild
fairchild / Grep in Project.tmCommand
Created August 7, 2008 02:19 — forked from lmarlow/Grep in Project.tmCommand
textmate grep in project bundle
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>5A9D4FC6-6CBE-11D9-A21B-000D93589AF6</string>
<key>command</key>
<string>#!/usr/bin/env ruby -rcgi
def parameterize(xml)
xml.gsub!('{iterator}', iterator_id.blank? ? 'Start' : 'Continue')
xml.gsub!('{iterator_id}', iterator_id || '')
xml.gsub!('{from_modified_date}', ((transactions_last_synced_on || 10.years.ago) - 1.day).to_s(:qb_date))
xml.gsub!('{to_modified_date}', (Time.now + 1.day).to_s(:qb_date))
xml
end