This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grafo = { | |
'a': {'b': 0, 'd': 1, 'e': 2}, | |
'b': {'a': 0, 'c': 4, 'e': 5}, | |
'c': {'b': 4, 'e': 7}, | |
'd': {'a': 1, 'e': 9}, | |
'e': {'a': 2, 'b': 5, 'c': 7, 'd': 9, 'f': 14}, | |
'f': {'e': 14} | |
} | |
def quicksort(vetor,inicio,fim): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Para limpar teu docker todo: | |
docker system prune -a --volumes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grafo = { | |
'a': ['b', 'd', 'e'], | |
'b': ['a', 'c', 'e'], | |
'c': ['b', 'e'], | |
'd': ['a', 'e'], | |
'e': ['a', 'b', 'c', 'd', 'f'], | |
'f': ['e'] | |
} | |
def busca_em_largura(grafo, vertice_do_grafo): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cria_grafo(lista_de_vertices, lista_de_arestas): | |
grafo = {} | |
for vertice in lista_de_vertices: | |
grafo[vertice] = [] | |
for aresta in lista_de_arestas: | |
grafo[aresta[0]].append(aresta[1]) | |
return grafo | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recursive_copy($source, $destination) | |
{ | |
if (is_dir($source) === true) { | |
$success = true; | |
if (!file_exists($destination)) { | |
mkdir($destination, 0777, true); | |
} | |
$files = array_diff(scandir($source), ['.', '..']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grafo = { | |
'a': ['b', 'd', 'e'], | |
'b': ['a', 'c', 'e'], | |
'c': ['b', 'e'], | |
'd': ['a', 'e'], | |
'e': ['a', 'b', 'c', 'd', 'f'], | |
'f': ['e'] | |
} | |
# coisos globais |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(filename, text) { | |
let element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Transforma array em XML. Este método trata os casos de repetição para chaves com | |
* valores de arrays sequenciais onde o objetivo é criar múltiplas tags com estas chaves. | |
* | |
* @param array $data | |
* @param SimpleXMLElement $xml_data | |
*/ | |
function array_to_xml(array $data, SimpleXMLElement $xml_data) | |
{ | |
foreach ($data as $key => $value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validar_cnpj($cnpj) | |
{ | |
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj); | |
// Valida tamanho | |
if (strlen($cnpj) != 14) | |
return false; |
NewerOlder