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
#!/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
#!/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
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 / vsp
Last active August 29, 2015 14:13
A vim wrapper to automatically open files in vsplit in the correct order, passing through arguments correctly
#!/bin/bash
PARAM_OPTS=( )
function get_param_opts {
(( ${#PARAM_OPTS[@]} > 0 )) && return
PARAM_OPTS=( $( vim -h | sed -n -e '/^ *-[-a-z]* </s/ <.*$//p' ) )
}
vim_args=""
files=( )
_virsh_vm_name()
{
virsh list --all --name "${@}"
}
_virsh_vol_name()
{
virsh vol-list default | sed '1,2d' | awk '{print $1}'
}
@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