Skip to content

Instantly share code, notes, and snippets.


Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
fairchild / arduino_multibyte_serial_example.cpp
Created Apr 13, 2009
Simple updated examples of arduino serial communications
View arduino_multibyte_serial_example.cpp
/* ------------------------------------------------
* SERIAL COM - HANDELING MULTIPLE BYTES inside ARDUINO - 03_function development
* by beltran berrocal
* this prog establishes a connection with the pc and waits for it to send him
* a long string of characters like "hello Arduino!".
* Then Arduino informs the pc that it heard the whole sentence
* the same as examlpe 03 but it deploys 2 reusable functions.
* for doing the same job.
fairchild /
Created Dec 5, 2009
2 scripts that can be used to create an bootable EBS from a running instance. ami-4205e72b created with this process
#!/bin/bash -xe
fairchild /
Last active Sep 29, 2019
functions usefull in user-data deploy scrips.
fake_fuse () {
echo "hello faker fuse"
apt-get -y install libfuse2
cd /tmp ; apt-get download fuse
cd /tmp ; dpkg-deb -x fuse_* .
cd /tmp ; dpkg-deb -e fuse_*
cd /tmp ; rm fuse_*.deb
cd /tmp ; echo -en '#!/bin/bash\nexit 0\n' > DEBIAN/postinst
cd /tmp ; dpkg-deb -b . /fuse.deb
cd /tmp ; dpkg -i /fuse.deb
View logstash_indexer.conf
input {
redis {
host => ""
type => "redis-input"
# these settings should match the output of the agent
data_type => "list"
key => "logstash"
# We use json_event here since the sender is a logstash agent
message_format => "json_event"
fairchild / Gemfile
Created Dec 7, 2011
An example sinatra omniauth client app
View Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
gem 'thin'
import urllib
import plantumlencoder
from IPython.core.magic import magics_class, cell_magic, Magics
from IPython.display import Image, SVG
class Plantuml(Magics):
View object_and_module_grapher.rb
# jEdit :folding=explicit:collapseFolds=1:indentSize=2:tabSize=2:
# add requires here #{{{
# handle command line #{{{
def usage #{{{
puts <<-USAGE
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
fairchild / gist:262248
Created Dec 23, 2009
example of posting an anonymous gist with curl
View gist:262248
curl -i -F file_name[gistfile1]='foooo' -F file_contents[gistfile1]='abcde' -F file_ext[gistfile1]='.sh'
You can’t perform that action at this time.