Skip to content

Instantly share code, notes, and snippets.

View hugomaiavieira's full-sized avatar

Hugo Maia Vieira hugomaiavieira

View GitHub Profile
@fernandoaleman
fernandoaleman / mysql2-apple-silicon-macos-sonoma.md
Created November 2, 2023 16:32
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

Edit 2024-02-05:

The instructions below are outdated.

There is an official PR (#2027) for mouse functionality. You should use that rather than what is described below.

See comments [1, 2] below.

ZMK mouse support

@dteoh
dteoh / rspec_rails_set_session.md
Created May 29, 2020 07:49
Setting session variables in an RSpec Rails request spec

Setting session variables in an RSpec Rails request spec

You are writing a spec with type: :request, i.e. an integration spec instead of a controller spec. Integration specs are wrappers around Rails' ActionDispatch::IntegrationTest class. I usually write controller tests using this instead of type: :controller, mainly because it exercises more of the request and response handling stack. So instead of writing something like get :index to start the request, you would write get books_path or similar.

One of the issues with using type: :request is that you lose the ability to

@contraexemplo
contraexemplo / pulseaudio-noise-cancelling.md
Last active October 20, 2023 18:15
Como ativar o módulo de cancelamento de ruído do PulseAudio

Primeiro, verifique se o módulo está presente na sua instalação digitando pacmd em seu terminal, listando todos os módulos presentes pelo comando list-modules e procurando por module-echo-cancel. Não está presente? Você precisa adicionar algumas linhas ao arquivo de texto responsável pela configuração do PulseAudio.

Com o seu editor favorito, abra (com privilégios de administrador) o arquivo /etc/pulse/default.pa e adicione as seguintes linhas ao fim do arquivo:

### Enable Echo/Noise-Cancellation
load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1" source_name=echoCancel_source sink_name=echoCancel_sink
set-default-source echoCancel_source
set-default-sink echoCancel_sink
@wteuber
wteuber / encrypt_decrypt.rb
Last active May 10, 2024 12:04
Simply encrypt and decrypt Strings in Ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end
@whistler
whistler / jenkins_rails_ubuntu.sh
Created July 26, 2012 02:33
Set up Jenkins and Rails on Ubuntu server
sudo aptitude install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install libmysqlclient-dev ruby-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install libreadline-dev
### Install Java ###
sudo apt-get install openjdk-6-jre-headless
@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@hugomaiavieira
hugomaiavieira / clearCache.sh
Last active October 18, 2023 19:41
Script para limpar o cache do seu Linux
#!/bin/sh
#
# Salve este script no diretório /etc/cron.hourly e dê permissão
# de execução a ele. Desse modo a cada hora sera verificada se a
# porcentagem de memória utilizada pelo sistema atingiu o valor definido
# na variável 'percent'. Caso positivo, o script informará ao kernel
# que este deverá alterar o valor da opção 'drop_caches' para 3.
#
# Mais detalhes: 'man proc' -> /proc/sys/vm/drop_caches.
PATH="/bin:/usr/bin:/usr/local/bin"
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end