Skip to content

Instantly share code, notes, and snippets.

View uqmessias's full-sized avatar
🤓
Being a Nerd...

Uilque Messias uqmessias

🤓
Being a Nerd...
View GitHub Profile
/**
* @param {number} num
* @returns {string}
*/
function formatMoney(num) {
return `R$ ${num
.toFixed(2)
.replace('.', ',')
.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.')}`;
}
@uqmessias
uqmessias / aposentadoria.js
Created July 26, 2024 15:49
Função para calcular a quantidade de meses que alguém poderia gastar um determinado dinheiro considerando o rendimento desse dinheiro e também para calcular quanto de dinheiro se consegue juntar com o rendimento mensal.
const fs = require("fs");
const path = require("path");
const crypto = require("crypto");
const stream = require("stream/promises");
const readline = require("readline");
const { totalmem } = require("os");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
@uqmessias
uqmessias / countries-names-and-flags-in-portuguese-brazil-pt-br.md
Last active August 1, 2024 18:39
The list of all (or almost all) countries with their names and flag codes in brazilian portuguese (pt-br) and english — Lista de todos (ou quase todos) os países com seus nome e códigos de bandeiras em português brasileiro (pt-br) e inglês.
var countriesInPortugueseBR = [
    {
      flag: 'af',
      nameEn: 'Afghanistan',
      namePt: 'Afeganistão',
    },
    {
      flag: 'za',
@uqmessias
uqmessias / README.md
Last active July 20, 2024 01:21
CLI tool to help me to remove duplicate files in a folder (recursively)

Remove duplicate files CLI

How to use it

$ node ./removeDuplicateFilesCli.js
package br.com.uilquemessias.utils;
import android.os.IBinder;
import android.support.test.espresso.Root;
import android.view.WindowManager;
import org.androidannotations.annotations.res.StringRes;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
@uqmessias
uqmessias / devices-model-resolution.md
Last active February 29, 2024 03:27
Some Android devices dimensions
const SALARIO_MINIMO_MENSAL = 1320;
/**
* @param {number} valor
* @param {number} casaDecimais (para o valor `10.2345678`, usar 0 => 10, 1 => 10.2, 2 => 10.23, 3 => 10.235)
*/
function arredondar(valor, casasDecimais) {
const multiplicador = Math.pow(10, casasDecimais);
return Math.round(valor * multiplicador) / multiplicador;
}
@uqmessias
uqmessias / rgb-color-bitwise-conversion-kotlin.kt
Created February 20, 2023 23:46
It converts an RGB Int into a vector with R, G, and G color parts. It also does the same by inverting the R with G (this is needed for an internal project). And all of this in Kotlin
import java.awt.Color
/**
* Got from https://play.kotlinlang.org/#eyJ2ZXJzaW9uIjoiMS44LjEwIiwicGxhdGZvcm0iOiJqYXZhIiwiYXJncyI6IiIsIm5vbmVNYXJrZXJzIjp0cnVlLCJ0aGVtZSI6ImlkZWEiLCJjb2RlIjoiaW1wb3J0IGphdmEuYXd0LkNvbG9yXG4vKipcbiAqIFlvdSBjYW4gZWRpdCwgcnVuLCBhbmQgc2hhcmUgdGhpcyBjb2RlLlxuICogcGxheS5rb3RsaW5sYW5nLm9yZ1xuICovXG5mdW4gbWFpbigpIHtcbiAgICB2YWwgcmdiOiBJbnQgPSAweDFmOGI1NFxuICAgIFxuICAgIHZhbCByZ2JSZWRDb2xvcjogSW50ID0gKHJnYiBzaHIgMTYpIGFuZCAweEZGXG4gICAgdmFsIHJnYkdyZWVuQ29sb3I6IEludCA9IChyZ2Igc2hyIDgpIGFuZCAweEZGXG4gICAgdmFsIHJnYkJsdWVDb2xvcjogSW50ID0gcmdiIGFuZCAweEZGXG4gICAgXG4gICAgdmFsIGdiclJlZENvbG9yOiBJbnQgPSByZ2IgYW5kIDB4RkZcbiAgICB2YWwgZ2JyR3JlZW5Db2xvcjogSW50ID0gKHJnYiBzaHIgOCkgYW5kIDB4RkZcbiAgICB2YWwgZ2JyQmx1ZUNvbG9yOiBJbnQgPSAocmdiIHNociAxNikgYW5kIDB4RkZcbiAgICBcbiAgICB2YWwgZ2JyOiBJbnQgPSAocmdiUmVkQ29sb3IgYW5kIDB4RkYpIG9yICgocmdiR3JlZW5Db2xvciBhbmQgMHhGRikgc2hsIDgpIG9yICgocmdiQmx1ZUNvbG9yIGFuZCAweEZGKSBzaGwgMTYpXG4gICAgXG5cdHByaW50bG4oXCJSR0IgIyR7cmdiLnRvU3RyaW5nKDE2KX0sICRyZ2IgKFtyOiAkcmdiUmVkQ29sb

It sums a list of amounts within a markdown snippet

_**2079,30** (2022/01)_<br>  
_**2014,40** (2022/02)_<br>  
_**2161,51** (2022/03)_<br>  
_**226,29** (2022/04)_<br>  
_**2.283,29** (2022/05)_<br>  
_**223,92** (2022/06)_<br>  
_**222,48** (2022/07)_<br>  
@uqmessias
uqmessias / toCurrency.js
Created October 7, 2022 19:51
Format number to currency format
const toCurrency = num => num.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.");