Skip to content

Instantly share code, notes, and snippets.

View ehrenmurdick's full-sized avatar

Ehren Murdick ehrenmurdick

View GitHub Profile
#!/usr/bin/env ruby
#
# DarkRoom
# Takes fullsize screenshots of a web page.
# Copyright (c) 2007 Justin Palmer.
#
# Released under an MIT LICENSE
#
# Usage
# ====
#!/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)
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 () {
class Numeric
def spaces
self * " "
end
end
p 128.spaces
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"}>
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"))
$.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);
});
# = 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')
require 'zip/zip'
Zip::ZipOutputStream.new("foo.zip") do |io| io.close_write 'fizzle' end
@ehrenmurdick
ehrenmurdick / logger.rb
Created October 5, 2010 17:39
Pretty print into rails logs
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