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
def children(options = {}) | |
options.merge!({ :order => 'updated_at desc' }) | |
options # => {:limit=>3, :order=>"updated_at desc"} | |
found = articles.find(:all, options) | |
options # => {:conditions=>"`articles`.section_id = 2", :readonly=>nil, :select=>nil, :group=>nil, :offset=>nil, :limit=>3, :include=>:_route, :joins=>nil, :order=>"updated_at desc, created_at desc"} | |
found += pages.find(:all, options) | |
found.sort! { |x, y| y.updated_at <=> x.updated_at } | |
options[:limit] ? found[0, options[:limit]] : found | |
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
def yui_js(arr) | |
defaults = [ 'yahoo-dom-event/yahoo-dom-event' ] | |
base = 'http://yui.yahooapis.com/combo?' | |
prefix = '2.5.2/build/' | |
src = base + (defaults + arr).uniq.map { |s| prefix + s }.join('&') + '.js' | |
%|<script type="text/javascript" src="#{src}"></script>| | |
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
#!/usr/bin/env ruby | |
Locations = { | |
'vatican' => 'home', | |
'dbstation' => 'remote' | |
} | |
Dotfile = ENV['RUN_AS'] ? File.expand_path("/Users/#{ENV['RUN_AS']}/.location") : File.expand_path('~/.location') | |
# ensure dotfile exists |
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
<p:find title="Services"> | |
<!-- set the current scope to the 'services' page --> | |
<p:children:each> | |
<!-- iterate over each child of services, which are the 'sections' --> | |
<h2><p:title/></h2> <!-- print out the section title --> | |
<ul> | |
<p:children:each> | |
<!-- now that we're in a 'section', iterate over each sub page --> | |
<li><p:link/></li> <!-- create a link to this sub page --> | |
</p:children:each> |
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
if [[ -x `which git` ]]; then | |
function git-branch-name () { | |
git branch 2> /dev/null | grep ^\* | sed s/^\*\ // | |
} | |
function git-dirty () { | |
git status | grep "nothing to commit (working directory clean)" | |
echo $? | |
} | |
function gsrb () { | |
branch=$(git-branch-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 String | |
def method_missing(method, *args, &block) | |
if method.to_s =~ /is_(.*?)\?/ | |
self.downcase == $1 | |
else | |
raise NoMethodError, "Undefined method '#{method}' for #{self.inspect}" | |
end | |
end | |
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
%r{<#{@tag_prefix}:([\w:]+?)(\s+(?:\w+\s*=\s*(?:"[^"]*?"|'[^']*?')\s*)*|)>|</#{@tag_prefix}:([\w:]+?)\s*>} |
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
<a href="javascript:void(0)" onclick="window.open('URL GOES HERE', 'keyword_here', 'fullscreen=yes,scrollbars=yes')">Click here for a new window</a> |
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 James | |
def movie ; "The Big Lebowski #{@special}" ; end | |
end | |
module Bob | |
def movie ; "Spiderman #{@special}" ; end | |
end | |
module Jane | |
def movie ; "Raiders of the Lost Ark #{@special}" ; 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 UserConcerns | |
module ControllerMethods ; end | |
module ModelMethods | |
def self.included(receiver) | |
receiver.extend ClassMethods | |
receiver.send :include, InstanceMethods | |
end |
OlderNewer