Skip to content

Instantly share code, notes, and snippets.

gem sources -a http://gems.github.com
rake gems:install
<%= render :partial => 'shared/paginate', :locals => {:collection => @orders, :options => generate_search_options(@filter)} unless @orders.empty? %>
<!-- Code by Ilya Grigorik - http://www.igvita.com/blog/2006/09/10/faster-pagination-in-rails/ -->
<% if collection.page_count != collection.first_page -%>
<div class="pagination">
<ul>
<% if collection.previous_page? -%>
<li class="nextpage">
<%= link_to "&#171; #{t('previous')}", { :p => collection.previous_page }.merge(options) %>
</li>
<% else -%>
<li class="disablepage">&#171; <%= t('previous') %></li>
<!-- Code by Ilya Grigorik - http://www.igvita.com/blog/2006/09/10/faster-pagination-in-rails/ -->
<% if collection.page_count != collection.first_page -%>
<div class="pagination">
<ul>
<% if collection.previous_page? -%>
<li class="nextpage">
<%= link_to "&#171; #{t('previous')}", { :p => collection.previous_page }.merge(options) %>
</li>
<% else -%>
<li class="disablepage">&#171; <%= t('previous') %></li>
<%= page_links(:prev => "&#171; #{t('previous')}", :next => "#{t('next')} &#187;") if @search.page_count > 1 %>
def collection
default_stop = (Date.today + 1).to_s(:db)
@filter = params.has_key?(:filter) ? OrderFilter.new(params[:filter]) : OrderFilter.new
scope = Order.scoped(:include => [:shipments, {:creditcards => :address}])
scope = scope.by_number @filter.number unless @filter.number.blank?
scope = scope.by_customer @filter.customer unless @filter.customer.blank?
scope = scope.between(@filter.start, (@filter.stop.blank? ? default_stop : @filter.stop)) unless @filter.start.blank?
scope = scope.by_state @filter.state.classify.downcase.gsub(" ", "_") unless @filter.state.blank?
scope = scope.conditions "lower(addresses.firstname) LIKE ?", "%#{@filter.firstname.downcase}%" unless @filter.firstname.blank?
def collection
@search = Order.new_search(params[:search])
if params[:search].nil? || params[:search][:conditions].nil?
@search.conditions.checkout_complete = true
end
@search.order_by ||= :created_at
@search.order_as ||= "DESC"
@search.per_page = Spree::Config[:orders_per_page]
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
source ~/.git_completion.sh
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}