Skip to content

Instantly share code, notes, and snippets.

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

thadeu thadeu

🏠
Working from home
View GitHub Profile
@thadeu
thadeu / async_wrapper.rb
Last active April 17, 2025 14:48
Ruby Async Wrapper & Promise
# frozen_string_literal: true
module AsyncWrapper
def self.included(base)
base.extend(ClassMethods)
end
def self.extended(base)
base.extend(ClassMethods)
end
@thadeu
thadeu / keybindings.json
Created November 25, 2024 15:49
VSCode Keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+shift+.",
"command": "erb.toggleTags",
"when": "editorTextFocus && editorLangId == erb"
},
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
@thadeu
thadeu / promise.rb
Created July 18, 2024 00:01
Promise pattern using Ruby like JS
require 'pry'
require 'benchmark'
require 'httparty'
def http_get(url)
response = HTTParty.get(url)
# p response.status
if response.code != 200
raise StandardError.new("http_get (#{url}) Error: #{response.code}")
@thadeu
thadeu / alacritty.toml
Created June 5, 2024 20:11
Alacritty configuration
# https://alacritty.org/config-alacritty.html
import = []
[font]
size = 14.0
normal = { family = 'JetBrainsMono Nerd Font Mono' }
## Mount NVMe EBS Extra Volume
https://docs.aws.amazon.com/pt_br/AWSEC2/latest/UserGuide/ebs-using-volumes.html
https://devopscube.com/mount-ebs-volume-ec2-instance/
https://ripon-banik.medium.com/mount-nvme-ebs-volume-on-ec2-and-persist-on-reboot-f29fd86f9fee
lsblk -f
mkfs -t ext4 /dev/nvme1n1
file -s /dev/nvme1n1
mkdir /data
@thadeu
thadeu / hash_monkeypatch.rb
Last active September 22, 2022 15:30
Ruby Deep OpenStruct
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'json', require: true
end
class Hash
@thadeu
thadeu / clear-sidekiq-jobs.sh
Created July 26, 2021 20:54 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@thadeu
thadeu / RecursiveQuery.js
Last active June 1, 2021 15:09
DynamoDB Recursive Query
class RecursiveQuery {
static async findByPk(props) {
const { pk, evaluatedKey = null, data = [], keys = null } = props;
const queryProps = {
IndexName: "GSI_INDEX_NAME",
KeyConditionExpression: "pk = :pk",
ExpressionAttributeValues: { ":pk": pk },
ExclusiveStartKey: evaluatedKey,
};
@thadeu
thadeu / README.md
Last active June 26, 2020 01:18
Import CSV to heroku from remote csv

Into terminal

$ heroku run console --app MY_APP --no-tty < import_remote_csv.rb
@thadeu
thadeu / .gitconfig
Created April 8, 2020 15:26
Alias to .gitconfig
[alias]
psh = push origin HEAD
cm = checkout master
co = checkout
cb = checkout -b
amend = commit -a --amend
ahead = "!sh -c 'echo branch is $(git fetch origin --quiet && git rev-list --count origin/master..HEAD) commits ahead, $(git fetch origin --quiet && git rev-list --count HEAD..origin/master) commits behind master'"
ci = commit
st = status -sb