This file contains hidden or 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
| def path_to_image(*params) | |
| path = super(*params) | |
| path = "#{request.protocol}#{request.host_with_port}#{path}" | |
| return path | |
| end |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| #!/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' |
This file contains hidden or 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 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| |
This file contains hidden or 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
| var Foo = function() { | |
| this.bar = "hey"; | |
| this.print = function() { | |
| console.log(this.bar); | |
| }; | |
| } | |
| Foo.new = function() { | |
| var n = {}; | |
| n.constructor = this; | |
| this.call(n); |
NewerOlder