Skip to content

Instantly share code, notes, and snippets.

View tobert's full-sized avatar
💭
🏳️‍🌈 💻 🏳️‍🌈

Amy Tobey tobert

💭
🏳️‍🌈 💻 🏳️‍🌈
View GitHub Profile
@tobert
tobert / nagios_snpp.pl
Created May 11, 2011 18:02
Ancient 2-way SNPP script
#!/usr/local/bin/perl
use strict;
use Getopt::Std;
use Net::SNPP;
use Fcntl ':flock';
use Sys::Syslog qw( :DEFAULT setlogsock );
# This is some really ancient code I wrote in ~2003 to do 2-way SNPP
# with Nextel phones so a handset could ack notifications from Nagios
# before web access was widely available.
@tobert
tobert / config.ru
Created May 18, 2011 02:01
Gollum rackup for Unicorn
$: << 'lib'
require 'rubygems'
require 'gollum'
require 'gollum/frontend/app'
use Rack::ShowExceptions
Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:wiki_options, {})
@tobert
tobert / nssh.rb
Created June 9, 2011 06:07
SSH wrapper for working with screen & clusters
#!/usr/bin/env ruby
# This script does minimal arg parsing to filter out SSH arguments to
# be mostly compatible with plain SSH command line syntax. It's not
# 100% but good enough.
#
# usage: nssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
# [-D [bind_address:]port] [-e escape_char] [-F configfile]
# [-i identity_file] [-L [bind_address:]port:host:hostport]
# [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
al@al-dev1 ~/src/puppet $ git checkout 2.7.1
HEAD is now at a23e391... Updating for 2.7.1 release.
# system puppet was built from this tree
# I also cleaned it out once to be sure all of the old 2.5 stuff was gone
al@al-dev1 ~/src/puppet $ bin/puppet agent -h
/usr/lib/ruby/1.8/puppet/application/agent.rb:5: undefined local variable or method `should_parse_config' for Puppet::Application::Agent:Class (NameError)
from /usr/lib/ruby/1.8/puppet/util/command_line.rb:54:in `require'
from /usr/lib/ruby/1.8/puppet/util/command_line.rb:54:in `require_application'
from /usr/lib/ruby/1.8/puppet/util/command_line.rb:59:in `execute'
from bin/puppet:4
@tobert
tobert / ssh_config
Created July 1, 2011 17:25
ssh_config head
KeepAlive yes
ForwardAgent yes
ForwardX11 no
EscapeChar `
ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto
ControlPersist yes
@tobert
tobert / write_gpt.sh
Created July 11, 2011 02:35
GPT partitioning function
#!/bin/bash
# Compute partition sizes based on system memory (swap) and disk size.
# There is no /boot because grub2 uses the BIOS Boot Partition (EF02)
# to write out the payloads that used to have to be in /boot at the
# front of the disks.
# The EFI Partition will end up unused on all of our legacy BIOS-only
# systems, but it's only 128MB and can remain consistent as the EFI/UEFI
# systems take over.
@tobert
tobert / linux.rules
Created July 21, 2011 02:24
permissions rules format
# Default Linux filesystem permission rules.
#
# This is an experimental configuration format for applying filesystem permissions
# after pushing fs data from git. Since git doesn't support more than very simple permissions
# something like this is needed afterwards. The goals here are to be terse, parseable at a glance,
# and comprehensive for basic unix. The "unix" prefix is there so that other models like "pacl"
# (POSIX ACL) can be added in later if it becomes necessary.
#
# format: unix <path>:<dir mode>:<file mode>:<owner>:<group>:<depth>
# path, required, a path on the filesystem, must start with /
@tobert
tobert / ruby-taskset.sh
Created August 1, 2011 18:11
Improve ruby's performance by locking to a single CPU
#!/bin/bash
# Ruby's GIL is a liability when actually doing CPU work
# on a large SMP machine, doubly so on NUMA. This works around it.
# Ruby processes are locked onto a single core + its HT sibling
# on intel machines, 2 cores on AMD. Ideally this would lock to
# one core on non-HT processors, but all of mine are HT so it WFM.
max_cpu=$(cat /proc/cpuinfo |awk -F ': ' '/processor/{print $2}' |tail -n 1)
@tobert
tobert / gist:1133130
Created August 9, 2011 00:24
side load cgroups into Debian init scripts
# put this fragment in a daemon's /etc/default/$NAME file to side-load
# putting that daemon into a cgroup automatically
ulimit -l unlimited
NOW=$(date +%s)
APPLICATION=$(basename $0 |sed -r -e 's/\.init$//' -e 's/-(dev|prod|staging|perf)$//')
INSTANCE=$(basename $0 |sed -r -e 's/\.init$//' -e 's/.*-(dev|prod|staging|perf)$/\1/')
# gross default that assumes unnamed instances are production
@tobert
tobert / test01.conf
Created August 21, 2011 19:59
A known-working LXC config file I've used with Gentoo & Debian
lxc.utsname = test01.tobert.org
lxc.rootfs = /srv/md0/lxc/test01
#lxc.tty = 1
lxc.console = /tmp/test01-console.log
lxc.cgroup.cpuset.cpus = 0
lxc.cgroup.cpu.shares = 100
lxc.mount.entry=none proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry=none dev/shm tmpfs defaults 0 0
lxc.mount.entry=none dev/pts devpts defaults 0 0