Skip to content

Instantly share code, notes, and snippets.

View JuarezLustosa's full-sized avatar
Working from home

Juarez Lustosa JuarezLustosa

Working from home
View GitHub Profile
class Rate
attr_accessor :credit_card, :value,
def self.calculate(credit_card, value)
new(credit_card, value).calculate
def initialize(credit_card, value)
@credit_card = credit_card
@value = value.to_i
Ruby e Rails
Livros (Free mas vale pagar um café para o autor ;) ):
Livros (Pagos):
JuarezLustosa /
Created November 19, 2018 15:56 — forked from maxivak/
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.


Create your mailer us usual:

JuarezLustosa /
Created November 7, 2017 18:45 — forked from sfate/
vim on heroku
#!/usr/bin/env bash
curl --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
def set_pay_plan
progress = self.progress
case progress
when 0.01..0.74
self.pay_plan = "s-20"
when 0.75..0.84
self.pay_plan = "s-225"
when 0.85..1.05
In addition, here is the code I used for the solution Chris suggested, for anyone interested.
# /models/concerns/location_validations.rb
module LocationValidations
extend ActiveSupport::Concern
included do
validates :name, presence: true
validates :address, presence: true
validates :state, presence: true
JuarezLustosa / gist:292b59e3f36155906f1482e2ec9eaa7d
Created December 6, 2016 19:36
Javascript Desempenho entre typeof e direct
var loops = 1e8,
while(loops--) {
if( typeof foo !== 'undefined' ) {}
loops = 1e8;
JuarezLustosa / filterable.rb
Created February 11, 2016 18:27 — forked from justinweiss/filterable.rb
# Call scopes directly from your URL params:
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
#!/usr/bin/env bash
apt-get -y update
apt-get install build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
apt-get install gcc
cd /tmp
tar -xvzf ruby-1.9.3-p374.tar.gz
cd ruby-1.9.3-p374/
./configure --prefix=/usr/local