Skip to content

Instantly share code, notes, and snippets.

View RodrigoPauletti's full-sized avatar
💻
Coding

Rodrigo Pauletti RodrigoPauletti

💻
Coding
View GitHub Profile
@RodrigoPauletti
RodrigoPauletti / react-var_dump.js
Created October 18, 2023 17:34 — forked from 8ctopotamus/react-var_dump.js
Display data in React, kinda like PHP's var_dump();
const dataDump = props => <pre>{JSON.stringify(props, null, 2)}</pre>
@RodrigoPauletti
RodrigoPauletti / CountryCodes.json
Created March 31, 2021 00:01 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@RodrigoPauletti
RodrigoPauletti / combo_dinamico.html
Created October 21, 2020 14:16 — forked from ografael/combo_dinamico.html
Carregar combo com JQuery - Cidades e Estados
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.getJSON('estados_cidades.json', function (data) {
<?php
function validar_cnpj($cnpj)
{
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj);
// Valida tamanho
if (strlen($cnpj) != 14)
return false;
@RodrigoPauletti
RodrigoPauletti / srp-solid-functions-example.php
Created June 2, 2020 16:44 — forked from joaorobertopb/srp-solid-functions-example.php
Princípio da responsabilidade única do SOLID sendo aplicando na refatoração de uma função.
<?php
//Ruim:
function emailClients(array $clients): void
{
foreach ($clients as $client) {
$clientRecord = $db->find($client);
if ($clientRecord->isActive()) {
email($client);
}
@font-path: '../fonts'; // Font's path
@font-face {
font-family: 'FONT_NAME';
src: url('@{font-path}/MY_FONT_FILENAME.eot');
src: url('@{font-path}/MY_FONT_FILENAME.eot?#iefix') format('embedded-opentype'),
url('@{font-path}/MY_FONT_FILENAME.woff2') format('woff2'),
url('@{font-path}/MY_FONT_FILENAME.woff') format('woff'),
url('@{font-path}/MY_FONT_FILENAME.ttf') format('truetype'),
url('@{font-path}/MY_FONT_FILENAME.svg#ID') format('svg'); // In this case, the ID is the value of property 'id' on 'font' tag. E.g. <font id="MY_FONT_ID">
@RodrigoPauletti
RodrigoPauletti / validar_cpf.php
Created May 7, 2020 03:17 — forked from rafael-neri/validar_cpf.php
Validar CPF em PHP (Completo)
<?php
function validaCPF($cpf) {
// Extrai somente os números
$cpf = preg_replace( '/[^0-9]/is', '', $cpf );
// Verifica se foi informado todos os digitos corretamente
if (strlen($cpf) != 11) {
return false;
@RodrigoPauletti
RodrigoPauletti / formatar_cnpj_cpf.md
Created May 7, 2020 03:16 — forked from davidalves1/formatar_cnpj_cpf.md
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === 11) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
  
@RodrigoPauletti
RodrigoPauletti / ajax-form.js
Created May 3, 2018 12:10 — forked from havvg/ajax-form.js
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),