Skip to content

Instantly share code, notes, and snippets.

# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
# include collections::test
class collections::test {
# Contains tests of the collections constructs
class collections::file_test {
# This resource will create File['tmp/collections-file-test'],
# setting content => template('collections/file-test.erb'),
# with a $data variable merging the stanza below with all of the
# following fragments.
collections::file { '/tmp/collections-file-test':
collector => 'file-test',
template => 'collections/file-test.erb',
data => {
class collections::test {
# Contains tests of the collections constructs
# Define an iterator stack
collections::create { 'foo':
}
# Add a thing for the stack to do:
# collections::tap is a defined type that will create a notify resource containing its parameters
#!/usr/bin/ruby
# THIS FILE IS MANAGED BY PUPPET
require 'zbxapi'
require 'pp'
zbx = ZabbixAPI.new('http://localhost/zabbix/api_jsonrpc.php', verify_ssl: false, http_timeout: 300)
zbx.login('<%= @admin_user %>', '<%= @admin_password %>')
#!/bin/bash
# Zabbix LLD to show mounted filesystems that use true block devices (for use with items such as vfs.dev.read/write)
exec 3<"/proc/mounts"
echo -n '{"data":['
opts=( FSDEV FSNAME FSTYPE FSOPTS FSDUMPFREQ FSDUMPPASS )
linesep="" while read -u3 -a line; do
[[ -b "${line[0]}" ]] || continue echo -n "$linesep" linesep="},"
sep='{'
i=0
#!/bin/bash
if (( $(id -u) != 0 )); then
echo "This script must be run as root"
exit 127
fi
opt_exit_status=0
write_diff="overlay.diff"
@ccooke
ccooke / code
Created September 24, 2013 18:09
An incomplete probability function, with a manual example of some prospective code to work on it.
class ProbabilityDensity < Array
def probability
Rational(1,count)
end
def to_density
if block_given?
each do |v|
if v.respond_to? :probability
@ccooke
ccooke / gist:6665672
Created September 23, 2013 01:59
A dice expression parser
require 'securerandom'
require 'strscan'
require 'pp'
module Dice
class Parser
module Term
class Number
attr_accessor :number, :value, :math_symbol
@ccooke
ccooke / gist:6664274
Created September 22, 2013 21:58
a partial dice expression grammar
module Dice
class Parser
attr_reader :terms
EXPRESSION = %r{^
(?<conditional> > | < | = | ){0}
(?<condition> \g<conditional> (?<condition_number> \d+ ) ){0}
(?<penetrating> !p ){0}
@ccooke
ccooke / self_destruct.rb
Created June 20, 2012 13:53
String/Hash/Array self-destruction
# Considered adding this to Object, but that's a much more complex job. This gets the work done.
class Hash
def self_destruct!
self.each do |k,v|
v.self_destruct! if v.respond_to? :self_destruct!
self[k] = nil
self.delete k
end
end