Skip to content

Instantly share code, notes, and snippets.

View alexandremaeda's full-sized avatar
🏠
Working from home

Alexandre Maeda alexandremaeda

🏠
Working from home
View GitHub Profile
@alexbruno
alexbruno / valid.cnpj.ts
Last active April 23, 2024 13:02
Validação de CNPJ
// Regex para validação de string no formato CNPJ
export const regexCNPJ = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/
// Método de validação
// Referência: https://pt.wikipedia.org/wiki/Cadastro_Nacional_da_Pessoa_Jur%C3%ADdica
export function validCNPJ(value: string | number | number[] = '') {
if (!value) return false
// Aceita receber o valor como string, número ou array com todos os dígitos
const isString = typeof value === 'string'
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@letanure
letanure / estados-cidades.json
Last active May 13, 2024 13:51
JSON estados cidades do brasil, dividido por estados. segunda lista atualizada em 2020, dados do IBGE
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@andersonaguiar
andersonaguiar / how-to-install-sass-on-windows
Created April 16, 2012 18:03
How to install SASS on Windows 7
How to install SASS on Windows 7
1 - Download the ruby http://rubyinstaller.org/downloads/
2 - Click install and select the option to create environment variables
(
If you forgot to schedule go to:
My Computer> Properties> Advanced Options> Environment Variables
Look for path and put in the path of the ruby bin installed, eg: C:\Ruby193\bin;
)
3 - Open cmd and download the gem of the SASS, typing: gem install sass
@MatthewEppelsheimer
MatthewEppelsheimer / country-shortcode.php
Last active February 27, 2023 11:44
WP Contact Form 7 shortcode with list of Countries
<?php
/*
Localizations:
- [Spanish](https://gist.github.com/MatthewEppelsheimer/1498955#gistcomment-3317461) props @chdgp
UPDATED: 2020-03-09