Skip to content

Instantly share code, notes, and snippets.

View rwillians's full-sized avatar

Rafael Willians rwillians

View GitHub Profile
@rwillians
rwillians / a.js
Created February 13, 2024 18:50
express rescue
const rescue = require('express-rescue')
class UserNotFound extends Error {}
// ...
app.get('/users/:id', [
rescue(async (req, res) => {
throw new UserNotFound(/* ... */)
},
@rwillians
rwillians / README.md
Last active February 11, 2024 15:31
if, switch ou strategy

If

Se há apenas duas possibilidades, uso if/else apenas como ternário:

return foo === null
  ? fizz
  : buzz
@rwillians
rwillians / compose.yml
Created January 30, 2024 16:02
nginx X-Forwarded-For and X-Real-IP
version: '3.9'
services:
nginx:
image: nginx:1.25.3-alpine
depends_on:
- api
ports:
- 3000:80
volumes:
@rwillians
rwillians / .editorconfig
Last active December 5, 2023 12:37
Project Setup
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
insert_final_newline = true
indent_style = space
trim_trailing_whitespace = true
@rwillians
rwillians / build-push-linux-amd64.sh
Created August 24, 2023 13:34
Scripts for manually building multi-platform image using more than 1 machine
#! /usr/bin/env sh
#
# Rode em uma máquina x64 (intel/amd)
#
VERSION='0.2.5'
docker --context=default buildx build \
-t "ghcr.io/rwillians/rinha-de-backend--elixir-plug-bandit-ecto:${VERSION}-amd64" \
@rwillians
rwillians / sample-0.yaml
Last active May 13, 2023 00:43
Sample form representation
fields:
- name: user-name
label: What's your name?
type: short-text
required: true
data:
placeholder: Jane Doe
- name: user-email
label: What's your email?
type: email
@rwillians
rwillians / resume.json
Last active January 23, 2024 13:08
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/master/schema.json",
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Rafael Willians",
"label": "Sr. Backend engineer",
"pronoums": "he/him",
"image": "https://s.gravatar.com/avatar/0d7ab408fb9411f7950957dfaa9d5472?s=100&r=pg&d=mm",
@rwillians
rwillians / index.js
Last active April 2, 2022 22:54
Hacker Rank - DS - 2D Arrays - JavaScript
'use strict'
const input = [
[-9, -9, -9, 1, 1, 1],
[ 0, -9, 0, 4, 3, 2],
[-9, -9, -9, 1, 2, 3],
[ 0, 0, 8, 6, 6, 0],
[ 0, 0, 0, -2, 0, 0],
[ 0, 0, 1, 2, 4, 0]
]
@rwillians
rwillians / .tool-versions
Created October 31, 2019 21:02
Sign token using joken
elixir 1.9.2
erlang 22.1
@rwillians
rwillians / cluster-down.sh
Created July 14, 2017 18:57
Local Swarm Cluster
#!/bin/bash
forceflag='false'
while getopts 'f' flag; do
case "${flag}" in
f) forceflag='true' ;;
esac
done