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 / 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
@thadeu
thadeu / rspec_model_testing_template.rb
Created April 3, 2020 13:33 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@thadeu
thadeu / csv.js
Created March 16, 2020 12:55
Generate CSV with JS Native
export default function Csv() {}
Csv.parse = function(data) {}
Csv.compose = function(data) {
let values = []
let header = Object.keys(data[0])
let csv = header.join(',')
// each object values
@thadeu
thadeu / README.md
Last active February 6, 2020 18:43
tcpdump 5060 sip messages

method 1

tcpdump -nqt -s 0 -A -i eth0 port 5060 -w /tmp/dump.pcap

tcpdump -qns 0 -A -r /tmp/dump.pcap

method 2

apt-get install ngrep sipgrep sngrep.

@thadeu
thadeu / update-datetime-debian.md
Last active February 5, 2020 21:55
Check and Update date to debian

Check and Update date to debian

List timezones easily

  $ timedatectl list-timezones

Set timezone to America/Sao_Paulo

on run {input, parameters}
set paths to ""
repeat with i from 1 to length of input
set cur to item i of input
set paths to paths & " " & quote & POSIX path of cur & quote
end repeat
set cmd to "vim -p" & paths
tell application "iTerm"
set created to false
if not (exists current window) then