Skip to content

Instantly share code, notes, and snippets.

@huy
huy / Hash.from_xml
Created February 10, 2011 05:29
Convert xml to hash using Nokogiri
# USAGE: Hash.from_xml(YOUR_XML_STRING)require 'rubygems'
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#123129
7
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
@huy
huy / gist:6295999
Last active December 21, 2015 10:59
graphite diagram
digraph GraphiteHowItWorks {
labelloc="t"
label=<
<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR><TD>
Graphite - How it works
</TD></TR>
</TABLE>
>
require './redis_client'
class RedisMonitor
CHECK_MASTER_PERIOD = 5
attr_accessor :verbose
def initialize(instances={})
@instances = instances