Skip to content

Instantly share code, notes, and snippets.

View lbrito1's full-sized avatar

Leonardo Brito lbrito1

  • frdm.co
  • Coquitlam, BC
  • 18:51 (UTC -07:00)
View GitHub Profile
@lbrito1
lbrito1 / openai-test.txt
Created March 22, 2024 21:41
Testing Chatgpt
Florists
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
lbrito1 / friday_dev_22-03.md
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
lbrito1 / serialization_benchmark.rb
Created March 21, 2019 17:36
JSON Serialization Benchmark Ruby/PG
require 'benchmark'
class SerializationBenchmark
def initialize
@temp_events = []
end
def create_events
1000.times do |i|
ev = Event.first.dup
@lbrito1
lbrito1 / rspec_finder.sh
Created February 19, 2019 19:42
RSpec failing seed finder
#!/bin/bash
# Finds the first seed that breaks the spec suite. Outputs to stdout and a file (rspec_output).
found=0
while [ $found == 0 ]
do
rspec --order random 2>&1 | tee -a ./rspec_output
found=$(more rspec_output | grep Failed | wc -l)
if [ $found == 0 ]
@lbrito1
lbrito1 / js_sleep.js
Last active June 28, 2018 13:49
js_sleep.js
console.log('Loaded external js')
@lbrito1
lbrito1 / fix_mysql_docker.md
Last active February 7, 2018 17:22
Solving mysql socket problem on docker

Probem

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."

https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_external-locking

@lbrito1
lbrito1 / largest_packages.sh
Last active February 6, 2018 14:50
Largest installed packages
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -30 | tac
@lbrito1
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
basic_maintenance
end
def maintenance_30k
basic_maintenance
@lbrito1
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
check_break_fluid
check_battery_terminals
check_engine_oil
end
@lbrito1
lbrito1 / wickedpdf-test.txt
Created October 11, 2016 15:57
wicked_pdf rake
lbrito@xps:~/.rvm/gems/ruby-2.3.1/gems/wicked_pdf-1.1.0
$ rake
fatal: Not a git repository (or any of the parent directories): .git
Creating dummy application to run tests
create
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile