Skip to content

Instantly share code, notes, and snippets.

@geoffgarside
geoffgarside / zfs-diskmap.sh
Last active August 29, 2015 14:04
zfs-diskmap: appends the drive device name to lines in zpool status which are gptids
#!/bin/sh
gpart_list=$(gpart list)
IFS=''
zpool status $1 | while read -r line ; do
echo "$line" | grep "gptid/" >/dev/null
if [ $? -eq 1 ]; then
echo $line
continue
@geoffgarside
geoffgarside / graylog2-server
Created June 18, 2014 07:25
Graylog2 0.20 Service Scripts for FreeBSD
#!/bin/sh
#
# PROVIDE: graylog2_server
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable graylog2_server:
#
# graylog2_server_enable="YES"
@geoffgarside
geoffgarside / unbound-stats.rb
Created June 9, 2014 07:51
Unbound Control Stats Collector
#!/usr/bin/env ruby
#
# Unbound Stats Collector
# sends unbound-control stats output to a batsd/statsd server
#
#
# source 'https://rubygems.org'
# gem 'statsd-ruby'
#
@geoffgarside
geoffgarside / gist:6591770
Created September 17, 2013 08:47
Convert a semicolon separated values file into CSV with proper escaping of commas. Assumes theres are no double quotes in the file already.
awk '{ end=split($0,a,";"); result = a[1]; for(i = 2; i <= end; i++) { if (index(a[i], ",")) { a[i] = "\"" a[i] "\""; } result = result "," a[i]; } print result }'
#!/usr/bin/env ruby
#
cmdargs = ARGV.map do |arg|
arg = arg.strip
if arg.index(" ")
"\"#{arg}\""
else
arg
end
@geoffgarside
geoffgarside / rails4-ember-template.rb
Created July 20, 2013 18:07
Rails 4 Ember Application Template
# Rails 4 Ember Application Template
# vim: set sts=2 sw=2 et:
# Remove normal files we don't want
remove_file "README.rdoc"
remove_file "public/index.html"
remove_file "app/assets/images/rails.png"
# Copy database.yml to sample
inside "config" do
run "cp database.yml database.yml.sample"
@geoffgarside
geoffgarside / rails4-template.rb
Last active June 26, 2022 21:27
Rails 4 Application Template
# Rails 4 Application Template
# Remove normal files we don't want
remove_file "README.rdoc"
remove_file "public/index.html"
remove_file "app/assets/images/rails.png"
# Copy database.yml and secrets.yml to sample
inside "config" do
run "cp database.yml database.yml.sample"
run "cp secrets.yml secrets.yml.sample"
diff -ruN orig/ansible-1.1/docs/man/man1/ansible-doc.1 new/ansible-1.1/docs/man/man1/ansible-doc.1
--- orig/ansible-1.1/docs/man/man1/ansible-doc.1 2013-04-03 01:39:05.000000000 +0100
+++ new/ansible-1.1/docs/man/man1/ansible-doc.1 2013-06-10 21:00:05.000000000 +0100
@@ -2,12 +2,12 @@
.\" Title: ansible-doc
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\" Date: 04/02/2013
+.\" Date: 02/01/2013
.\" Manual: System administration commands
@geoffgarside
geoffgarside / easter.rb
Created April 10, 2013 09:22
Ruby Time class easter calculations, revived from a dead app :P
require 'time'
module EasterCalculations
extend ActiveSupport::Concern
module ClassMethods
def easter(year = nil)
y = year ||= now.year
c = y / 100
n = y - 19 * ( y / 19 )
#!/usr/bin/env ruby
require 'net/telnet'
prefix = ARGV.length > 1 ? ARGV[1] : nil
prefix_regexp = prefix && Regexp.new("\A#{prefix}")
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|