Skip to content

Instantly share code, notes, and snippets.

@cprice404
cprice404 / acceptance-config.yaml
Created March 23, 2012 21:31
config files on acceptance vms
HOSTS:
pe-ubuntu-lucid:
roles:
- master
platform: ubuntu-10.04-i386
pe-centos6:
roles:
- agent
platform: el-6-i386
CONFIG:
@cprice404
cprice404 / puppet
Created May 17, 2012 21:26
Callgrind profile data for a puppet client run
#!/usr/bin/env ruby
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::PROCESS_TIME
#RubyProf.measure_mode = RubyProf::ALLOCATIONS
#RubyProf.measure_mode = RubyProf::MEMORY
RubyProf.start
begin
@cprice404
cprice404 / benchmark_sql_limit.clj
Created August 1, 2012 00:23
SQL query limit/fetchSize profiling
(ns foo
(:use [criterium.core])
(:require [clojure.java.jdbc :as sql]
[clojure.java.jdbc.internal :as sql-internal]))
(defn my-bench [desc f]
(println (format "\n
Beginning benchmark for '%s'
-----------------------------------------------------" desc))
(time (with-progress-reporting (bench (f)
@cprice404
cprice404 / bythepower
Created August 1, 2012 20:11
ascii art
I===~:,,::~:~::~~~~~:::::,::::~~::::::,.........,,,,,,,:,::::::::::~~::::,,.....
=~~~:::::::::~~=~~~~::::,,,:::::,,,,,.. ..............,,,::::::::::::::::,,,,...
~~=~~~~~:~:::::~~:::::,,,,,,:,,,,,,.....................,,::::::::::::::::,,,...
~=~~~~=~~~::::::::,,,.,,,,,,,.,,..........=OO$...........,,,,,::,::~:,::,,,,,..,
=~~=~~~::::::,:,:,,,,,,,...............,??????I?$:.......,,,,,:,,,,:,,,,,,,,,,.:
==~~~~~~::::,::,,,,,,,,...............I????IIIIIIIZ.......,,,,,,,,,,,,,,,,:,,,,.
==~~~~:::::::,,,,,,,,................?+??I?7Z?III???......,,,,,,,,,,,,,,,,,,,,,,
===~:~~::::,,,,,...................,I?????7Z888I7Z$Z.........,,,,,...,,,,,,,,,,:
+=~~~~::,:::,,,,..................77????II?77Z77$IO,.....,.,,.,........,,,,,,,,.
+=~~~:::,,,,,....................:7????$II77I7$IODZ......,,..,.............,..,.
@cprice404
cprice404 / Modulefile
Created August 16, 2012 14:50
pmt install error
name 'inkling-postgresql'
version '0.2.0'
source 'git://github.com/inkling/puppet-postgresql.git'
author 'Inkling'
description 'PostgreSQL defined resource types'
summary 'PostgreSQL defined resource types'
license 'Apache'
project_page 'https://github.com/inkling/puppet-postgresql'
dependency 'puppetlabs/stdlib', '>= 2.4.0'
@cprice404
cprice404 / gist:3702455
Created September 11, 2012 22:04
ruby class vars and inheritance
irb
1.8.7 :001 > class Foo
1.8.7 :002?> class << self
1.8.7 :003?> def setvar(val)
1.8.7 :004?> @myvar = val
1.8.7 :005?> end
1.8.7 :006?> end
1.8.7 :007?> end
=> nil
1.8.7 :008 > class Bar < Foo
@cprice404
cprice404 / gist:3710938
Created September 13, 2012 00:18
puppetdb over ssl
host, port = args
puts "Hi there"
Puppet.notice("HI from logging!!!")
require 'puppet/network/http_pool'
path = "/metrics/mbean/java.lang:type=Memory"
headers = { "Accept" => "application/json" }
Puppet.notice("HI from logging2!!!")
@cprice404
cprice404 / gist:3830511
Created October 3, 2012 23:18
awesome set magic
1.8.7 :004 > def testfoo(ports)
1.8.7 :005?> val1 = Zlib.crc32(Set.new(ports).inspect)
1.8.7 :006?> val2 = Zlib.crc32(Set.new(Set.new(ports)).inspect)
1.8.7 :007?> puts "val1 '#{val1}'"
1.8.7 :008?> puts "val2 '#{val2}'"
1.8.7 :009?> end
=> nil
1.8.7 :010 > testfoo([22,8080])
val1 '3915886963'
val2 '3915886963'
explain analyze SELECT certname_catalogs.certname, catalog_resources.resource, catalog_resources.type, catalog_resources.title,catalog_resources.tags, catalog_resources.exported, catalog_resources.sourcefile, catalog_resources.sourceline, rp.name, rp.value FROM catalog_resources JOIN certname_catalogs USING(catalog) LEFT OUTER JOIN resource_params rp USING(resource) INNER JOIN certnames ON certname_catalogs.certname = certnames.name WHERE (catalog_resources.type = 'Ssh_key') AND (catalog_resources.exported = true) AND (certnames.deactivated IS NULL) AND (NOT ((certname_catalogs.certname = 'some.host.name')))
require 'puppet/error'
require 'puppet/util/puppetdb/command_names'
require 'puppet/util/puppetdb/char_encoding'
class Puppet::Util::Puppetdb::Command
include Puppet::Util::Puppetdb::CommandNames
Url = "/v2/commands"
SpoolSubDir = File.join("puppetdb", "commands")