Skip to content

Instantly share code, notes, and snippets.

View lbrito1's full-sized avatar

Leonardo Brito lbrito1

  • Coquitlam, BC
  • 18:02 (UTC -07:00)
View GitHub Profile
lbrito1 / openai-test.txt
Created March 22, 2024 21:41
Testing Chatgpt
Anthracite Mining
Soybean Farming
Oilseed (Except Soybean) Farming
Dry Pea and Bean Farming
Wheat Farming
Corn Farming
Rice Farming
Oilseed and Grain Combination Farming
All Other Grain Farming
lbrito1 /
Last active March 22, 2019 20:14
Friday Night Dev 22/03

Num contexto Ruby/Rails, como fazer testes de feature onde a interação com APIs/scripts externos seja essencial?

Interação do Staxe - investir em evento.

O problema é que essas requisições são feitas pelo driver do Capybara -- ou seja, um browser -- e não são capturadas pelo VCR por exemplo, nem são impedidas de rodar pelo Webmock.

Soluçoes atuai

  1. puffing-billy, que cria um proxy através do qual o driver faz todas as requisições. Vc controla o proxy, vc pode whitelist/blacklistar o que vc quiser.
  2. Wrappar os scripts que fazem requisições com um ERB para desabilitá-los se Rails.env.test?.
lbrito1 / serialization_benchmark.rb
Created March 21, 2019 17:36
JSON Serialization Benchmark Ruby/PG
require 'benchmark'
class SerializationBenchmark
def initialize
@temp_events = []
def create_events
1000.times do |i|
ev = Event.first.dup
lbrito1 /
Created February 19, 2019 19:42
RSpec failing seed finder
# Finds the first seed that breaks the spec suite. Outputs to stdout and a file (rspec_output).
while [ $found == 0 ]
rspec --order random 2>&1 | tee -a ./rspec_output
found=$(more rspec_output | grep Failed | wc -l)
if [ $found == 0 ]
lbrito1 / js_sleep.js
Last active June 28, 2018 13:49
console.log('Loaded external js')
lbrito1 /
Last active February 7, 2018 17:22
Solving mysql socket problem on docker


mysql container starts failing with Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock., even though you created the correct volume that is used by mysqld and it has the correct permissions (777). The problem persists even if you remove the pid files from mysqld dir or it is empty already.

Why does this happen?

Hell if I know. My guess is: "Enable external locking (system locking), which is disabled by default. If you use this option on a system on which lockd does not fully work (such as Linux), it is easy for mysqld to deadlock."

lbrito1 /
Last active February 6, 2018 14:50
Largest installed packages
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -30 | tac
lbrito1 / example2.rb
Last active March 20, 2017 14:03
Example #2 - Don't obsess over code DRYness
# Example 2
class Car
include Checkups
def maintenance_10k
def maintenance_30k
lbrito1 / example1.rb
Last active March 20, 2017 14:04
Example #1 - Don't obsess over code DRYness
# Example 1
class Car
include Checkups
def maintenance_10k
lbrito1 / wickedpdf-test.txt
Created October 11, 2016 15:57
wicked_pdf rake
$ rake
fatal: Not a git repository (or any of the parent directories): .git
Creating dummy application to run tests
create Rakefile
create .gitignore
create Gemfile