Skip to content

Instantly share code, notes, and snippets.

View FeMaffezzolli's full-sized avatar

Felipe Maffezzolli FeMaffezzolli

View GitHub Profile
@FeMaffezzolli
FeMaffezzolli / formatCurrencyValue.ts
Created July 16, 2020 20:20
Format currency value
const formatValue = (value: number): string =>
Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(value);
@FeMaffezzolli
FeMaffezzolli / stringFromSeconds.ts
Created July 3, 2020 22:40
stringFromSeconds.ts
/**
* @example
*
* Get "00:20" from 20 or "01:16" from 76
*
*/
function stringFromSeconds(seconds: number): string {
const date = new Date(0)
date.setSeconds(seconds)
const [sliceFrom, offset] = seconds >= 3600
@FeMaffezzolli
FeMaffezzolli / searchDepthValue.js
Last active June 16, 2020 10:16
Search value in object by concatened string of keys of nested objects.
/**
* Search value in object by concatened string of keys of nested objects.
*
* @example
*
* Find street name from object:
*
* const obj = {
* address: {
* district: {
@FeMaffezzolli
FeMaffezzolli / objectFromFlatten.js
Last active June 16, 2020 09:43
Create an object from a flattenObject.
/**
* Creates an object from a flattenObject.
*
* @example
*
* Create following object:
*
* {
* address: {
* city: {
@FeMaffezzolli
FeMaffezzolli / flattenObject.js
Last active June 16, 2020 09:45
Create a flatten object from an any level nested object.
/**
* Creates a flatten object from an any level nested object.
*
* @example
*
* Create following object:
*
* {
* 'address.city.name': 'São Paulo',
* 'address.state.name': 'SP',
@FeMaffezzolli
FeMaffezzolli / valida.cpf.js
Last active September 21, 2020 03:38
valida.cpf.js
const isValidCpf = (cpfValue) => {
if (!cpfValue) return false
const formatToString = val => {
if (Array.isArray(val)) return val.join('')
if (typeof val === 'string') return val
return null
}
const cpfString = formatToString(cpfValue)
@FeMaffezzolli
FeMaffezzolli / valida.cnpj.js
Last active September 12, 2020 14:32 — forked from alexbruno/valid.cnpj.ts
Validação de CNPJ
export function cnpjValidation(value) {
if (!value) return false
// Aceita receber o valor como string, número ou array com todos os dígitos
const validTypes =
typeof value === 'string' || Number.isInteger(value) || Array.isArray(value)
// Elimina valor não em formato inválido
if (!validTypes) return false
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export ANDROID_HOME=~/Android/Sdk
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
# Path to your oh-my-zsh installation.
export ZSH="/Users/diegofernandes/.oh-my-zsh"
export PATH="$PATH:/usr/local/bin"
const { resolve } = require('path');
module.exports = {
env: {
browser: true,
es6: true,
jest: true,
},
globals: {
Atomics: 'readonly',
@FeMaffezzolli
FeMaffezzolli / README.md
Created March 6, 2020 00:09 — forked from diego3g/README.md
Criação de servidor Node.js

Configuração do servidor

  1. Configurar chave SSH
  2. Criar Droplet
  3. Realizar update e upgrade
  4. Crua usuário adduser deploy e usermod -aG sudo deploy
  5. Cria pasta .ssh pro deploy
  6. cp ~/.ssh/authorized_keys /home/deploy/.ssh/authorized_keys
  7. chown -R deploy:deploy .ssh/
  8. chmod 700 .ssh