Skip to content

Instantly share code, notes, and snippets.

Avatar

Mateus Gomes mateusg

  • Natal, Brazil
View GitHub Profile
View nubank_csv.js
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')
View database_cleaner.rb
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]
View simple-form.pt-BR.yml
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>'
@mateusg
mateusg / carrierwave.pt-BR.yml
Created Nov 18, 2013
pt-BR translations for Carrierwave
View carrierwave.pt-BR.yml
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}"
@mateusg
mateusg / active_admin.pt-BR.yml
Created Nov 7, 2013
pt-BR translations for Active Admin
View active_admin.pt-BR.yml
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?"
View thats_why_i_hate_haml.haml
1.
Download the excel file with the current data for
= @table
= link_to 'here', '#'
View inverse_of_example.rb
# === 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
@mateusg
mateusg / disable_newrelic_agent_before_start_resque.rb
Last active Dec 12, 2015
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.
View disable_newrelic_agent_before_start_resque.rb
# 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')
@mateusg
mateusg / sample_deploy.rb
Created Dec 19, 2012
Clean Capistrano deploy file with bundler + rvm + permissions restore
View sample_deploy.rb
# *** 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, "#######"
View labels2_simple_form_wrapper.rb
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
You can’t perform that action at this time.