Skip to content

Instantly share code, notes, and snippets.

View pjkelly's full-sized avatar

PJ Kelly pjkelly

  • Orange County, CA
View GitHub Profile
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
var amountVisible = function(element) {
var scroll_top = $(window).scrollTop();
var scroll_bottom = scroll_top + $(window).height();
var element_top = element.offset().top;
var element_bottom = element_top + element.height();
if (element_bottom > scroll_top && element_bottom < scroll_bottom) {
return element_bottom - scroll_top;
} else {
return scroll_bottom - element_top;
}
module Columnizer
def columnize(k=3)
result_set = []
n = self.index(self.last)
r = (n + 1).to_f / k.to_f
(0..n).each do |z|
x = (z.to_f * r).ceil
x = x - n while x > n
result_set << self[x]
end