Skip to content

Instantly share code, notes, and snippets.

View nathwill's full-sized avatar
🐜
doin' stuff

Nathan Williams nathwill

🐜
doin' stuff
  • Treehouse
  • Portland, OR
View GitHub Profile
@nathwill
nathwill / Vagrantfile
Last active December 17, 2015 18:49
chef-solo multi-vm vagrantfile
# vm and role mapping for multi-vm vagrant
boxes = [
{ :name => :app, :roles => ['base', 'web'] },
{ :name => :mc, :roles => ['base', 'memcache'] },
{ :name => :db, :roles => ['base', 'db-master'] },
{ :name => :util, :roles => ['base', 'redis', 'resque' ] },
]
Vagrant.configure("2") do |config|
# base image configuration
@nathwill
nathwill / gist:6441103
Created September 4, 2013 18:46
OpenVZ CPU Calculations
#!/usr/bin/env ruby
require 'fileutils'
def get_freq
File.readlines('/proc/cpuinfo').each do |line|
next unless line.match(/^cpu MHz/)
return line.split(/:/).last.strip.to_f * 1048576
end
end
@nathwill
nathwill / gist:8032248
Last active December 31, 2015 19:18
do crazy crazy shit with a backup file
#!/bin/bash
set -eu
# only run one instance
LOCKFILE=/tmp/pg_backup.lock
[ -f $LOCKFILE ] && { echo "Error: $LOCKFILE exists"; exit 1; } >&2
touch $LOCKFILE
@nathwill
nathwill / gist:9054335
Created February 17, 2014 16:49
centos docker built routine
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
auth --useshadow --enablemd5
selinux --disabled
rootpw --lock --iscrypted locked
zerombr
clearpart --all --initlabel
@nathwill
nathwill / pf.conf
Last active January 29, 2024 05:37
a dummy's sample pf.conf
# $OpenBSD: pf.conf,v 1.52 2013/02/13 23:11:14 halex Exp $
#
# See pf.conf(5) for syntax and examples.
#
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.
### Macros
# system
@nathwill
nathwill / ssh-audit.txt
Last active November 28, 2017 23:00
lazy audit logging
# Set up audit logging for connections outbound from the bastion
default['openssh']['client'].tap do |client|
client['permit_local_command'] = 'yes'
client['local_command'] = '/usr/bin/logger -p INFO -t AUTH %u signed into %h:%p as %r'
end
@nathwill
nathwill / chef_user_monkey_patch.rb
Last active August 29, 2015 14:06
chef user monkey patch for github ssh keys
require 'chef/resource/directory'
require 'chef/resource/file'
require 'chef/resource/remote_file'
require 'chef/resource/user'
require 'chef/provider/user'
class Chef
class Resource::TreehouseUser < Chef::Resource::User
def github_users(arg = nil)
set_or_return(
@nathwill
nathwill / Makefile
Last active August 29, 2015 14:07
snippet of packer-centric makefile
projs := $(basename $(wildcard *.json))
cmds := validate inspect build fix
aliases := bootstrap rebuild
# Enable packer debug logging
PACKER_LOG := 1
PACKER_LOG_PATH := /tmp/packer-debug
export PACKER_LOG PACKER_LOG_PATH
# call out rules that don't generate output
@nathwill
nathwill / json_decoder.lua
Created May 30, 2015 16:45
heka json decoder
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
Parses a payload containing JSON.
Config:
- type (string, optional, default nil):
@nathwill
nathwill / sensu_event.lua
Created June 5, 2015 18:12
sensu event encoder for heka
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
Encodes a heka message as a sensu event
Config:
- status_field (string, optional, default: status)