Skip to content

Instantly share code, notes, and snippets.

@mudge
mudge / logstash.conf
Last active April 17, 2019 07:58
A grok pattern for Rails 3.2 logs for use with logstash. Assumes that you have a multiline filter to combine Rails logs into one line and only one worker is logging to a file (c.f. https://gist.github.com/mudge/5063930).
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
}
@stefanozanella
stefanozanella / description.md
Created December 2, 2012 20:30
Puppet implementation patterns: Test with External Function

Test with External Function

When

You want to test a resource definition (class, defined type) that uses a function provided by a third-party module your module depends upon. It's supposed that you're implementing your tests with rspec-puppet.

How

@lemonlatte
lemonlatte / addUser.sh
Created July 9, 2012 03:22
Login authentication from a LDAP server
#!/bin/sh
dn='dc=math,dc=nccu,dc=edu,dc=tw'
username='jim.yeh'
uid='jim.yeh'
gid='student'
cat << EOF > user_example.ldif
dn: cn=$username,ou=users,ou=login,$dn
@halkeye
halkeye / sorted_json.rb
Created April 2, 2012 23:13
Puppet module for outputting json in a sorted consistent way
#
# sorted_json.rb
# Puppet module for outputting json in a sorted consistent way. I use it for creating config files with puppet
require 'json'
def sorted_json(json)
if (json.kind_of? String)
return json.to_json
elsif (json.kind_of? Array)
@wyattanderson
wyattanderson / gist:1264760
Created October 5, 2011 15:38
Unique Hostname Colorization
# Calculate a short checksum of the real hostname to determine a unique color
if [[ $TERM =~ "256color" ]]; then
host_color="38;5;$((16 + $(hostname | cksum | cut -c1-3) % 256))";
else
host_color="1;$((31 + $(hostname | cksum | cut -c1-3) % 6))";
fi