Skip to content

Instantly share code, notes, and snippets.

Arthur Nogueira Neves arthurnn

Block or report user

Report or block arthurnn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
arthurnn / active_job_instrumentation.rb
Created Feb 12, 2019
Base instrumentation for ActiveJob + Sidekiq
View active_job_instrumentation.rb
def stats
def dogtags
ActiveSupport::Notifications.subscribe("enqueue.active_job") do |*args|
event =*args)
View sendgrid_delivery.rb
# frozen_string_literal: true
require 'sendgrid-ruby'
require 'sendgrid_mailer/mailer'
class SendgridDelivery
class InvalidEmail < StandardError; end
def initialize(*)
arthurnn / multi_shard_test.rb
Created Feb 27, 2018
Rails 5 connection swapping for sharding env
View multi_shard_test.rb
require "active_record"
require "minitest/autorun"
ENV["RAILS_ENV"] = "development"
ActiveRecord::Base.configurations = {
"development" => { "adapter" => "sqlite3", "database" => "fake.db" },
"shard1" => { "adapter" => "sqlite3", "database" => "shard1.db" },
"shard2" => { "adapter" => "sqlite3", "database" => "shard2.db" }
View vitess.rb
class Vitess < Formula
desc "Vitess is a database clustering system for horizontal scaling of MySQL."
homepage ""
url "",
:branch => "arthurnn/easier_build",
:revision => "f73a77ebe144e022db27c6eb9df92dc6b60a52ae"
head "",
:shallow => false
version "2.1.1.f73a77"
View conn_handler_swap_test.rb
require "active_record"
require "minitest/autorun"
class Person < ActiveRecord::Base
establish_connection adapter: "sqlite3", database: "foobar.db"
class ConnHandlerSwapTest < Minitest::Test
def setup
@readonly =
View test_encrypted_gem.rb
require "bundler/inline"
gemfile(true) do
source ""
gem 'bcrypt'
gem "activerecord", "~> 5.0.0"
gem 'sqlite3'
gem 'attr_encrypted', github: 'attr-encrypted/attr_encrypted', require: false
View encrypt_test.rb
require "bundler/inline"
gemfile(true) do
source ""
gem "activerecord", "~> 5.0.0"
gem 'sqlite3'
gem 'attr_encrypted', '~> 3.0', require: false
require 'active_record'
arthurnn / example_test.rb
Last active Oct 29, 2018
Load ActiveRecord fixtures from a block instead of a yml file
View example_test.rb
require 'minitest/autorun'
require 'active_record'
ActiveRecord::Base.logger =
conn = { adapter: 'sqlite3', database: ':memory:' }
class User < ActiveRecord::Base
connection.create_table :users, force: true do |t|
t.string :username
View test.rb
require 'active_support/all'
module SetupAndTeardown
extend ActiveSupport::Concern
included do
class_attribute :callbacks
self.callbacks = []
You can’t perform that action at this time.