Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Moran pmoran

  • REA Group
  • Melbourne, Australia
View GitHub Profile
View gist:445818
class Product
def self.select_satisfying(specification)
satisfying = specification.all
# apply more complex selection, such as selecting across different combination of model objects
end
end
View gist:445832
---
title: About Us
order: 1
filter: erb
---
<%= render(:partial => "main/about") %>
View gist:445833
gemmate() {
mate $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep $1 | sort`
}
complete -o default -o nospace -F _gemdocomplete gemmate
View gist:445813
class IsEffectiveProductSpecification
def criteria
{ :conditions => ["effective_from => :today", { :today <= Date.today}] }
end
end
View gist:445817
class CompositeSpecification < Array
def all
self.inject(Product.scoped(nil)) do |combined_scope, specification|
combined_scope.scoped(specification.criteria)
end
end
end
View gist:445830
<% menu_items.each do |page| %>
<% if is_current_page?(page) %>
<li class='current'><p><%= page.title %></p> </li>
<% else %>
<li><%= link_to_page(page) %></li>
<% end %>
<% end %>
View gist:445829
def menu_items
@pages.find(:all, :in_directory => "/main", :sort_by => 'order')
end
View gist:445831
<% @partials.find(:all, :in_directory => "/main") do |partial| %>
<div id='<%= partial.name %>' style='display: none'>
<div><%= render(:partial => partial) %></div>
</div>
<% end %>
View gist:739583
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb
module Screenshots
if Cucumber::OS_X
def embed_screenshot(id)
`screencapture -t png reports/#{id}.png`
embed("#{id}.png", "image/png")
end
else
def embed_screenshot(id)
`import -window root reports/#{id}.png`