Skip to content

Instantly share code, notes, and snippets.

View rlister's full-sized avatar
💭
wfh

Ric Lister rlister

💭
wfh
View GitHub Profile
@rlister
rlister / Dockerfile
Last active February 22, 2017 05:57
Example Dockerfile for NewRelic sysmond
FROM busybox:ubuntu-14.04
MAINTAINER rlister@spreecommerce.com
ENV VERSION 2.3.0.132
ADD https://download.newrelic.com/server_monitor/release/newrelic-sysmond-${VERSION}-linux.tar.gz .
RUN tar zxvf newrelic-sysmond-${VERSION}-linux.tar.gz && \
rm -f newrelic-sysmond-${VERSION}-linux.tar.gz
WORKDIR /newrelic-sysmond-${VERSION}-linux
@rlister
rlister / nginx.conf
Created September 22, 2015 20:36
Running docker registry on fleet
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
@rlister
rlister / autoscaling.rb
Created August 21, 2015 17:27
creates capistrano autoscaling_servers command to get instance list from AWS autoscaling groups
require 'aws-sdk-v1'
require 'capistrano/framework'
@autoscaling_groups = []
def autoscaling_servers(opts = {})
Array(opts[:regions]).each do |region|
AWS::AutoScaling.new(region: region).groups[opts[:group]].tap do |group|
@autoscaling_groups.push(group)
end.ec2_instances.each do |instance|
FROM busybox
MAINTAINER Ric Lister <rlister@gmail.com>
## busybox wget cannot do https, so grab curl binary
ENV CURL_VERSION 7.30.0
RUN (wget -O - http://www.magicermine.com/demos/curl/curl/curl-${CURL_VERSION}.ermine.tar.bz2 | bunzip2 -c - | tar xf -) \
&& mv /curl-${CURL_VERSION}.ermine/curl.ermine /bin/curl \
&& rm -rf /curl-${CURL_VERSION}.ermine
WORKDIR /app
@rlister
rlister / iterm.pl
Created October 15, 2014 02:12
open ssh to list of hosts in iterm tabs
#!/usr/bin/env perl
use strict;
use warnings;
## use applescript to start multiple iTerm tabs with ssh into listed hosts
##
## usage:
##
## iterm.pl host1 host2
@rlister
rlister / gist:1e8025c0f97b2482b4b2
Created August 27, 2014 19:57
force ohai ec2 plugin for aws instances
## for an unknown reason, on a subset of instances the
## ohai ec2 data is not populated unless this file exists
## so touch it until we figure out why
[ '/etc/chef', '/etc/chef/ohai', '/etc/chef/ohai/hints' ].each do |dir|
directory(dir).run_action(:create)
end
## this plugin file just needs to exist to able the plugin
ec2_json = file '/etc/chef/ohai/hints/ec2.json' do
@rlister
rlister / foreman.rb
Created June 9, 2014 16:43
foreman export from capistrano, then restart application using monit
## export upstart config using foreman
namespace :foreman do
desc "Export Procfile to upstart"
task :export do
links = {
'.env' => "~#{fetch(:foreman_user)}/#{fetch(:application)}/env",
'.foreman' => "~#{fetch(:foreman_user)}/#{fetch(:application)}/foreman",
}
on roles(:app) do
@rlister
rlister / gist:8423677
Created January 14, 2014 18:54
LIMIT clause without value triggers segmentation violation: select * from /.*/ limit;
2014/01/14 18:49:08 http: multiple response.WriteHeader calls
SIGSEGV: segmentation violation
PC=0x412f84
signal arrived during cgo execution
runtime.cgocall(0x412e40, 0x7fdfa0134778)
/home/vagrant/bin/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x7fdfa0134760
parser._Cfunc_parse_query(0x27dc340, 0xc2102cae40, 0x27dc340, 0x7, 0xc2101da5c0)
parser/_obj/_cgo_defun.c:71 +0x31 fp=0x7fdfa0134778
parser.ParseQuery(0xc2102cac60, 0x18, 0x0, 0x0, 0x0, ...)
class BluepillOverride
def self.provider
Class.new(Chef::Provider::BluepillService) do
def shell_out!(*args)
args.each do |command|
rvm_shell "#{command}" do
code command
end
end
end
## gather mongo-related stats and jam them into graphite
require 'mongo'
## method to convert nested hash to array of dot-separated properties
class Hash
def propertize(prepend=nil)
self.map do |key,value|
new_key = [prepend, key].compact.join('.')
value.is_a?(Hash) ? value.propertize(new_key) : "#{new_key} #{value.to_s}"
end.flatten