Skip to content

Instantly share code, notes, and snippets.

View MatiasFernandez's full-sized avatar

Matias Fernandez MatiasFernandez

View GitHub Profile
@MatiasFernandez
MatiasFernandez / basic_auth.rb
Created December 16, 2014 15:16
Add HTTP Basic Auth to any environment except Development and Test to Rails App
unless Rails.env.development? || Rails.env.test?
YourApplication::Application.configure do |config|
config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Application Name") do |u, p|
[u, p] == [ENV['HTTP_USER'], ENV['HTTP_PASSWORD']]
end
end
end
@MatiasFernandez
MatiasFernandez / gist:82da986c9ccfe8fe836e
Created December 16, 2014 20:51
Filter "Visual Event" events by DOM element using jQuery
$.grep(VisualEvent.instance.s.elements, function(e) { return e.node == $('JQUERY_SELECTOR')[0] })
@MatiasFernandez
MatiasFernandez / application.rb
Created May 3, 2016 17:25
Log Capybara Exceptions
# Note: Add the uncommented lines inside the Application class definition inside application.rb file
# [...]
# class XYZ < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(::Diagnostic)
end
@MatiasFernandez
MatiasFernandez / sidekiq_queue.rb
Last active September 21, 2016 20:02
Sidekiq API Extension. Some useful code to interact with Sidekiq API in a simple way
class SidekiqQueue < Sidekiq::Queue
def newer(limit = 1)
fetch_one_or_more_jobs(starting: :back, limit: limit)
end
def older(limit = 1)
fetch_one_or_more_jobs(starting: :front, limit: limit)
end
def all
@MatiasFernandez
MatiasFernandez / log_sql.rb
Last active May 28, 2019 15:45
Show SQL logging in rails console
ActiveRecord::Base.logger = Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
@MatiasFernandez
MatiasFernandez / changed_ruby_files.rb
Last active September 26, 2017 13:45
Git pre commit hook to run rubocop on modified files
force_skip = ['master', 'develop'].include? `git rev-parse --abbrev-ref HEAD`.strip
diff_files = []
# Note: ACMRTUXB is all file types except delete
diff_files.concat(`git --no-pager diff --name-only --diff-filter='ACMRTUXB' origin/develop...`.split(/\n/))
diff_files.concat(`git --no-pager diff --name-only --diff-filter='ACMRTUXB' --cached`.split(/\n/))
if force_skip || diff_files.empty?
# so that rubocop doesnt run any tests
puts '-v'
@MatiasFernandez
MatiasFernandez / script.rb
Created August 2, 2017 15:05
Edit schema migrations table
class SchemaMigration < ActiveRecord::Base; self.primary_key = :version; end
@MatiasFernandez
MatiasFernandez / fetch_csv.rb
Last active October 3, 2018 14:22
Fetch remote CSV
def remote_csv(url)
CSV.new(open(url))
end
@MatiasFernandez
MatiasFernandez / cd-agiles2017.md
Created October 15, 2017 19:31
Continuous Deployment sin equipos de QA ni de ops - Agiles 2017 Chile

Continuous Deployment sin equipos de QA ni ops - Ágiles 2017 Chile

Abstract

En esta charla cuento mi experiencia trabajando en un proyecto para una empresa de Estados Unidos en donde pasamos de un modelo de release train con releases diarios a continuous deployment con múltiples releases por día. Todo esto lo logramos sin tener ningun equipo de QA ni de operaciones, solo developers.

Slides: https://www.slideshare.net/Azagthot/continuous-deployment-sin-equipos-de-qa-ni-de-ops-80834132

Info adicional

@MatiasFernandez
MatiasFernandez / errores-a17.md
Created October 17, 2017 12:20
Clasificacion y priorizacion de errores y bugs - Agiles 2017 Chile

Clasificacion y priorizacion de errores y bugs - Ágiles 2017 Chile

Abstract

En esta charla cuento sobre un proceso que diseñamos, inspirados en la medicina, para clasificar y priorizar todos los errores que aparecen en nuestro sistema de forma inesperada. De forma de poder conocer el 100% de los errores que ocurren y poder tener feedback continuo sobre el estado del sistema, algo que es muy importante cuando se utiliza continuous deployment.

Slides: https://www.slideshare.net/Azagthot/clasificacion-y-priorizacion-distribuida-de-errores-y-bugs

Info adicional