Skip to content

Instantly share code, notes, and snippets.

View pdf's full-sized avatar

Peter Fern pdf

  • Melbourne, Australia
View GitHub Profile
@pdf
pdf / gist:6419454
Created September 3, 2013 03:31
mailq parse example
msgs = {}
state = nil
id = nil
mqstdout.each_line do |line|
line.strip!
case
when state.nil? && /^(?<msgid>[0-9A-F]+)\s+(?<size>[0-9]+)\s+(?<date>.+[^\s])\s+(?<sender>[^\s]+)$/ =~ line
id = msgid
msgs[id] = {
size: size.to_i,
@pdf
pdf / libvirt-xmlsimple.rb
Created March 24, 2011 03:00
Convert hash into libvirt domain XML
require 'rubygems'
# xml-simple has a bug that needs to be fixed before this works, see:
# https://github.com/pdf/xml-simple/commit/b4da34165c88fe912b45af614b326ed512a666c7
require 'xmlsimple'
# domain1 omits the __value__ key except where required
domain1 = {
"@type"=>"kvm",
"name"=>"demo1",
"uuid"=>"4dea24b3-1d52-d8f3-2516-782e98a23fa1",