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 / logstash_indexer.conf
Created July 2, 2012 01:53
Logstash config example
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 / setup.sh
Created July 1, 2012 21:22
Setup a Ubuntu 12.04 server for serving a ruby and nodejs apps
#!/bin/bash
set -x
set -e
# Setup a new ubuntu 12.04 server
# this file can be used as the userdata file for a new instance.
# It should set any environments variables needed, and select which setup functions to run, in what order.
USERNAME=${1:-deploy}
APPNAME=${2:-deploy}
@fairchild
fairchild / kiss.rb
Created May 30, 2012 04:48
Faraday KissMetrics API wrapper
require "rubygems"
require "em-synchrony"
require "em-synchrony/em-http"
require 'faraday'
class Kiss
# post event data to kiss_metrics API
def self.send(data)
@conn ||= Faraday.new(:url => 'https://trk.kissmetrics.com/', :ssl => {:ca_path => "/usr/lib/ssl/certs"}) do |builder|
builder.response :logger
@fairchild
fairchild / es.sh
Created May 20, 2012 22:33 — forked from shaneog/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get install unzip
sudo apt-get install python-software-properties -y
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
@fairchild
fairchild / update_existing_hash.rb
Created April 15, 2012 16:52
merge a hash, only updating the first hash with values from the second where the first
# merge a hash, only updating the first hash with values from the second where the first already has an exisitng key
# for example,
# a= {"a"=>1, "b"=>2, "z"=>3}
# b= {"x"=>99, "y"=>88, "z"=>77}
# will result in {"a"=>1, "b"=>2, "z"=>77}
def update_existing(a, b)
a.inject({}){|sum, el| (b.has_key?(el.first) && b[el.first]) ? sum.update(el.first=>b[el.first]) : sum[el.first]=a[el.first]; sum}
end
@fairchild
fairchild / Gemfile
Created December 7, 2011 09:58
An example sinatra omniauth client app
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'
@fairchild
fairchild / bootstrap.haml.rb
Created December 7, 2011 09:34
haml layout for using bootstrap
@@ layout
%html
%head
%link(rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css")
%body
.container
.content
= yield
#!/usr/bin/env ruby
require 'pry'
require 'ticketmaster'
require 'ticketmaster-redmine'
require 'ticketmaster-kanbanpad'
def redmine(opts={})
@redmine ||= TicketMaster.new(:redmine, {:username => "fairchild", :password => "me", :server => "https://tracker.tfoundry.com/"})
end
@fairchild
fairchild / ubuntu11.10-gems.sh
Created October 26, 2011 06:40
Bootstap a base ubuntu installation to be a chef-client
# Prepare a node to run chef-client
# Apt-install various things necessary for Ruby, guest additions,
# etc., and remove optional things to trim down the machine.
apt-get -y update
apt-get -y upgrade
apt-get -y install
# Install build requirements for common ruby packages
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libxml2-dev libxslt1-dev
@fairchild
fairchild / temperature-gmetric.rb
Created October 21, 2011 06:30
send a temperature value to ganglia
#!/usr/bin/ruby
# apt-get install freeipmi-tools ruby rubygems
# gem install gmetric
require 'rubygems'
require 'gmetric'
require "socket"