Skip to content

Instantly share code, notes, and snippets.

View entombedvirus's full-sized avatar

Rohith Ravi entombedvirus

  • San Francisco, CA
View GitHub Profile
var Foo = function() {
this.bar = "hey";
this.print = function() {
console.log(this.bar);
};
}
Foo.new = function() {
var n = {};
n.constructor = this;
this.call(n);
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|
#!/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'
# 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
def path_to_image(*params)
path = super(*params)
path = "#{request.protocol}#{request.host_with_port}#{path}"
return path
end
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally
CommentBox.prototype = {
refresh: function() {
var textarea = this.text;
if (textarea.val().trim() == "" && !this.hasFocus) {
textarea.addClass("empty").val("write something...");
} else if (textarea.val().trim() == "write something...") {
textarea.val("").removeClass("empty");
};
},
ThreadError (return can't jump across threads):
/app/controllers/application.rb:10
/vendor/plugins/identity_map/lib/identity_map.rb:90:in `call'
/vendor/plugins/identity_map/lib/identity_map.rb:90:in `check_static_refresh'
/vendor/plugins/identity_map/lib/identity_map.rb:75:in `with_identity_map'
/vendor/plugins/identity_map/init.rb:7:in `evaluate_init_rb'
/vendor/rails/activesupport/lib/active_support/callbacks.rb:177:in `call'
/vendor/rails/activesupport/lib/active_support/callbacks.rb:177:in `evaluate_method'
/vendor/rails/actionpack/lib/action_controller/filters.rb:393:in `call'
/vendor/rails/actionpack/lib/action_controller/filters.rb:598:in `run_before_filters'
state_machine :initial => :unmonitored do
state :unmonitored, :up, :down
event :tick do
transition :unmonitored => :unmonitored
transition [:up, :down] => :up, :if => :process_running?
transition [:up, :down] => :down, :unless => :process_running?
end
while true; do total_before=$(wc -l /var/log/haproxy.log | cut -f1 -d' '); sleep 5; total_after=$(wc -l /var/log/haproxy.log | cut -f1 -d' '); echo $(((total_after-total_before)/5)) lps; done