Skip to content

Instantly share code, notes, and snippets.

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
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;
}
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} &)
@pjkelly
pjkelly / symlink-imagemagick
Created December 11, 2010 05:46
symlink imagemagick installed via homebrew to /usr/local
@pjkelly
pjkelly / DevelopmentEnvironmentInstructions.markdown
Created December 13, 2010 17:13
Instructions for setting up a Rails development environment using Cinderella

These instructions are for Snow Leopard only.

XCode

Ensure that you have XCode for the version of OS X you're running. These are not installed by default on new machines and can be installed off the OS installation DVD. If you're not sure, run the following command. It should return something like this: /usr/bin/gcc; if it does not, you need to install XCode.

which gcc

SSH Keys

First, let's install a new version of Ruby. You can accept the default settings it suggests

mkdir -p ~/src
cd ~/src
curl -OL http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar xzvf ruby-enterprise-*.tar.gz
sudo ./ruby-enterprise-*/installer
@pjkelly
pjkelly / liveset-link-and-button-helpers.markdown
Created February 16, 2011 19:18
Methods and example output for all four Liveset link & button helper methods.
@pjkelly
pjkelly / track-development-branch.sh
Created March 10, 2011 17:08
Track and switch to the revised-data-delivery branch of the OMN repository.
git fetch origin
git config branch.revised-data-delivery.remote origin
git config branch.revised-data-delivery.merge refs/heads/revised-data-delivery
git checkout revised-data-delivery
@pjkelly
pjkelly / moonshine-passenger-issues.sh
Created March 16, 2011 18:28
Output occurring since upgrading to Passenger 3.0.5 even after the recent freezing of 3.0.4 in Moonshine.
** [out :: myapp.com] notice: /ApplicationManifest#37495940/Package[passenger]/ensure: ensure changed '3.0.5' to '3.0.4'
** [out :: myapp.com] err: /ApplicationManifest#37495940/Exec[build_passenger]/returns: change from notrun to 0 failed: sudo /usr/bin/ruby -S rake clean apache2 returned 1 instead of 0
** [out :: myapp.com] notice: /ApplicationManifest#37495940/File[/etc/apache2/mods-available/passenger.load]: Dependency exec[sudo /usr/bin/ruby -S rake clean apache2] has 1 failures
** [out :: myapp.com] warning: /ApplicationManifest#37495940/File[/etc/apache2/mods-available/passenger.load]: Skipping because of failed dependencies
** [out :: myapp.com] notice: /ApplicationManifest#37495940/File[/etc/apache2/mods-available/passenger.conf]: Dependency exec[sudo /usr/bin/ruby -S rake clean apache2] has 1 failures
** [out :: myapp.com] warning: /ApplicationManifest#37495940/File[/etc/apache2/mods-available/passenger.conf]: Skipping because of failed dependencies
** [out :: myapp.com] notice: /ApplicationManifest
$('ul#quiz-answers li');
$('ul#quiz-answers li:first').animate({
top: '148px'
}, {
duration: 1000,
step: function( now, fx ){
console.log(now);
// $( "ul#quiz-answers li:gt(0)" ).css( "top", now );
}
});