Skip to content

Instantly share code, notes, and snippets.

View robdbirch's full-sized avatar

Robert Birch robdbirch

View GitHub Profile
@robdbirch
robdbirch / gist:a47d48876d1ede195152
Last active August 29, 2015 14:18
Ruby Thrift Code
# Add to Gemfile
# gem 'thrift'
# gem 'storm'
require 'storm'
# Ruby DRPC Snippet of Code
class StormRunner
  def submit_to_storm(service_name,data,host,port)
@robdbirch
robdbirch / Mock JSON Server
Last active August 29, 2015 14:15
Simple http to serve up mock JSON for simple integration testing
#!/usr/bin/env ruby
require 'optparse'
require 'webrick'
require 'pp'
options = { :port => 8080, :root => '.' }
OptionParser.new do |opts|
opts.banner = 'Usage: dataServicesServer.rb -p port -r web_root'
@robdbirch
robdbirch / mavenrepo.md
Last active August 29, 2015 14:13
Maven Repository in less than 15 minutes

This cheat sheet will enable you to setup a private Maven repository to store only your business libraries. It should take about 15 minutes with very little administrative hassle to set up and maintain.

Caveat Emptor

This is NOT the recommended practice for deploying a Maven repository. The main reason this is not the recommended installation practice is this installation does not take advantage of the Nexus servers ability to proxy, manage and cache other library assets from other repositories. There are an abundant number of voluminous documents and stackoverflow questions that will show the "correct way everybody should deploy a Maven repo". Here are some links to docs and discussions:

#Detecting Native Gems
#Gems using native libraries can be detected through a Gemfile.lock file.
bundle exec ruby -e 'puts Gem.loaded_specs.values.select{ |i| !i.extensions.empty? }.map{ |i| i.name }'
@robdbirch
robdbirch / gist:5608735
Created May 19, 2013 19:43
God server transitions
def life_cycle(w)
w.lifecycle do |on|
on.condition(:flapping) do |c|
c.to_state = [:start, :restart]
c.times = 5
c.within = 5.minute
c.transition = :unmonitored
c.retry_in = 10.minutes
c.retry_times = 5
c.retry_within = 2.hours
@robdbirch
robdbirch / gist:5608719
Created May 19, 2013 19:39
God Middleware Condition
def middleware_up?
gps = God.status
applog @watch, :debug, "God Status: #{gps.inspect}"
(gps['mongo'][:state] == :up) and (gps['apollo'][:state] == :up)
end
class MiddlewareRunning < God::PollCondition
def initialize
@robdbirch
robdbirch / gist:5608704
Created May 19, 2013 19:36
God Mongo Shutdown function
def m_shutdown()
m = <<-mongo_shutdown
/usr/local/bin/mongo<<-md
use admin
db.shutdownServer()
exit
md
mongo_shutdown
end
@robdbirch
robdbirch / gist:5608547
Last active December 17, 2015 12:19
God with Boot Order Dependencies

God and Boot Order Dependencies

I noticed quite a few questions on how to support boot order dependencies using God. Below are instructions on how I used the God DSL to ensure process boot order.

Conditions of God

A new God Condition is needed and it must inherit from one of the God Condtion classes. A new condition has the following requirements:

  • Condition class name is camel case
  • Is derived from one of three Condition classes