Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
@fairchild
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
fairchild / bundle-to-ebs.sh
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
View bundle-to-ebs.sh
#!/bin/bash -xe
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
AKI=${2:-'aki-5f15f636'}
ARI=${3:-'ari-0915f660'}
ARCH=${4:-'i386'}
SIZE=${5:-10}
AZ=${6:-'us-east-1d'}
NAME=${7:-"ami-from-$INSTANCE_ID"}
@fairchild
fairchild / user_data_functions.sh
Last active Sep 29, 2019
functions usefull in user-data deploy scrips.
View user_data_functions.sh
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 => "127.0.0.1"
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
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'
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
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
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
@fairchild
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' http://gist.github.com/gists
You can’t perform that action at this time.