Skip to content

Instantly share code, notes, and snippets.

View dabit's full-sized avatar

David Padilla dabit

View GitHub Profile
module Uno
def queue_mode
@queue_mode ||= :single
end
def queue_mode=(value)
@queue_mode = value
end
def enqueue_mode(mode)
%h2
Brands
.brands
-('A'..'Z').each do |letter|
-li_brands=""
[email protected] do |brand|
-if brand.name.slice(0..0).upcase == letter
-li_brands+="<li>#{link_to(brand.name,{:controller=>:brands, :action => :show, :id =>brand.to_param}, :class=>"#{brand.name}")}</li>"
-unless li_brands==""
def self.use_certificate(code, cart)
return false if cart.nil?
return cart.set_gift(0, nil) if code.blank?
return false if cart.gift_code == code
certificate = self.certificate(code).first
unless certificate.blank? || certificate.state == 'in_cart'
unless certificate.state == 'empty'
total = cart.total + cart.gift_discount
if certificate.amount < total
.clear.sizes
- @product.grouped_attributes.each do |attribute,upcs|
= attribute.name
%br
%ul.sizes.details
- attribute.cached_size_values.each do |size|
- if upc = upcs.detect {|u| u.size == size}
%li
= check_box_tag "post[upc_id]", storefront_update_sellers_list_path(upc.id), false, :class => "post_upc_class", :id => upc.id
%a{:href => "#", :class => "chk-select"}
@dabit
dabit / lines.haml
Created September 5, 2011 20:11
HAML.haml
%div
Este es tu nombre de usuario:
= "#{current_user.name}"
Gracias por ser como eres, vales mil
SimpleCov.at_exit do
percent = SimpleCov.result.covered_percent
unless percent == 100.0
puts "Coverage is not at 100% !!!!"
Kernel.exit(1)
end
end
@dabit
dabit / fields_for.html.haml
Created September 20, 2011 05:24
fields_for.html.haml
- i ||= 0
= f.fields_for :options do |ff|
- i += 1
%label Option #{i}
@dabit
dabit / shots.feature
Created September 20, 2011 05:29
shots.feature
 @javascript
 Scenario: Add image for different countries
   Given a country exists with name: "Mexico", locale: "en_MX"
   And a country exists with name: "United States", locale: "en_US"
   And an event exists with name: "Huge Sale"
When I go to the edit event page for "Huge Sale"
   And I select "United States" as the country
When I attach the file "spec/support/logo.jpg" to "Image"
And I press "Update"
Then I should see an image
def display_item(item)
to_return = []
if item.upc?
if item.item
to_return << item.quantity
to_return << "<a href='#{edit_admin_product_path(item.item.product.id)}'>#{item.item.product.name}</a>"
to_return << item.item.product_attribute.name
to_return << item.item.size.name
end
else
@dabit
dabit / alias.sh
Created October 7, 2011 16:00
Useful aliases
alias gs="git status"
alias gc="git commit"
alias gp="git push"
alias gpl="git pull"
alias r=rails
alias ga="git add"
alias gr="git rm"
alias clean="find . -name \"*.orig\" -print -exec rm {} \;"
alias be="bundle exec"
alias ber="bundle exec rake"