Skip to content

Instantly share code, notes, and snippets.

View MarceloCajueiro's full-sized avatar

Marcelo G. Cajueiro MarceloCajueiro

View GitHub Profile
@MarceloCajueiro
MarceloCajueiro / argentina.sql
Created November 17, 2016 17:42
Cities and provinces from Argentina in a postgresql dump.
COPY cities (id, state_id, name, created_at, updated_at) FROM stdin;
1440 9 Ciudad Autónoma de Buenos Aires 2016-11-17 17:18:37.619255 2016-11-17 17:18:37.619255
1441 10 Carhué 2016-11-17 17:18:37.628344 2016-11-17 17:18:37.628344
1442 10 Colonia San Miguel Arcángel 2016-11-17 17:18:37.633553 2016-11-17 17:18:37.633553
1443 10 Delfín Huergo 2016-11-17 17:18:37.639846 2016-11-17 17:18:37.639846
1444 10 Espartillar 2016-11-17 17:18:37.64566 2016-11-17 17:18:37.64566
1445 10 Esteban Agustín Gascón 2016-11-17 17:18:37.653344 2016-11-17 17:18:37.653344
1446 10 La Pala 2016-11-17 17:18:37.660556 2016-11-17 17:18:37.660556
1447 10 Maza 2016-11-17 17:18:37.667124 2016-11-17 17:18:37.667124
1448 10 Rivera 2016-11-17 17:18:37.674722 2016-11-17 17:18:37.674722
@MarceloCajueiro
MarceloCajueiro / read_only_middleware.rb
Created February 21, 2016 12:55
Use database follower with Sidekiq
require 'delegate'
module SidekiqExt
# Use read-only database if :db option is :read_only,
# otherwise use the default connection.
#
# Example:
#
# class MyWorker
# include Sidekiq::Worker
@MarceloCajueiro
MarceloCajueiro / lista.md
Created November 26, 2015 21:20
Lista Suplementos
@MarceloCajueiro
MarceloCajueiro / heroku_killer.rb
Last active August 29, 2015 14:26
Heroku dyno killer
require 'pty'
require 'active_support'
require 'active_support/core_ext/time'
require 'active_support/core_ext/numeric'
TIMEOUT_TO_KILL_DYNO = 3.minute.from_now
TIMEOUT_TO_ANY_KILL = 30.seconds
MAX_PROBLEMS = 3
PROBLEMS = {
@MarceloCajueiro
MarceloCajueiro / gist:d32b9cb50cfd5777052b
Created May 21, 2015 12:59
Shell functions to use with Rails/Spring
rake() { if [ -f bin/rake ]; then bin/rake "$@"; else bundle exec rake "$@"; fi }
rails() { if [ -f bin/rails ]; then bin/rails "$@"; else bundle exec rails "$@"; fi }
rspec() { if [ -f bin/rspec ]; then bin/rspec "$@"; else bundle exec rspec "$@"; fi }
@MarceloCajueiro
MarceloCajueiro / gist:7254544
Created October 31, 2013 18:28
Delete jobs from sidekiq
queue = Sidekiq::Queue.new("low")
queue.each do |job|
if job.klass == "MailChimpUpdate"
job.delete
end
end
@MarceloCajueiro
MarceloCajueiro / f.rb
Created August 20, 2013 19:13 — forked from bricker/f.rb
def json
if self.persisted?
original_bylines_json = self.class.find(self.id).bylines.as_json
else
original_bylines_json = [].as_json
end
end
# ---------------
@media all {
.page-break {
display: none;
}
}
@media print {
.page-break {
display: block;
page-break-before: always;
class PeopleController < CrudController
respond_to :js
def new
object = build_resource
object.personable = Individual.new
super
end
@MarceloCajueiro
MarceloCajueiro / gist:5014692
Last active December 14, 2015 02:38
Simple way to print commit url
gh_commit(){
echo "https://github.com/$1/$2/commit/$3"
}
nohup_commit(){
gh_commit "nohupbrasil" $*
}
contabil_commit(){
nohup_commit "contabilidade" $*