Skip to content

Instantly share code, notes, and snippets.

View wbotelhos's full-sized avatar
💭
I'm not my code.

Washington Botelho wbotelhos

💭
I'm not my code.
View GitHub Profile
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@wbotelhos
wbotelhos / routes.rb
Last active June 2, 2023 14:03
How to Set Session on Rails Request Spec
# frozen_string_literal: true
Rails.application.routes.draw do
if Rails.env.test?
namespace :test do
resource :session, only: :create
end
end
end
/**
* @name InfoBox
* @version 1.1.11 [January 9, 2012]
* @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
* @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
* @fileoverview InfoBox extends the Google Maps JavaScript API V3 <tt>OverlayView</tt> class.
* <p>
* An InfoBox behaves like a <tt>google.maps.InfoWindow</tt>, but it supports several
* additional properties for advanced styling. An InfoBox can also be used as a map label.
* <p>
@wbotelhos
wbotelhos / libreadline_6_not_found.sh
Created November 29, 2016 20:42
Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
@wbotelhos
wbotelhos / gpg-safe.sh
Created September 27, 2019 19:00
gpg: WARNING: unsafe permissions on homedir '~/.gnupg'
sudo chown -R $USER ~/.gnupg
sudo chmod 700 ~/.gnupg
sudo chmod 600 ~/.gnupg/*
@wbotelhos
wbotelhos / firefox.sh
Last active June 8, 2022 04:22
Firefox Install (Ubuntu)
#!/bin/sh
set -e
# Firefox launcher containing a Profile migration helper for
# temporary profiles used during alpha and beta phases.
# Authors:
# Alexander Sack <asac@jwsdot.com>
# Fabien Tassin <fta@sofaraway.org>
@wbotelhos
wbotelhos / convert_sass_to_scss.sh
Created March 17, 2022 01:20
Convert SASS to SCSS
#!/bin/bash
convert() {
file=$1
target=${file//.sass/.scss}
paths_with_file=$(echo $file | tr '/' "\n" | wc -l | tr -d ' ')
paths_number=$(($paths_with_file - 4)) # app assets stylesheets ... filename.sass
@wbotelhos
wbotelhos / mysql-ld-library-not-found-for-lzstd.sh
Last active October 20, 2021 20:29
Mac ARM64 M1 - MySQL Error "ld: library not found for -lzstd"
gem install mysql2 -- --with-mysql-lib=$(brew --prefix)/Cellar/mysql/5.7.35/lib/ --with-mysql-dir=$(brew --prefix)/Cellar/mysql/5.7.35/ --with-mysql-config=$(brew --prefix)/Cellar/mysql/5.7.35/bin/mysql_config --with-mysql-include=$(brew --prefix)/Cellar/mysql/5.7.35/include/
@wbotelhos
wbotelhos / country-code-to-emoji-flag.rb
Created February 12, 2021 12:41
Country Code to Emoji Flag
def country_code_to_flag(country_code)
code = country_code.to_s.upcase
return unless code =~ /\A[A-Z]{2}\z/
code.codepoints.map { |codepoint| (codepoint + 127_397).chr(Encoding::UTF_8) }.join
end
country_code_to_flag("BR")
# => "🇧🇷"
@wbotelhos
wbotelhos / rails_schema_migration_cheat_sheet.md
Last active January 5, 2021 18:22
Rails Schema Migration Cheat Sheet

Migration

add_column :table_name, :column_name, :decimal, default: 0, precision: 15, scale: 10
add_column :table_name, :column_name, :jsonb, default: {}, null: false
add_column :table_name, :column_name, :string, array: true, default: []

add_foreign_key :table_name, :table_name
add_foreign_key :table_name, :table_name, column: :column_name, name: :index_table_name_on_column_name