This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Uso: | |
# | |
# ruby digitos.rb 1980 1987 | |
# | |
puts (ARGV[0]..ARGV[1]).select {|n| n.chars.to_a.uniq.size == n.size}.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Rails 3.1 | |
# | |
def force_ssl(options = {}) | |
before_filter(options) do | |
if !request.ssl? && !Rails.env.development? | |
redirect_to :protocol => 'https://', :status => :moved_permanently | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def json_for_autocomplete(items, method, extra_data=[]) | |
items.collect do |item| | |
# | |
# Esta es la linea que importa, le estás diciendo a autocomplete que use nitprovedor como value | |
# | |
hash = {"id" => item.id.to_s, "label" => item.send(method), "value" => item.nitproveedor} | |
extra_data.each do |datum| | |
hash[datum] = item.send(datum) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Controller | |
class PostsController < ApplicationController | |
before_filter :authenticate_user!, :except => [:show, :index] | |
autocomplete :tag, :name | |
end | |
# Routes: | |
resources :posts do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form accept-charset="UTF-8" action="https://www.alipay.com/cooperate/gateway.do" id="payment-form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div> | |
<input id="out_trade_no" name="out_trade_no" type="hidden" value="123456" /> | |
<input id="partner" name="partner" type="hidden" value="20887XXX910XXX97" /> | |
<input id="total_fee" name="total_fee" type="hidden" value="0.01" /> | |
<input id="seller_email" name="seller_email" type="hidden" value="[email protected]" /> | |
<input id="notify_url" name="notify_url" type="hidden" value="http://127.0.0.1:3000/en-US?action=notify&controller=store%2Fcheckout%2Falipay" /> | |
<input id="return_url" name="return_url" type="hidden" value="http://127.0.0.1:3000/en-US?action=done&controller=store%2Fcheckout%2Falipay" /> | |
<input id="show_url" name="show_url" type="hidden" value="http://127.0.0.1:3000/en-US?action=show&controller=store%2Fcheckout%2Falipay" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@products.each_with_index do |p, i| | |
p.update_attribute(:date_available, i.minutes.ago) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- @shipping_methods.each do |method| | |
%p | |
= f.radio_button :shipping_method, method.service_code | |
= f.label :shipping_method, method.service_name, value: method.service_code | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |