Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
natritmeyer / init.pp
Last active January 3, 2016 07:59
Sensible puppet defaults
Exec {
logoutput => 'on_failure'
}
exec { 'some_command' :
#...,
logoutput => true
}
@natritmeyer
natritmeyer / convert_duration_to_seconds.rb
Created July 28, 2015 13:14
Ruby ISO 8601 duration converter
require 'test/unit'
# implementation
class Duration
def in_seconds(raw_duration)
match = raw_duration.match(/PT(?:([0-9]*)H)*(?:([0-9]*)M)*(?:([0-9.]*)S)*/)
hours = match[1].to_i
minutes = match[2].to_i
seconds = match[3].to_f
seconds + (60 * minutes) + (60 * 60 * hours)