Skip to content

Instantly share code, notes, and snippets.

View nicklewis's full-sized avatar

Nick Lewis nicklewis

View GitHub Profile
@nicklewis
nicklewis / gist:6300156
Last active December 21, 2015 11:38
puppetdb metric
curl -H 'Accept: application/json' http://<puppetdb>:8080/v2/metrics/mbean/com.puppetlabs.puppetdb.command%3Atype%3Dglobal%2Cname%3Dprocessing-time
/v2/metrics/mbean/com.puppetlabs.puppetdb.scf.storage%3Atype%3Ddefault%2Cname%3Dgc-catalogs-time
/v2/metrics/mbean/com.puppetlabs.puppetdb.scf.storage%3Atype%3Ddefault%2Cname%3Dgc-params-time
/v2/metrics/mbean/com.puppetlabs.puppetdb.scf.storage%3Atype%3Ddefault%2Cname%3Dreplace-catalog-time
@nicklewis
nicklewis / dfa.pp
Last active October 8, 2015 08:48
A DFA in Puppet language
class print_result($result,$input){
$answer = $result ? {
s1 => even,
s2 => odd,
}
notify { "The input $input is $answer": }
}
define dfa($state,$original_input,$input,$rules,$callback) {
$first = inline_template("<%= input[0] %>")
{
"command": "deactivate node",
"payload": "\"the_node_name\"",
"version": 1
}
@nicklewis
nicklewis / gist:2402713
Created April 17, 2012 01:13
weird array vs. string append behavior
$topscope_array = ['a']
$topscope_string = 'a'
node default {
$array = ['a']
$string = 'a'
include foo
notify { "node array is $array (should be a)": }
notify { "node string is $string (should be a)": }
}
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index fc36c35..be04a90 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -57,6 +57,7 @@ class Puppet::Node::Environment
def self.clear
@seen.clear
+ self.current = nil
end
RubyFileStat.java:365:in `cmp': java.lang.ClassCastException: org.jruby.RubySymbol cannot be cast to org.jruby.RubyFileStat
from RubyFileStat$i$1$0$cmp.gen:65535:in `call'
from RuntimeHelpers.java:2513:in `invokedynamic'
from RubyComparable.java:117:in `callCmpMethod'
from RubyComparable.java:103:in `op_equal'
from RubyComparable$s$1$0$op_equal.gen:65535:in `call'
from CachingCallSite.java:312:in `cacheAndCall'
from CachingCallSite.java:169:in `call'
from EqCallSite.java:37:in `call'
from CallOneArgNode.java:57:in `interpret'
@nicklewis
nicklewis / binary_search_specs.rb
Created September 14, 2011 20:09
Binary search for order-dependent test failures
#!/usr/bin/env ruby
specs_in_order = File.read('spec_order').split
failing_spec = ARGV.first
specs = specs_in_order[0...specs_in_order.index(failing_spec)]
suspects = specs
@nicklewis
nicklewis / shuffle_spec.rb
Created September 14, 2011 19:00
Run specs in random order
#!/usr/bin/env ruby
if size_opt = ARGV.index('-s')
seed = ARGV[size_opt+1]
end
seed ||= Time.now.to_i
if clip_opt = ARGV.index('-c')
begin
@nicklewis
nicklewis / if-puppet-was-more-like-lisp.pp
Created June 14, 2011 05:01
If Puppet was more like Lisp
((file /etc/apache2/apache2.conf
(ensure file)
(source puppet:///modules/apache/apache2.conf)
(notify
(service apache
(ensure running)
(enable true)
(require
(package apache
(ensure latest)))))))
@nicklewis
nicklewis / jenkins.rb
Created May 25, 2011 20:46
Jenkins lava lamp
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'atom'
# Light lava lamps based on Jenkins build status RSS feed
# Green lamp lights if all builds are good;
# Red lamp lights if any build fails.
#