Skip to content

Instantly share code, notes, and snippets.

View databus23's full-sized avatar

Fabian Ruff databus23

View GitHub Profile
@databus23
databus23 / gist:1689076
Created January 27, 2012 14:38
Monkey patch Chef::REST::AuthCredentials to support keys directly
#Chef::REST::AuthCredentials accepts only filenames by default
#this extends the Chef::REST::AuthCredentials so that the key can be provided directly
require 'chef/rest/auth_credentials'
class Chef
class REST
class AuthCredentials
alias :original_load_signing_key :load_signing_key
def load_signing_key
if key_file.start_with?("-----BEGIN RSA PRIVATE KEY-----")
@databus23
databus23 / test.rb
Created May 23, 2011 16:41
nokogiri duplicate xpath results bug
require 'rubygems'
require 'nokogiri'
while true
doc=Nokogiri::XML(open('test.xml'))
xpath_query="//MetricTemplate[@name=\"Availability\" or @name=\"does not exist\"]"
puts "xpath: #{xpath_query}"
result = doc.xpath(xpath_query)
if result.length>1
puts "duplicate:"