Skip to content

Instantly share code, notes, and snippets.

View mgswolf's full-sized avatar

Marcelo Giovane Silva mgswolf

  • DefIndex
  • Goiânia, Goiás, Brasil
View GitHub Profile
@mgswolf
mgswolf / deploy.rb
Created January 15, 2012 22:31
Example Capistrano GIT and RVM on Amazon EC2
# General
ssh_options[:keys] = ["#{ENV['HOME']}/.ssh/amazon.pem"]
set :application, "test_app"
set :user, "ubuntu"
set :domain, "your_domain.com"
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :copy
set :use_sudo, false
@mgswolf
mgswolf / gist:1618051
Created January 15, 2012 23:47
Nginx init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d script for Ubuntu 8.10 and lesser versions.
# Description: nginx init.d script for Ubuntu 8.10 and lesser versions.
### END INIT INFO
@mgswolf
mgswolf / gist:2637961
Created May 8, 2012 17:54
Nested attribute UJS on a big number of records
#Artist Model
class Artist < ActiveRecord::Base
has_many :performers, :dependent => :destroy
has_many :musics, :through => :performers
#default_scope order(:name)
def self.find_ordened_artists
@mgswolf
mgswolf / rails_template.rb
Created July 11, 2012 18:24
Rails Template
# Application Generator Template
# Modifies a Rails app to use Devise with RSpec and Cucumber
# Usage: rails new APP_NAME -m rails_template.rb -T
# Information and a tutorial:
# https://github.com/RailsApps/rails3-devise-rspec-cucumber
# Generated using the rails_apps_composer gem:
# https://github.com/RailsApps/rails_apps_composer/
@mgswolf
mgswolf / pdf-kit.rb
Created October 29, 2012 17:11
example use of pdf-kit
# your controller
def export_pdf
html = render :layout => 'print' #or false
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root/app/assets/stylesheets/print.css"
require 'faker'
puts '---Cleaning DataBase --'
[User].map(&:delete_all)
#admin
puts '---Creating Admin user ---'
User.create!(email: '[email protected]', password: 'taskpass', name: 'Admin Tasks')
#normal users
#show.html.erb
<%= link_to show_image(r.imagem_url(:thumb)), reclamacao_path(r) %>
<%= link_to reclamacao_path(r) do %>
<%= image_tag(r.imagem_url(:thumb)) if r.imagem.present? %>
<% end %>
#application_helper.rb
en:
routes:
pt-BR:
routes:
home: inicio
new: novo
edit: editar
destroy: destruir
password: senha
sign_in: entrar