Skip to content

Instantly share code, notes, and snippets.

html, body {
border:0pt none;
margin:0pt;
min-width:750px;
padding:0pt;
width:100%;
}
body {
color:#333333;
#!/usr/bin/env ruby
## git-rank-contributors: a simple script to trace through the logs and
## rank contributors by the total size of the diffs they're responsible for.
## A change counts twice as much as a plain addition or deletion.
##
## Output may or may not be suitable for inclusion in a CREDITS file.
## Probably not without some editing, because people often commit from more
## than one address.
##
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)]/"
}
#
# 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
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]
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?
<%= page_links(:prev => "&#171; #{t('previous')}", :next => "#{t('next')} &#187;") if @search.page_count > 1 %>
<!-- 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>
<%= render :partial => 'shared/paginate', :locals => {:collection => @orders, :options => generate_search_options(@filter)} unless @orders.empty? %>