View highlight.sh
highlight -O rtf 03.with_multiple_orms.rb --font-size 24 --font Inconsolata --style zenburn -W -J 80 -j 3 --src-lang ruby | pbcopy
View gist:0b9f6c477812817725741da212f571a0
Devise.setup do |config|
config.mailer_sender = ENV['EMAIL_FROM']
require 'devise/orm/active_record'
config.case_insensitive_keys = [:email]
config.strip_whitespace_keys = [:email]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 11
config.pepper = ENV['PASSWORD_PEPPER']
View null_seller.rb
# Only the sysadmin will have this type of {Seller}
class NullSeller < Seller
def active?
true
end
def activated?(key)
true
end
View null_object.rb
class Seller
belongs_to :user
def can_add_products?
products.count < seller.products_limit
end
def seller
if is_sysadmin?
NullSeller.new
View check_payments.rb
class PaymentGateway::MangoGateway < PaymentGateway
# Checks for payments
def check_payments
begin
payments = Mango::Charges.list(secret_api_key)
if payments.any?
logger.info "payments: #{payments.inspect}"
logger.info "[Mango] Payment Found! "
# ...
end
View talk.rb
class Animal
attr_accessible :kind
def talk
fail "I don't know how to talk! "
end
end
class Cat < Animal
def talk
View start.sh
#!/bin/bash
bundle check || bundle install
bundle exec rake db:migrate
bundle exec rails server
View setup.rb
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
chdir APP_ROOT do
# This script is a starting point to setup your application.
View index.liquid.html
<!-- index.liquid -->
{% if products.size > 0 %}
{% if keywords != nil %}
<h3 class="search-results-title">Resultados para: <span class="search-results-keywords">{{ keywords }}</span></h3>
{% if keywords contains "Camisa" or keywords contains "Camisas" %}
<span class="atencion">¡SÓLO ESTA SEMANA! Todas las camisas tienen descuento de 20% con el código CAMISOLA</span>
{% endif %}
{% endif %}
View show.liquid.html
<!-- show.liquid -->
<div id="cart-form">
{% if product | has_category: 'Envío Gratis' %}
<h1 class="jumbo">{{ product.name }}</h1>
{% else %}
<h1>{{ product.name }}</h1>
{% endif %}
<p class="prices">
<span class="price selling">{{ product.price_with_currency }}</span>
</p>