Skip to content

Instantly share code, notes, and snippets.

View ch1ago's full-sized avatar
🏠
Working mostly from home since 2006

Thiago Almeida ch1ago

🏠
Working mostly from home since 2006
  • Mexico City
  • 15:00 (UTC -06:00)
View GitHub Profile
upstream unicorn_proxy_api {
server proxy_api_1 fail_timeout=0;
server proxy_api_2 fail_timeout=0;
server proxy_api_3 fail_timeout=0;
server proxy_api_4 fail_timeout=0;
server proxy_api_5 fail_timeout=0;
server proxy_api_6 fail_timeout=0;
echo "***** UPDATE *****"
apt-get -yq update
echo "***** INSTALL PACKAGES *****"
apt-get -yq install curl git-core python g++ make python-software-properties libqt4-dev build-essential bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev libmagickwand-dev imagemagick
apt-get -yq install xvfb firefox
echo "***** DOWNLOADING *****"
@ch1ago
ch1ago / urlbox.rb
Last active August 29, 2015 13:55 — forked from urlbox/urlbox.rb
# not necessary in Rails
require 'cgi'
require 'openssl'
require 'open-uri'
# OPTIONS :force, :full_page, :thumb_width, :width, :height
def urlbox(url, options={})
urlbox_apikey = 'xxx-xxx'
urlbox_secret = 'xxx-xxx'
@ch1ago
ch1ago / cart.rb
Last active December 21, 2015 20:18
class Cart < ActiveRecord::Base
has_many :cart_lines
accepts_nested_attributes_for :cart_lines, allow_destroy: true
....
end
class CartLine < ActiveRecord::Base
belongs_to :cart
belongs_to :product
%w[old_price main_price cost_price].each do |k|
def q_#{k}
quantity * #{k}
end
end
Feature: Site Follow
In order to follow somebody
As a user
I want to click and follow
Scenario: As a visitor
Given the sample users
And I am a visitor
And I am on @ned's site page
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'pg'
gem 'rails-i18n'
gem 'spree', github: 'spree/spree'
gem 'spree_i18n', github: 'spree/spree_i18n'
class FoosController < ApplicationController
before_action :set_foo, only: [:show, :edit, :update, :destroy]
# GET /foos
def index
@foos = Foo.all
end
# GET /foos/1
def show
# t.string "key"
# t.string "val"
class MyConfig < ActiveRecord::Base
class << self
def all_as_hash
begin
Rails.cache.fetch(:my_config_hash) do
h = {}
all.each { |m| h[m.key] = m.val }
@ch1ago
ch1ago / start
Last active December 14, 2015 02:48
#!/bin/sh
### BEGIN INIT INFO
# Provides: stalker_crown_production
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage stalker process
# Description: Start, stop, restart stalker process for a specific application.
### END INIT INFO