Skip to content

Instantly share code, notes, and snippets.

View danslimmon's full-sized avatar

Dan Slimmon danslimmon

View GitHub Profile
iab ienn if err != nil {
\<CR> return err
\<CR>}
function sshscreen() {
tmpfile=$(mktemp -t sshscreen-)
echo "exec ssh $*" > "$tmpfile"
chmod 755 "$tmpfile"
screen -s "$tmpfile"
}
@danslimmon
danslimmon / bob_log_grammar.rb
Created July 8, 2011 13:10
Factory/Dictionary solution to log grammar
class LogFormatElement
@_caster = nil
attr_accessor :abbrev, :name, :regex
# Class variables that determine the _default_ for abbrev, name, and regex in an instance.
# That is, an instance will initialize with these values for the instance variables @abbrev,
# @name, and @regex.
class << self; attr_accessor :abbrev, :name, :regex end
# Additionally we need to access this from within the instance:
class << self; attr_accessor :_caster end
@danslimmon
danslimmon / deprec_hook.rb
Created September 4, 2011 18:22
Deprecation git hook
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
# This is a git update hook that allows you to declare a given class
# or method or what-have-you deprecated. If you try to push deprecated
# code to the repo, you'll see an error and the push will fail. The
# error also gives you a string that you can stick in your commit
# message to bypass the deprecation rule.
@danslimmon
danslimmon / gist:1510628
Created December 22, 2011 15:11
chef runtimes => logstash
grok patterns:
CHEF_RUNTIME INFO: Chef Run complete in %{NUMBER:runtime} seconds
HOST_PART \b[A-Za-z][0-9A-Za-z-]{0,62}\b
HOST_FIRSTPART %{HOST_PART:hostname_short}
collector.conf:
filter {
dan@george:~$ echo union > foo.csv
dan@george:~$ file foo.csv
foo.csv: ASCII c program text
dan@george:~$ echo onion > foo.csv
dan@george:~$ file foo.csv
foo.csv: ASCII text
dan@george:~$ echo function > foo.csv
dan@george:~$ file foo.csv
foo.csv: ASCII text
dan@george:~$ echo typedef > foo.csv
#!/bin/bash
set -x
exec >/tmp/foo.log 2>&1
$ echo "uvoptcuce faimspz ara"|sed 'secede; severe; syzygy; samsara; serenade; seduceable; serpentine; strategist'
unadoptable fainting aegis
@danslimmon
danslimmon / gist:3822522
Created October 2, 2012 19:02
add_timestamps.pl
#!/usr/bin/perl
#
# What it does (example):
#
# dan@cleon:~/tools/server$ yes | ./add_timestamps.pl | head
# 2012-10-02 14:59:16.579109 y
# 2012-10-02 14:59:16.579180 y
# 2012-10-02 14:59:16.579210 y
# 2012-10-02 14:59:16.579240 y
# 2012-10-02 14:59:16.579269 y