Skip to content

Instantly share code, notes, and snippets.

View tteurs's full-sized avatar
🏠
Working from home

Matheo Gracia Pegoraro tteurs

🏠
Working from home
  • Porto Alegre - RS- Brazil
  • 06:17 (UTC -03:00)
View GitHub Profile
@tteurs
tteurs / mysql2-apple-silicon-macos-sonoma.md
Created April 17, 2024 20:29 — forked from fernandoaleman/mysql2-apple-silicon-macos-sonoma.md
How to install mysql2 gem on apple silicon M1, M2 or M3 macOS Sonoma

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using

Faster Rails tests

Feedback loop speed in one of the biggest contributing factors to overall development time. The faster you get results, the faster you can move on to other things. A fast enough test suite is therefore critical to teams' success, and is worth investing some time at the beginning to save in the long run.

Below is a list of techniques for speeding up a Rails test suite. It is not comprehensive, but should definitely provide some quick wins. This list of techniques assumes you're using minitest, but most everything should translate over to rspec by simply replacing test/test_helper.rb with spec/spec_helper.rb.

git clone https://github.com/OpenDevin/OpenDevin.git
cd OpenDevin
conda create -n od python=3.10
conda activate od
docker ps
(optional) install docker if not already installed
docker pull ghcr.io/opendevin/sandbox
export OPENAI_API_KEY={your key}
(optional I had to install rust) curl --proto '=https' --tlsv1.2 -sSf [https://sh.rustup.rs](https://sh.rustup.rs/) | sh
(optional) restart terminal
estados = JSON.parse open('https://gist.githubusercontent.com/letanure/3012978/raw/36fc21d9e2fc45c078e0e0e07cce3c81965db8f9/estados-cidades.json').read
estados['estados'].select{|x| x['sigla'] != 'CE' }.each do |aux|
estado = Estado.find_or_create_by(sigla: aux['sigla'], descricao: aux['nome'].mb_chars.upcase.to_s
)
aux['cidades'].each do |cidade|
Municipio.find_or_create_by(estado:estado, descricao:cidade.mb_chars.upcase.to_s
)
end

Rails Active Storage how to restrict uploadable file types

Active Storage doesn't have validations yet.

We can restrict the accepted file types in the form:

<div class="field">
  <%= f.label :deliverable %>
 &lt;%= f.file_field :deliverable, direct_upload: true, 
@tteurs
tteurs / 00.md
Created June 29, 2023 06:02 — forked from maxivak/00.md
Load 'seed' data in Rails - rake task. Details: http://maxivak.com/loading-seed-data-in-rails/

Rake task to load 'seed' data in Rails

Keybase proof

I hereby claim:

  • I am tteurs on github.
  • I am tteu (https://keybase.io/tteu) on keybase.
  • I have a public key ASB329xUgIvrNp51BocCpsXZ7f2gpqQpQ_5b5Aw7TQn4Tgo

To claim this, I am signing this object:

@tteurs
tteurs / nginx.conf
Created October 18, 2019 17:54 — forked from tompave/nginx.conf
commented nginx.conf for Ruby on Rails
# A commented nginx configuration file for Ruby on Rails
#
# Author: Tommaso Pavese
# tommaso@pavese.me
# http://tommaso.pavese.me
#
# License: http://www.wtfpl.net/
#
#
# Tested with:
@tteurs
tteurs / rails_admin_import.pt-BR.yml
Created January 16, 2019 13:20
rails_admin_import gem translation to pt-BR
pt-BR:
admin:
actions:
import:
title: Importar
menu: Importar
breadcrumb: Importar
link: Importar
bulk_link: Importar
done: Importado
Verifying that +tteurs is my blockchain ID. https://onename.com/tteurs