Skip to content

Instantly share code, notes, and snippets.

View mateusg's full-sized avatar

Mateus Gomes mateusg

View GitHub Profile
@mateusg
mateusg / labels2_simple_form_wrapper.rb
Created December 14, 2012 13:36
SimpleForm wrapper for http://attardi.org:81/labels2/ placeholder plugin.
config.wrappers :inline_form, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.wrapper :tag => 'label', :class => 'input' do |label|
label.use :label_text, :wrap_with => { :tag => 'span' }
label.use :input
end
end
@mateusg
mateusg / sample_deploy.rb
Created December 19, 2012 14:18
Clean Capistrano deploy file with bundler + rvm + permissions restore
# *** RVM CONFIGURATION ***
set :rvm_ruby_string, "ree-1.8.7-2012.02@#####"
set :rvm_type, :system
before 'deploy:setup', 'rvm:install_rvm' # install RVM
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, or:
require 'rvm/capistrano'
require "bundler/capistrano"
set :application, "#######"
@mateusg
mateusg / disable_newrelic_agent_before_start_resque.rb
Last active December 12, 2015 00:49
Fixes the error caused by NewRelic that prevents Resque workers from dying (https://github.com/defunkt/resque/issues/578#issuecomment-12509400). When newrelic_rpm >= 3.5.6.48 is released, remove this hotfix and update the gem.
# deploy.rb
# Fixes the error that prevents resque workers from dying, caused by NewRelic (https://github.com/defunkt/resque/issues/578#issuecomment-12509400).
# FIXME: When newrelic_rpm >= 3.5.6.48 is released, remove this hotfix and update the gem.
task :set_newrelic_false, :roles => [:resque_worker, :resque_scheduler] do
default_run_options[:env] = { 'NEWRELIC_ENABLE' => false }
end
before('resque:start', 'set_newrelic_false')
before('resque:scheduler:start', 'set_newrelic_false')
# === Sem o inverse_of
c = Customer.first
o = c.orders.first
c.first_name == o.customer.first_name # => true
c.first_name = 'Manny'
c.first_name == o.customer.first_name # => false
# === Com o inverse_of
class Customer < ActiveRecord::Base
has_many :orders, inverse_of: :customer
1.
Download the excel file with the current data for
= @table
= link_to 'here', '#'
@mateusg
mateusg / active_admin.pt-BR.yml
Created November 7, 2013 22:27
pt-BR translations for Active Admin
pt-BR:
active_admin:
dashboard: "Painel Administrativo"
dashboard_welcome:
welcome: "Bem vindo ao Active Admin. Esta é a página de painéis padrão."
call_to_action: "Para adicionar seções ao painel, verifique 'app/admin/dashboard.rb'"
view: "Visualizar"
edit: "Editar"
delete: "Remover"
delete_confirmation: "Você tem certeza que deseja remover este item?"
@mateusg
mateusg / carrierwave.pt-BR.yml
Created November 18, 2013 22:46
pt-BR translations for Carrierwave
pt-BR:
errors:
messages:
carrierwave_processing_error: "Não foi possível redimensionar imagem."
carrierwave_integrity_error: "Não é uma imagem."
carrierwave_download_error: "Não foi possível fazer download da imagem."
extension_white_list_error: "O formato %{extension} não é permitido. Formatos suportados: %{allowed_types}"
extension_black_list_error: "O formato %{extension} não é permitido. Formatos proibidos: %{prohibited_types}"
pt-BR:
simple_form:
"yes": 'Sim'
"no": 'Não'
required:
text: 'obrigatório'
mark: '*'
# You can uncomment the line below if you need to overwrite the whole required html.
# When using html, text and mark won't be used.
# html: '<abbr title="required">*</abbr>'
RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.before :suite do
DatabaseCleaner.clean_with :truncation
end
config.before :each do
if example.metadata[:js] || example.metadata[:truncation]
var parseDate = function(date) {
var year = 2000 + parseInt($('.period .filter').text().match(/^.*(\d{2})$/)[1])
date = date
.replace('Fev', 'Feb')
.replace('Abr', 'Apr')
.replace('Mai', 'May')
.replace('Ago', 'Aug')
.replace('Set', 'Sep')
.replace('Out', 'Oct')