This file contains 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 | |
# | |
# DarkRoom | |
# Takes fullsize screenshots of a web page. | |
# Copyright (c) 2007 Justin Palmer. | |
# | |
# Released under an MIT LICENSE | |
# | |
# Usage | |
# ==== |
This file contains 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 | |
COLOR_FILE = '/Users/ehrenmurdick/bin/config/desktop-color' | |
require 'color' | |
require 'rmagick' | |
include Magick | |
if File.exist?(COLOR_FILE) | |
color = Marshal.load(File.open(COLOR_FILE).read) |
This file contains 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
git_branch() { | |
echo $(git-symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) | |
} | |
git_prompt_info () { | |
ref=$(git-symbolic-ref HEAD 2>/dev/null) || return | |
echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" | |
} | |
project_name () { |
This file contains 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
class Numeric | |
def spaces | |
self * " " | |
end | |
end | |
p 128.spaces |
This file contains 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
it "should map route stuff" do | |
route_for(:controller => "institutions", :action => "destroy", :id => "1").should == "/institutions/1" | |
end | |
# The recognized options <{"action"=>"show", "id"=>"1", "controller"=>"institutions"}> did not match <{"action"=>"destroy", "id"=>"1", "controller"=>"institutions"}>, difference: <{"action"=>"destroy"}> |
This file contains 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
require 'activesupport' | |
class Module | |
def memoize method | |
define_method :"#{method}_with_memoization" do |*args| | |
varname = "@_memoized_#{method}" | |
if instance_variable_names.include?(varname) | |
instance_variable_get(varname) | |
else | |
instance_variable_set(varname, send("#{method}_without_memoization")) |
This file contains 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
$.fn.confusicate = function() { | |
$(this).each(function() { | |
var elem = $(this); | |
elem.mouseover(function() { | |
setInterval(function() { | |
elem.css({position: 'relative'}); | |
elem.animate({top: (Math.random() * 100) - 50 + 'px', left: ((Math.random() * 100) - 50) + 'px'}, 100); | |
elem.animate({fontSize: (Math.random() * 5) - 2.5 + 'em'}, 80); | |
}, Math.random() * 100 + 200); | |
}); |
This file contains 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
# = Icebox : Caching for HTTParty | |
# | |
# Cache responses in HTTParty models [http://github.com/jnunemaker/httparty] | |
# | |
# === Usage | |
# | |
# class Foo | |
# include HTTParty | |
# include HTTParty::Icebox | |
# cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache') |
This file contains 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
require 'zip/zip' | |
Zip::ZipOutputStream.new("foo.zip") do |io| io.close_write 'fizzle' end |
This file contains 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 ActiveSupport | |
class BufferedLogger | |
if RAILS_ENV == 'development' | |
def flowerbox *args | |
info "=" * 80 | |
info caller[0] | |
args.each do |a| | |
info "-" * 80 | |
info a.inspect | |
end |
OlderNewer