Skip to content

Instantly share code, notes, and snippets.

View phsantiago's full-sized avatar
:shipit:

Pedro H. Santiago phsantiago

:shipit:
View GitHub Profile
@phsantiago
phsantiago / es6_mask_cpf_cnpj.js
Created August 22, 2017 15:19
Máscara para CPF e CNPJ em javascript utilizando ES6
const mask = (v) => {
v=v.replace(/\D/g,"")
let len = v.length
if (len < 12) {
v=v.replace(/(\d{3})(\d)/,"$1.$2")
.replace(/(\d{3})(\d)/,"$1.$2")
.replace(/(\d{3})(\d{1,2})$/,"$1-$2")
} else {
v=v.replace(/^(\d{2})(\d)/,"$1.$2")
.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3")
CREATE EXTERNAL TABLE IF NOT EXISTS Accesslogs(
BucketOwner string,
Bucket string,
RequestDateTime string,
RemoteIP string,
Requester string,
RequestID string,
Operation string,
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
"Ser produtivo não está ligado a quantas horas você tem que trabalhar, e sim a quanto trabalha nas horas que tem."
Eu
<?php
$return = preg_replace( '/\b(\d{2})\D?(\d{3})\D?(\d{3})\D?(\d{4})\D?(\d{2})\b/' , '$1.$2.$3/$4-$5' , $cnpj );
echo $return;
function process_error_backtrace($errno, $errstr, $errfile, $errline, $errcontext) {
if(!(error_reporting() & $errno))
return;
switch($errno) {
case E_WARNING :
case E_USER_WARNING :
case E_STRICT :
case E_NOTICE :
case E_USER_NOTICE :
$type = 'warning';
private function validaCPF($cpf = null) {
// Verifica se um número foi informado
if(empty($cpf)) {
return false;
}
// Elimina possivel mascara
$cpf = preg_replace('/[^0-9]/', '', $cpf);
$cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT);
UPDATE or_postmeta
SET meta_value = REPLACE(meta_value, 'https://www.youtube.com/watch?v=', '') where meta_key like 'yt_video%'
mysqldump -hclubinho.com.br -uclubinho -p clubinhodadidi_com_br > clubinhodadidi_com_br_2408.sql
There is a beauty in simplicity.
“If you can't explain it to a six year old, you don't understand it yourself.”
― Albert Einstein
“Like all magnificent things, it's very simple.”
― Natalie Babbitt
“Life is really simple, but we insist on making it complicated.”
― Confucius