This file contains hidden or 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
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 1.0).to_f | |
@@last_gc_run = Time.now | |
Before do | |
begin_gc_deferment | |
end | |
After do | |
reconsider_gc_deferment |
This file contains hidden or 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 Hash | |
class << self | |
def from_xml(xml_io) | |
begin | |
result = Nokogiri::XML(xml_io) | |
return { result.root.name.to_sym => xml_node_to_hash(result.root)} | |
rescue Exception => e | |
# raise your custom exception here | |
end | |
end |
This file contains hidden or 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
# features/support/env.rb | |
require 'webrat' | |
require 'webrat/core/matchers' | |
Webrat.configure do |config| | |
config.mode = :rack | |
config.open_error_files = false # Set to true if you want error pages to pop up in the browser | |
end |
This file contains hidden or 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
#!/bin/sh | |
ref=$(git symbolic-ref HEAD 2> /dev/null) | |
if [[ -n $ref ]]; then | |
if [[ $ref =~ "master" ]]; then | |
rm public/.htaccess | |
else | |
echo "RailsEnv ${ref#refs/heads/}" > public/.htaccess | |
fi |
This file contains hidden or 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
#!/bin/sh | |
# | |
# This shell script passes all its arguments to the binary inside the | |
# MacVim.app application bundle. If you make links to this script as view, | |
# gvim, etc., then it will peek at the name used to call it and set options | |
# appropriately. | |
# | |
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This | |
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico | |
# Weber and Bjorn Winckler, Aug 13 2007). |
This file contains hidden or 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
# TextMate dotfiles filter | |
# use this filter in Preferences -> Advanced -> Folder References -> File Pattern | |
# to show .gitignore, .gems (useful for Heroku), .bundle in your project | |
!(/\.(?!(htaccess|gitignore|gems|bundle))[^/]*|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$ |
This file contains hidden or 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
@app_name = File.basename(@root) | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm public/images/rails.png" | |
run "rm -f public/javascripts/*" | |
run "rm config/database.yml" |
This file contains hidden or 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
# weighted tanimoto for taggables | |
# works with acts_as_taggable_on_steroids, | |
# assuming you have a weight attribute in your Tagging model | |
def tanimoto(a,b) | |
a_size = a.taggings.map { |t| t.weight}.sum | |
b_size = b.taggings.map { |t| t.weight}.sum | |
return 0 if (a_size == 0 || b_size == 0) | |
c_size = a.taggings.map { |t| b.tag_list.include?(t.name) ? [t.weight, b.taggings.find_by_tag_id(t.tag_id).weight].min : 0 }.sum | |
This file contains hidden or 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 | |
require Dir | |
unless ARGV[0] | |
puts 'Usage: newpost "the post title"' | |
exit(-1) | |
end | |
blog_root = "/Users/jrk/proj/blog" |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beforeRunningCommand</key> | |
<string>nop</string> | |
<key>bundleUUID</key> | |
<string>C9BD1ADE-4FD9-4842-A641-DFB373B7D42C</string> | |
<key>command</key> | |
<string>#!/usr/bin/env ruby |