Skip to content

Instantly share code, notes, and snippets.

👨‍💻
lol

Wesley Amaral Lopes wesdeveloper

👨‍💻
lol
Block or report user

Report or block wesdeveloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Validate if a CNPJ is valid
/**
* Validate if a CNPJ is valid.
* @param {*} data - CNPJ
* @param {*} cnpjBlackList - Array with blacklist of wrongs CNPJs
* @returns {Boolean} return a boolean
*
* @example
* isCnpjValid('98.080.425/0011-00'); //false
*/
export const isCnpjValid = (
@wesdeveloper
wesdeveloper / Validate if a CPF is valid
Last active Aug 22, 2019
Validate if a CPF is valid
View Validate if a CPF is valid
/**
* Validate if a CPF is valid.
* @param {String} data - CPF
* @param {Array} cpfBlackList - Array with balcklist of wrongs CPFs
* @returns {Boolean} return an boolean.
*
* @example
* isCpfValid('07102325364'); // false
*/
export const isCpfValid = (
@wesdeveloper
wesdeveloper / https_express_server.js
Created May 15, 2019
Https server with express.
View https_express_server.js
const fs = require("fs");
const https = require("https");
const express = require("express");
// Instância express
const app = express();
app.get("/", (req, res) => {
res.send("Hello world using HTTPS!");
});
View https_node_server.js
const fs = require("fs");
const https = require("https");
// Carrega o certificado e a key necessários para a configuração.
const options = {
key: fs.readFileSync("server.key"),
cert: fs.readFileSync("server.cert")
};
// Cria a instância do server e escuta na porta 3000
@wesdeveloper
wesdeveloper / generate_ssl_certificate
Created May 15, 2019
Generate an ssl certificate.
View generate_ssl_certificate
openssl req -nodes -new -x509 -keyout certificado.key -out certificado.cert
View Validations - Boilerplate
const Joi = require('joi');
const validateParam = (schema, name) => (req, res, next) => {
const result = Joi.validate({ param: req.params[name] }, schema);
if (result.error) {
return res.status(400).json(result.error);
}
if (!req.payload) {
req.payload = {};
}
View Nginx Setup
// Nginx.config
worker_processes 4;
events { worker_connections 1024; }
http {
upstream web {
least_conn;
View setup-fedora29.sh
# echo '#!/bin/sh'
# Author : Wesley Lopes
# This script will install
# curl, git, terminator, vim, fonts-firacode, node 11
# docker, docker-compose, zsh, pop os theme
# slack, spotify, snapd
sudo dnf update &&
sudo dnf install -y curl vim git terminator zsh &&
View ubuntu-setup.sh
#!/bin/bash
# Author : Wesley Lopes
# This script will install
# curl, git, terminator, vim, fonts-firacode, node 11
# docker, docker-compose, XAMPP
# zsh, pop os theme, gnome-tweaks, compass
# slack, spotify
sudo apt update &&
View variables-lifecycle.js
// Declaração
var value;
// Inicialização
value = 5;
// Utilização
console.log(value); // 5
You can’t perform that action at this time.