Skip to content

Instantly share code, notes, and snippets.

@slumos
slumos / More generic
Created November 4, 2011 18:07
Find out-of-date ganglia metrics
~ 0% nc web-012 8649 | xml sel -T -t -m "/GANGLIA_XML/CLUSTER/HOST/METRIC[@TMAX > 0 and @TN > @TMAX]" -s A:T:L "parent::HOST/@NAME" -v "concat(parent::HOST/@NAME,' ',@NAME,' ',@TN,' > ',@TMAX)" -n
web-001.example.com disk_total 2507 > 1200
web-002.example.com load_one 72 > 70
web-003.example.com disk_total 1500 > 1200
web-005.example.com load_one 83 > 70
#compdef VBoxManage vbm
# Based on "Oracle VM VirtualBox Command Line Management Interface
# Version 3.2.0" and a close reading of _cvs from the ZSH functions
# directory. Options and arguments are manually specified, which may
# cause drift should VBoxManage change.
#
# 'vbm' is my alias, as typing CamelCase hurts my fingers:
# alias vbm='VBoxManage -q'
#
11/11/21 12:08:49 INFO bayes.BayesClassifierDriver: =======================================================
Confusion Matrix
-------------------------------------------------------
a b c d e f g h i j k l m n o p q r s t u <--Classified as
381 0 0 0 0 9 1 0 0 0 1 0 0 2 0 1 0 0 3 0 0 | 398 a = rec.motorcycles
1 284 0 0 0 0 1 0 6 3 11 0 66 3 0 1 6 0 4 9 0 | 395 b = comp.windows.x
2 0 339 2 0 3 5 1 0 0 0 0 1 1 12 1 7 0 2 0 0 | 376 c = talk.politics.mideast
4 0 1 327 0
@slumos
slumos / cron.erb
Created January 20, 2012 19:44
Generate a cron offset from an IP address (puppet template)
<%
seed = IPAddr.new(ipaddress).to_i
minutes_offset = (seed % 60) * 2
hour = (minutes_offset / 60) % 24
minute = minutes_offset % 60
-%>
<%= minute %> <%= hour %> * * * the-job
#! /bin/zsh
usage () {
echo "usage: ${0:t} [-f known_hosts] host..."
}
KNOWN_HOSTS="$HOME/.ssh/known_hosts"
expanded_hosts() {
case $(uname) in
file { '/dir':
ensure => directory,
purge => true,
recurse => true,
}
#! /usr/bin/zsh
user="$1"
env="$2"
shift 2
function usage {
cat <<EOF 2>&1
usage: app-run.sh user environment command args...
user - the user to run as
@slumos
slumos / ru.sh
Created September 23, 2012 05:22
#! /usr/bin/env zsh
user="$1"
env="$2"
function usage {
cat <<EOF 2>&1
usage: ru rails_user rails_env command args...
Run command as rails_user with RAILS_ENV=rails_env.
@slumos
slumos / roseq.sh
Created December 27, 2012 01:00
Get a random sequence from random.org
#! /bin/zsh
function usage {
print "$0:r max [min]" 1>&2
}
max=$1
min=${2:-1}
if [ -z $max ]; then
module MyApp
class Application < Rails::Application
# Allows us to read configuration from unconventional places
# (e.g. /etc).
#
# To use:
# config/config_paths.yml:
# development:
# config/blah: config/blah.yml
#