Skip to content

Instantly share code, notes, and snippets.

View bjverde's full-sized avatar

Bjverde bjverde

  • Brasília, DF, Brasil
View GitHub Profile
@davidalves1
davidalves1 / formatar_cnpj_cpf.md
Last active October 13, 2025 16:10
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $CPF_LENGTH = 11;
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === $CPF_LENGTH) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
@JustAnotherMark
JustAnotherMark / youtube-custom-speed.js
Created May 23, 2016 08:50
Custom Youtube video speed
vid = document.getElementsByClassName("video-stream html5-main-video")[0];
vid.playbackRate = 3.5;