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
  • 17:20 (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

@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:
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

MacOS

Download from here:

http://d.pr/f/QE3d

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to:

@tteurs
tteurs / install.md
Created January 31, 2014 17:39 — forked from galulex/install.md

Developer libs

mysql, rmagic, curl, git, vim, sqlite, nodejs nokogiri...

sudo apt-get install libxslt-dev libxml2-dev libmagickwand-dev imagemagick libsqlite3-dev libcurl3-dev curl git git-gui vim-gtk mysql-server mysql-client libmysql-ruby libmysqlclient-dev mysql-workbench ctags icedtea-plugin nodejs rar wmctrl

Ruby

ruby 1.9.3