Skip to content

Instantly share code, notes, and snippets.

View arthurnn's full-sized avatar
🟢
CI is passing

Arthur Nogueira Neves arthurnn

🟢
CI is passing
View GitHub Profile
diff -ruN twirp-1.8.0.7.ga1a8eb9/README.md twirp-1.10.0/README.md
--- twirp-1.8.0.7.ga1a8eb9/README.md 2023-01-10 12:01:35.000000000 -0500
+++ twirp-1.10.0/README.md 2023-01-10 12:07:42.000000000 -0500
@@ -1,6 +1,8 @@
# Twirp-Ruby
-[Twirp is a protocol](https://twitchtv.github.io/twirp/docs/spec_v5.html) for routing and serialization of services defined in a [.proto file](https://developers.google.com/protocol-buffers/docs/proto3), allowing easy implementation of RPC services with auto-generated clients in different languages.
+[![Run Tests](https://github.com/github/twirp-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/github/twirp-ruby/actions/workflows/tests.yml)
+
+[Twirp is a protocol](https://github.github.io/twirp/docs/spec_v5.html) for routing and serialization of services defined in a [.proto file](https://developers.google.com/protocol-buffers/docs/proto3), allowing easy implementation of RPC services with auto-generated clients in different languages.
@arthurnn
arthurnn / active_job_instrumentation.rb
Created February 12, 2019 12:54
Base instrumentation for ActiveJob + Sidekiq
def stats
# TODO
end
def dogtags
# TODO
end
ActiveSupport::Notifications.subscribe("enqueue.active_job") do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
@arthurnn
arthurnn / sendgrid_delivery.rb
Created December 17, 2018 16:50
Sendgrid mailer
# frozen_string_literal: true
require 'sendgrid-ruby'
require 'sendgrid_mailer/mailer'
class SendgridDelivery
class InvalidEmail < StandardError; end
def initialize(*)
end
@arthurnn
arthurnn / multi_shard_test.rb
Created February 27, 2018 11:56
Rails 5 connection swapping for sharding env
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" }
}
class Vitess < Formula
desc "Vitess is a database clustering system for horizontal scaling of MySQL."
homepage "http://vitess.io"
url "https://github.com/arthurnn/vitess.git",
:branch => "arthurnn/easier_build",
:revision => "f73a77ebe144e022db27c6eb9df92dc6b60a52ae"
head "https://github.com/arthurnn/vitess.git",
:shallow => false
version "2.1.1.f73a77"
require "active_record"
require "minitest/autorun"
class Person < ActiveRecord::Base
establish_connection adapter: "sqlite3", database: "foobar.db"
end
class ConnHandlerSwapTest < Minitest::Test
def setup
@readonly = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'bcrypt'
gem "activerecord", "~> 5.0.0"
gem 'sqlite3'
gem 'attr_encrypted', github: 'attr-encrypted/attr_encrypted', require: false
end
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "activerecord", "~> 5.0.0"
gem 'sqlite3'
gem 'attr_encrypted', '~> 3.0', require: false
end
require 'active_record'
@arthurnn
arthurnn / example_test.rb
Last active October 29, 2018 04:57
Load ActiveRecord fixtures from a block instead of a yml file
require 'minitest/autorun'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDOUT)
conn = { adapter: 'sqlite3', database: ':memory:' }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
connection.create_table :users, force: true do |t|
t.string :username
require 'active_support/all'
module SetupAndTeardown
extend ActiveSupport::Concern
included do
class_attribute :callbacks
self.callbacks = []
end