Skip to content

Instantly share code, notes, and snippets.

@mmrobins
mmrobins / jenkins_lava_lamp.rb
Created May 25, 2011 21:06
Jenkins Lava Lamp Script
#!/usr/bin/env ruby
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.
#
# Requires atom gem and bottlerocket X10 control software to be installed.
@mmrobins
mmrobins / gist:1119333
Created August 2, 2011 00:34
Puppetral MCollective Resource Cloning
╰─ [0]% puppetsudo irb
Password:
irb(main):001:0> require 'mcollective'; include MCollective::RPC => Objectirb(main):002:0> require 'puppet' => true
irb(main):003:0> Puppet::Resource.new('user', 'harry', :parameters => {:ensure => :present}).save=> User[harry]{:membership=>:minimum, :ensure=>:present, :loglevel=>:notice, :key_membership=>:minimum, :auth_membership=>:minimum, :provider=>:directoryservice, :name=>"harry", :role_membership=>:minimum, :profile_membership=>:minimum}
irb(main):004:0> client0 = rpcclient('puppetral'); client0.identity_filter(/lan-0/)
@mmrobins
mmrobins / gist:1313721
Created October 25, 2011 18:17
ActiveMQ Puppet Enterprise Errors
==> /var/log/pe-httpd/error.log <==
24 / 24
memcached retrieving ["ab39482cf4abc59ced1fc65bba0cc5ad"] [a1880232341f3425d8c34e7d0a81930d] => [nil] [3]
memcached saving ["ab39482cf4abc59ced1fc65bba0cc5ad"] [a1880232341f3425d8c34e7d0a81930d] -> [["ip-10-112-67-14", "ip-10-114-85-11", "ip-10-118-49-17", "ip-10-1
94-138-254", "ip-10-204-55-216", "ip-10-205-14-132", "ip-10-205-2-130", "ip-10-244-145-203", "ip-10-244-15-192", "ip-10-245-207-28", "ip-10-245-218-150", "ip-1
0-245-91-164", "ip-10-36-30-238] [277]
74.85.255.4 - - [25/Oct/2011 18:12:32] "GET /lm/nodes " 200 440 6.2160
@mmrobins
mmrobins / gist:1350318
Created November 9, 2011 04:02
ActiveMQ error shortly after applying oversubscription patch
Running passenger with RI's oversubscription patches doing an "Inspect All" with 2 second discovery timeout
==> /var/log/pe-activemq/activemq.log <==
2011-11-09 02:30:20,337 | WARN | Ack for non existent subscription, ack:MessageAck {commandId = 0, responseRequired = false, ackType = 2, consumerId = ID:ip-10-212-86-245-42499-1320800856049-3:6743:-1:1, firstMessageId = null, lastMessageId = ID:ip-10-212-86-245-42499-1320800856049-3:6674:-1:1:76, destination = topic://mcollective.puppetral.reply, transactionId = null, messageCount = 1, poisonCause = null} | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Connection Dispatcher: /10.212.86.245:438872011-11-09 02:30:20,380 | WARN | Async error occurred: java.lang.IllegalArgumentException: The subscription does not exist: ID:ip-10-212-86-245-42499-1320800856049-3:6743:-1:1 | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Connection Dispatcher: /1
0.212.86.245:43887
java.lang.IllegalArgumentException: The subscription does not exist
@mmrobins
mmrobins / gist:1678166
Created January 25, 2012 19:46
Puppet load order for duplicate modules - types, manifests and facts
# tests to see what happens to facts, types and manifests in modules if the the module
# exists multiple times in the module path
# example modulepath = 'modpath1:modpath2'
# whatever definition of root_home lives in the later part of the module path wins
# modpath1 defintion = myhome
# modpath2 defintion = yourhome
# result = yourhome
notify { $root_home : }
@mmrobins
mmrobins / gist:1726100
Created February 2, 2012 22:08
Puppet nested timed output logging
https://github.com/mmrobins/puppet/tree/2.6.x.speed_investigate
╭─[~/work/puppet]─[matthewrobinson@mattmac]─[20120202 - 14:07]-‹2.6.x.speed_investigate›
╰─ [1]% puppet apply ~/work/puppet/test.pp --debug | egrep "Start|Finished"
debug : Start (14:09:37) main
debug : | Start (14:09:37) Set our code or file to use.
debug : | Finished (Time elapsed 0.000242) Set our code or file to use.
debug : | Start (14:09:37) Collect our facts
debug : | Finished (Time elapsed 0.992216) Collect our facts
debug : | Start (14:09:38) Find our Node
% cookie=mycookieicopied
% token=mytokenicopied
% vim ingress_payload # paste in your payload data you copied and save
% curl -v -X POST -H "Cookie:$cookie" -H "X-CSRFToken:$token" --data @ingress_payload http://www.ingress.com/rpc/dashboard.getThinnedEntitiesV2
* About to connect() to www.ingress.com port 80 (#0)
* Trying 72.14.249.180... connected
* Connected to www.ingress.com (72.14.249.180) port 80 (#0)
> POST /rpc/dashboard.getThinnedEntitiesV2 HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.ingress.com
% cookie=mycookieicopied
% token=mytokenicopied
% vim ingress_payload # paste in your payload data you copied and save
% curl -v -X POST -H "Cookie:$cookie" -H "X-CSRFToken:$token" --data @ingress_payload http://www.ingress.com/rpc/dashboard.getThinnedEntitiesV2
* About to connect() to www.ingress.com port 80 (#0)
* Trying 72.14.249.180... connected
* Connected to www.ingress.com (72.14.249.180) port 80 (#0)
> POST /rpc/dashboard.getThinnedEntitiesV2 HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.ingress.com
@mmrobins
mmrobins / 201306_ruby_hangman_lru
Created June 5, 2013 02:52
Markus' Ruby hangman to implement an LRU function
def LRU(n, &b)
h={}
->(*k) do
h[k] = h.delete(k) do
puts "cache miss"
if h.length >= n
puts "clearing cache past #{n}"
h.shift
end
b[*k]
# mod 10
# cards: 0-9
# each one card face up
# goal high score
# mod 10
# dealer required to take card if < otherwise stands
# known card order
#
# moves = []
# [