Skip to content

Instantly share code, notes, and snippets.

@justinstoller
justinstoller / clean.rb
Last active December 13, 2017 00:10
Misc when using the Puppet Profiler
#!/usr/bin/env ruby
def clean_profile_line(line)
if line =~ /.*\[(\d+)\] (\d(\.\d\d?)*) (.*): took (\d*\.?\d*) seconds/
request_id = $1
step_and_maybe_substeps = $2
# unused artifact of the regex, named here for documentation purposes
maybe_substeps = $3
step_name = $4
#!/usr/bin/env ruby
require 'csv'
inputfile = ARGV[0]
intermediate = {
'node' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta plugins' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta pluginfacts' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'catalog' => {'KOs' => 0, 'values' => [], 'ok' => 0},
sellout:puppet justin$ git diff spec/
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index 0316c8b..4a20a2b 100644
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -2,6 +2,7 @@
require 'spec_helper'
require 'matchers/include_in_order'
require 'puppet_spec/compiler'
+require 'pry'
#!/usr/bin/env ruby
require 'json'
def dig(hash, keys)
keys.reduce(hash) {|h, k| i = h[k]; i ? i : break }
end
def to_csv(json, fields)
fields.map{|f| json[f] }.join(',')
@justinstoller
justinstoller / summarize_sim.rb
Created March 19, 2018 16:41
summarize gatlins runs
#!/usr/bin/env ruby [23/9866]
require 'csv'
inputfile = ARGV[0]
intermediate = {
'node' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta plugins' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta pluginfacts' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'catalog' => {'KOs' => 0, 'values' => [], 'ok' => 0},
@justinstoller
justinstoller / encoding.md
Created March 19, 2018 18:32 — forked from Iristyle/encoding.md
Encoding in Puppet

Basic encoding info

  • ASCII is 0 - 7F (128 total characters) - ASCII is a subset of UTF-8
  • UTF-8 - variable width 1 to 4 bytes
Numberof bytes Bits forcode point Firstcode point Lastcode point Byte 1 Byte 2 Byte 3 Byte 4
1 7 U+0000 U+007F 0xxxxxxx      
2 11 U+0080 U+07FF 110xxxxx 10xxxxxx    
3 16 U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxx  
require 'openssl'
PRIVATE_KEY_LENGTH = 2048
NOT_BEFORE = Time.now
NOT_AFTER = Time.now + (5 * 365 * 24 * 60 * 60)
CA_EXTENSIONS = [
["basicConstraints", "CA:TRUE", true],
["keyUsage", "keyCertSign, cRLSign", true],
["subjectKeyIdentifier", "hash", false],
["authorityKeyIdentifier", "keyid:always", false]
# to reliably reproduce run with: ruby repro.rb 10000
require 'fcntl'
class Pump
attr_reader :string
def initialize(io)
@io = io
@thread = nil
@string = ''
@run = true
# To be used within the Puppet::Server::Master initialize method
# Outpus to be used when calling find, save, etc on termini
# e.g.
#
# require 'puppet/indirector/indirection'
# require 'puppet/indirector/terminus'
# ...
#
# class Puppet::Server::Master
# ...
in master-service we call
master-core/construct-root-routes w/
puppet-version (string from config)
use-legacy-auth-conf (bool from config)
jruby-service (instance of JRubyService)
get-code-content (fn from VersionedCodeService)
get-code-id (fn from VersionCodeService)
handle-request (fn from RequestHandlerService)
environment-class-cache-enabled (bool from config)