This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
require 'marshall' | |
class Commit < Exception | |
end | |
class Rollback < Exception | |
end | |
class AbortTransaction < Rollback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is UNRELEASED code. | |
# There is currently no license to use it; that will come later | |
# This code was written while working for Betfair and will be released publicly later | |
require 'thread' | |
module MethodInterception | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Abominate | |
def replace_object new_object | |
raise Exception.new( "Ia! Ia! Cthulhu Fhtagn!" ) unless instance_variable_defined? "@i_know_this_is_an_abomination" | |
context = class << self ; self ; end | |
new_object.instance_variables.each do |var| | |
instance_variable_set( var, new_object.instance_variable_get( var ) ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
KEYWORD_REGEX = /(?:|[^%])(%\((\w+)\))/ | |
def keyreplace! &block | |
while match = self.match( KEYWORD_REGEX ) | |
offsets = match.offset( 1 ) | |
replacement = block.call( match[2].to_sym ) || "" | |
self[ offsets[0] ... offsets[1] ] = replacement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def match_class?( class_spec ) | |
case class_spec | |
when Class | |
# A plain value | |
return false unless self.is_a? class_spec | |
when Hash | |
# When we expect a keyed enumerator | |
return false unless self.method(:each) | |
# A hashlike each will return two values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oid ".iso.org.dod.internet.private.enterprises.netapp.netapp1" do | |
mib "NETWORK-APPLIANCE-MIB" # Won't be needed when we can snmpwalk directly | |
key "netapp.sysStat.cpu.cpuBusyTimePerCent", graph("CPU", :yaxisside => GRAPH_AXIS_RIGHT ) + trigger( :>, 60 ) | |
key "netapp.sysStat.cpu.cpuContextSwitches", graph("CPU") | |
key "netapp.sysStat.cpu.cpuInterrupts", graph("CPU") | |
key "netapp.sysStat.cpu.cpuUpTime", trigger( :<, :lastval, :critical, "Filer has rebooted" ) | |
key "netapp.sysStat.autosupport.autosupportFailedSends", trigger( :>, 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plugin for zbxprox.pl, which is not yet released (2011-10-03) | |
{ | |
'name' => "Mysql", | |
'config' => { | |
'host' => '127.0.0.1', | |
'user' => 'client', | |
'pass' => 'XXXXXXXXXXXXXXXXX', | |
'command' => "show status", | |
'cachetime' => 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the helper functionality we'll use | |
module MultiplexClass | |
# Set up some variables... | |
def self.extended(base) | |
base.class_exec do | |
# The class we will take subclasses from | |
@_multiplex_subclass_parent = self | |
# A hash of the tagged subclasses createed so far |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Considered adding this to Object, but that's a much more complex job. This gets the work done. | |
class Hash | |
def self_destruct! | |
self.each do |k,v| | |
v.self_destruct! if v.respond_to? :self_destruct! | |
self[k] = nil | |
self.delete k | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Dice | |
class Parser | |
attr_reader :terms | |
EXPRESSION = %r{^ | |
(?<conditional> > | < | = | ){0} | |
(?<condition> \g<conditional> (?<condition_number> \d+ ) ){0} | |
(?<penetrating> !p ){0} |
OlderNewer