Skip to content

Instantly share code, notes, and snippets.

View entombedvirus's full-sized avatar

Rohith Ravi entombedvirus

  • San Francisco, CA
View GitHub Profile
def path_to_image(*params)
path = super(*params)
path = "#{request.protocol}#{request.host_with_port}#{path}"
return path
end
# Taken from http://snippets.dzone.com/posts/show/898 w/ some modifications
class ::Array
# Chooses a random array element from the receiver based on the weights
# provided. If _weights_ is nil, then each element is weighed equally.
#
# [1,2,3].random #=> 2
# [1,2,3].random #=> 1
# [1,2,3].random #=> 3
#
# If _weights_ is an array, then each element of the receiver gets its
#!/usr/bin/env ruby
class Munin
class LogReader
attr_accessor :log_file, :me, :pluginstatedir, :statefile
def initialize(file_name)
@file_name = file_name
@me = File.basename($0)
@pluginstatedir = ENV['MUNIN_PLUSTATE'] || '/var/lib/munin/plugin-state'
module CachedAttributes
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def has_cached_attribute(name, default_value)
# Only include the InstanceMethods module once
after_initialize do |instance|
var Foo = function() {
this.bar = "hey";
this.print = function() {
console.log(this.bar);
};
}
Foo.new = function() {
var n = {};
n.constructor = this;
this.call(n);