Skip to content

Instantly share code, notes, and snippets.

View skippy's full-sized avatar

Adam Greene skippy

  • San Juan County, WA
View GitHub Profile
@skippy
skippy / README.md
Created January 31, 2015 21:53
localshred/protobuf vs protobuf-ruby/beefcake

Overview:

  • speed 'champ': protobuf
  • namespacing: protobuf (beefcake doesn't support it 'out of the box')
  • rubyness: beefcake by a nose

notes:

  • performance isn't everything, though I was surprised how much protobuf seemed to be ahead. These are very basic benchmarks, and your milage may, and probably will (!), vary. I noticed without strings protobuf was about 1/2 faster, but when including strings, that dropped to about 1/3 faster.
  • I like namespacing. If I'm going to go through the 'hassle' of putting a schema and DSL onto my wire definitions, then namespacing is more than a nice-to-have. Beefcake has a way to add it during build-time via the shell ENV, but protobuf wins a bit by just getting 'er done.
@skippy
skippy / docker.sh
Last active August 29, 2015 14:12
modifying the docker host's /etc/hosts file with the location of a private docker-registry so we don't need to restart the docker daemon (and force all the containers to restart0
# run from a coreos fleet file; change as you see fit
# NOTE: this shares the /etc folder with docker; ugh!
# using multiple -v doesn't seem to work (as consul-template
# does atomic writes, which requires writing a tmp file
# then moving it).
docker run --rm \
--name docker-registry \
-e SERVICE_IGNORE=1 \
-v /etc:/configs \
skippy/consul-template \
@skippy
skippy / boot.sh
Last active September 27, 2020 17:54
starting a consul cluster via fleet. 3 servers are started, and clients fill out the rest of the fleet. If you want to get specific, add `MachineMetadata` to specifically place where consul-servers will spend up
#!/bin/bash
# set -eo pipefail
export CONSUL_NUM_INSTANCES=${CONSUL_NUM_INSTANCES:-3}
echo " => stopping consul"
fleetctl stop -block-attempts=10 \
$(eval echo "consul-server@{1..$CONSUL_NUM_INSTANCES}.service") \
consul-agent.service
# FIXME: sometimes it takes awhile for systemd to stop things...
@skippy
skippy / cloud-config.yml
Created December 31, 2014 18:38
modifying fleet metadata (from aws meta-data service) before fleet.service start; this is a proof of concept (but it works!)
#cloud-config
---
coreos:
units:
- name: update-fleet-metadata.service
command: start
content: |-
[Unit]
Description=Update Fleet metadata tag
Before=fleet.service
@skippy
skippy / bootstrap.sh
Last active August 29, 2015 14:06
sample shell script execution from curl
#!/usr/bin/env sh
echo "Hello World"
@skippy
skippy / gist:1433920
Created December 5, 2011 15:16
safely call hoptoad
module MyApp
class Notifier
class << self
def notify(*args)
safely_trigger(Airbrake, :notify, args)
end
def safely_trigger(klass, method, args)
#simple, safe; heavy but it isn't called very often!
@skippy
skippy / source-complex.rb
Created September 16, 2011 05:18
chef nginx source.rb
# NOTES ON CHANGE:
# * runit_service will launch the service, so put it at the end
# * because of the immediate restart needs, do some ugly stuff at the end to deal with that
# * concern: TOO complex; the immediate restarts should not be needed...
#
#
# Cookbook Name:: nginx
# Recipe:: source
#
# Author:: Adam Jacob (<[email protected]>)
@skippy
skippy / gist:1108661
Created July 27, 2011 04:17
knife search node "name:i-2f525a41" -l
$ knife search node "name:i-2f525a41" -l
1 items found
Node Name: i-2f525a41
Environment: development
FQDN:
IP:
Run List:
Roles:
Recipes
@skippy
skippy / embed.js
Created July 5, 2011 06:46
require within own namespace
window.myApp = window.myApp || {};
(function( myApp, undefined ) {
var require, define;
(function () {
//wrap require.js in our namespace!
var version = "0.24.0".........
}());
myApp.require = require;
@skippy
skippy / Node::Attribute#[]
Created July 4, 2011 08:13
ssh_known_hosts
def [](key)
@current_nesting_level << key
# We set this to so that we can cope with ||= as a setting.
# See the comments in []= for more details.
@has_been_read = true
# If we have a set type, our destiny is to write
if @set_type
a_value = @set_type == :automatic ? value_or_descend(current_automatic, key, auto_vivifiy_on_read) : nil