Skip to content

Instantly share code, notes, and snippets.

View miroswd's full-sized avatar
🕸️
shazam

Altamir Santos miroswd

🕸️
shazam
View GitHub Profile
@miroswd
miroswd / settings.json
Last active February 8, 2022 00:26
VSCode properties
{
// Material Icon
"workbench.iconTheme": "material-icon-theme",
"material-icon-theme.folders.associations": {
"infra":"app",
"entities":"class",
"schemas":"class",
"typeorm":"database",
"repositories":"mappings",
"http":"container",
@miroswd
miroswd / createSlug.js
Created September 8, 2021 19:38
Como remover os acentos de uma string || remove accents js || create a slug using js
// Remove accents and spaces from a string
'rEFerêncIA PAra EDIÇãO de SLUG'.toLowerCase().replaceAll(/ /g,'-').normalize("NFD").replace(/[\u0300-\u036f]/g, "")
@miroswd
miroswd / transformJsonToString.js
Created September 8, 2021 19:48
Transform json to string
/**
* @param {Object[]} arrJson
* @returns {String}
*/
let transformJsonToString = (arrJson) => {
let newObj = "[";
let counter = 0;
arrJson.forEach((element) => {
let str =
@miroswd
miroswd / generateCpfs.js
Created December 9, 2021 12:42
Gerador de CPF em massa
const NUMBER_OF_CPFS = 100
function randomiza(n) {
var ranNum = Math.round(Math.random() * n);
return ranNum;
}
function mod(dividendo, divisor) {
return Math.round(dividendo - Math.floor(dividendo / divisor) * divisor);
}
const aws = require('aws-sdk');
const mime = require('mime');
const path = require('path');
const fs = require('fs');
const multerConfig = require('../../config/multerConfig');
const { AWS_BUCKET_REGION, AWS_BUCKET } = process.env;
module.exports = class S3Storage {
@miroswd
miroswd / dateFormat.js
Created July 1, 2022 15:53
Format date natively with JS
const date = new Date("2022-01-31 00:00");
const actual = new Intl.DateTimeFormat("pt-br", {
dateStyle: "full",
timeStyle: "long",
}).format(date);
import pino from 'pino';
const environment = process.env.ENVIRONMENT || "dev";
const logger = pino({
transport: {
target: "pino-pretty"
},
base: {
pid: environment.toUpperCase()
@miroswd
miroswd / dividedArray.js
Last active January 12, 2023 09:38
Slice array items
const arr = [1,2,3,4];
const splitedArrItems = [];
const splitIdx = 2;
const indice = arr.length/splitIdx;
for (let i = 0; i < indice; i++) {
splitedArrItems.push(arr.splice(0, splitIdx));
}
@miroswd
miroswd / flagCreditCard.js
Last active January 19, 2023 19:28
get flag credit card using js | flag credit card regex | bandeira de cartão de crédito regex js
const flags = {
visa: /^4\d{12}(\d{3})?$/gm,
mastercard: /^(5[1-5]\d{4}|677189)\d{10}$/gm,
diners: /^3(0[0-5]|[68]\d)\d{11}$/gm,
discover: /^6(?:011|5[0-9]{2})[0-9]{12}$/gm,
elo:/^(?:401178|401179|431274|438935|451416|457393|457631|457632|504175|627780|636297|636368|655000|655001|651652|651653|651654|650485|650486|650487|650488|506699|5067[0-6][0-9]|50677[0-8]|509\d{3})\d{10}$/gm,
amex: /^3[47]\d{13}$/gm,
jcb:/^(?:2131|1800|35\d{3})\d{11}$/gm,
aura: /^(5078\d{2})(\d{2})(\d{11})$/gm,
hipercard:/^(606282\d{10}(\d{3})?)|(3841\d{15})$/gm,
@miroswd
miroswd / token.pm
Created January 26, 2023 14:33
Script to get token with test in postman
let response = pm.response.json();
let token = response.token
console.log('token ->', token)
pm.environment.set("token",token);