Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
# 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
#################################################################
#
# File: lib/api.rb
#
#################################################################
require 'user' # ActiveRecord model
# Connect to the db
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
class MailSender
def self.send_mail(smtp_settings, user, mail_subject, mail_body)
options = { :address => smtp_settings["address"],
:domain => smtp_settings["domain"],
:port => smtp_settings["port"].to_i,
:user_name => smtp_settings["user_name"],
:password => smtp_settings["password"],
:authentication => smtp_settings["authentication"],
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
# put this in /lib/resque.rb
require 'mail'
module Emailer
class Send
@queue = :issue_mailer
def self.perform(addressee, subject, body)
require 'mail'
module SpamBitch
module Phone
def self.carriers
{ claro: 'vtexto.com', att: 'txt.att.net', tmobile: 'sms.tmobile.net' }
end
def self.send_sms(telephone, msg, carrier)
options = {
require "csv"
desc "Import CSV file into an Active Record table"
task :csv_model_import, [:filename, :model] => :environment do |task,args|
firstline=0
keys = {}
CSV.foreach(args[:filename]) do |row|
if (firstline==0)
keys = row
firstline=1
require 'json'
require 'mail'
Mail.defaults do
delivery_method :smtp,
{ address: "smtp.sendgrid.net",
port: 587,
domain: 'heroku.com',
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
#!/usr/bin/ruby
require 'mail'
GMAIL_USERNAME = "username"
GMAIL_PASSWORD = "password"
options = { :address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361
function update_all {
cd $PROJECTS_PATH
for i in $(find . -type d); do
if [ -d "$i/.git" ]; then
echo -e "\033[1mPulling "$i"\033[0m"
cd "$i"
# pull repos without local changes
if git diff-index --quiet HEAD --; then
git pull --rebase --quiet > /dev/null
if [ -e Gemfile ]; then