Skip to content

Instantly share code, notes, and snippets.

View relistan's full-sized avatar

Karl Matthias relistan

View GitHub Profile
@relistan
relistan / dnsd.rb
Last active December 9, 2015 23:39 — forked from peterc/dnsd.rb
A Ruby 1.8.7 (for MagLev) port of Peter Cooper's DNS server example.
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
# Ruby 1.8.7/MagLev version by Karl Matthias
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@relistan
relistan / captureio.coffee
Created December 1, 2012 16:59 — forked from pguillory/gist:729616
Hooking into Node.js stdout
class CaptureIO
# Coffeescript port of: https://gist.github.com/729616
#
# Usage:
# test = new CaptureIO()
# unhook = test.hookStdout((string, encoding, fd) ->
# util.debug('stdout: ' + util.inspect(string))
# )
# Restoring stdout:
@relistan
relistan / ssh_config
Created July 7, 2012 09:45
Keep SSH Alive Even on Virgin Media
Host *
ServerAliveInterval 10
ServerAliveCountMax 600
@relistan
relistan / git_commands.md
Created March 31, 2012 11:45
Deployment with Git detection of pending migrations

Helpful Git Commands

These are some useful git commands for implementing this in your own deployment setup.

Detecting if we're running on a clean checkout:

  • git fetch
  • git diff --shortstat [branch]

Determining if there are pending migrations:

@relistan
relistan / out.txt
Created June 23, 2014 22:25
Validating Centurion
kmatthias-mbp:dockercon kmatthias$ bundle exec centurion -p test -e production -a deploy
** Invoke environment:production (first_time)
** Invoke environment:common (first_time)
** Execute environment:common
** Execute environment:production
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:get_image (first_time)
** Execute deploy:get_image
** Invoke deploy:pull_image (first_time)
@relistan
relistan / Services Layout.md
Last active August 29, 2015 14:02
Centurion with etcd Proof-of-Concept

Services Layout

The following code run from inside a Ruby script that has loaded the etcd gem would create the necessary keys to deploy using the above code.

client.set('/services/fooservice/ports/3021', value: 9292)
client.set('/services/fooservice/env/TESTING_URL', value: 'http//foo.example.com/asdf')
@relistan
relistan / gist:53be1fc306543df4ffdd
Created May 29, 2014 18:37
etcd service discovery and configuration schema
client.set('/services/fooservice/ports/3021', value: 9292)
client.set('/services/fooservice/env/TESTING_URL', value: 'http//foo.com/asdf')
client.set('/services/fooservice/hosts/chi-staging-foo-1.nr-ops.net', value: 'up')
client.set('/services/fooservice/hosts/chi-staging-foo-2.nr-ops.net', value: 'up')
client.set('/services/fooservice/hosts/chi-staging-foo-3.nr-ops.net', value: 'down')
client.set('/services/fooservice/endpoints/chi-staging-foo-1.nr-ops.net', value: 'http://chi-staging-foo-1.nr-ops.net:3021/')
client.set('/services/fooservice/endpoints/chi-staging-foo-2.nr-ops.net', value: 'http://chi-staging-foo-2.nr-ops.net:3021/')
client.set('/services/fooservice/endpoints/chi-staging-foo-3.nr-ops.net', value: 'http://chi-staging-foo-3.nr-ops.net:3021/')
@relistan
relistan / gist:9648383
Last active August 29, 2015 13:57
Inspect the remotes for a directory full of git repos, filtering for newrelic
#!/bin/bash
REPOS=""
for config in `find . -maxdepth 3 -name config | grep '.git'`; do
egrep "github.com:newrelic|github.com/newrelic" $config > /dev/null
if [[ $? -eq 0 ]]; then
repo_dir=`dirname $(dirname ${config})`
REPOS="${REPOS} `basename ${repo_dir}`"
fi
done