Skip to content

Instantly share code, notes, and snippets.

View traviskroberts's full-sized avatar

Travis Roberts traviskroberts

View GitHub Profile
<%= link_to "Chart", manage_downloads_path(:view_graph => nil, :inner_tab => @inner_tab, :current_tab => @current_tab), :class => 'btn btn-primary' + (@view_graph ? 'active' : '') %>
@traviskroberts
traviskroberts / stock.rb
Created July 31, 2012 21:56
Grab unique vintages for accounts stocks.
def stocked_styles
joins("INNER JOIN wine_instances wi ON wi.id = stocks.wine_instance_id INNER JOIN wines w ON w.id = wi.wine_id INNER JOIN styles s ON s.id = w.style_id").select("DISTINCT(s.name) AS style_name").order("style_name").map { |s| s.style_name }
end
@traviskroberts
traviskroberts / stock.rb
Created July 31, 2012 21:38
Grab unique vintages for accounts stocks.
def stocked_countries
joins(<<END
INNER JOIN wine_instances wi ON wi.id = stocks.wine_instance_id
INNER JOIN wines w ON w.id = wine_instances.wine_id
INNER JOIN countries c c.id = w.country_id
END).select("DISTINCT(c.name) AS country_name").order("country_name").map { |v| v.country_name }
end
@traviskroberts
traviskroberts / cleaner_routes.rb
Last active October 3, 2015 17:58 — forked from dhh/gist:2492118
Route Organization
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}_routes.rb")))
end
end
BCX::Application.routes.draw do
draw :admin
draw :frontend
draw :resources
@traviskroberts
traviskroberts / gist:2399340
Created April 16, 2012 15:05
TextMate snippet for Bootstrap control group.
<div class="control-group">
<%= f.label_tag :${1:name}${2:, "${3:Name}"}, :class => "control-label${4: required}" %>
<div class="controls">
<%= f.${5:text_field}, :${1}${6:, :class => "${7:span5}"} %>
</div>
</div>
AED United Arab Emirates Dirham
AFN Afghanistan Afghani
ALL Albania Lek
AMD Armenia Dram
ANG Netherlands Antilles Guilder
AOA Angola Kwanza
ARS Argentina Peso
AUD Australia Dollar
AWG Aruba Guilder
AZN Azerbaijan New Manat
Wvision::Application.routes.draw do
namespace :api do
resources :accounts do
resources :cellars, :only => [:index, :create]
resources :wine_queue, :only => [:index]
resources :wines_to_pull, :only => [:index]
match '/queue/wines-to-pull', :to => 'wines_to_pull#index'
match '/queue/:name', :to => 'wine_queue#index'
end
resource :user_session, :controller => 'user_session'
<?php
/**
* sfProgressBar
*
* Draw a nifty progress bar for command-line tasks
*
* USAGE:
* // Create Progress Bar instance, pass number of increments
* $progressBar = new sfProgressBar($numItems);
*
def rebate_status(rebate_claim)
case rebate_claim.status
when 0
output = "New Claim"
when 1
output = "Pending LT Verification"
when 2
output = "Pending Property Verification"
when 3
output = "Disputed"