This file contains 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
const fs = require('fs').promises; | |
async function listarArquivosDoDiretorio(diretorio, arquivos) { | |
if(!arquivos) | |
arquivos = []; | |
let listaDeArquivos = await fs.readdir(diretorio); | |
for(let k in listaDeArquivos) { | |
let stat = await fs.stat(diretorio + '/' + listaDeArquivos[k]); |
This file contains 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 | |
$data1 = "25/02/2013"; | |
$data2 = "22/02/2013"; | |
// transforma a data do formato BR para o formato americano, ANO-MES-DIA | |
$data1 = implode('-', array_reverse(explode('/', $data1))); | |
$data2 = implode('-', array_reverse(explode('/', $data2))); | |
// converte as datas para o formato timestamp |
This file contains 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 limpar_texto($str){ | |
return preg_replace("/[^0-9]/", "", $str); | |
} | |
// Exemplo de Utilização | |
echo limpar_texto('Olá 1456Mundo!'); | |
// vai retornar 1456 | |
?> |
This file contains 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 | |
$hostname = "localhost"; | |
$bancodedados = "bancodedados"; | |
$usuario = "usuario"; | |
$senha = "senha"; | |
$mysqli = new mysqli($hostname, $usuario, $senha, $bancodedados); | |
if ($mysqli->connect_errno) { | |
echo "Falha ao conectar: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; |
This file contains 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
let data_americana = "2020-12-30"; | |
let data_brasileira = data_americana.split('-').reverse().join('/'); | |
// Pronto! A data foi convertida. | |
console.log(data_brasileira); // retorna: 30/12/2020 |
This file contains 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 get_endereco($cep){ | |
// formatar o cep removendo caracteres nao numericos | |
$cep = preg_replace("/[^0-9]/", "", $cep); | |
$url = "http://viacep.com.br/ws/$cep/xml/"; | |
$xml = simplexml_load_file($url); |
This file contains 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 zb_change_return_shop_url() { | |
return home_url() . "/sua-pagina-personalizada"; | |
} | |
add_filter( 'woocommerce_return_to_shop_redirect', 'zb_change_return_shop_url' ); |
This file contains 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
const fs = require('fs'); | |
function listarArquivosEPastasDeUmDiretorio(diretorio, arquivos) { | |
if(!arquivos) | |
arquivos = []; | |
let listaDeArquivos = fs.readdirSync(diretorio); | |
for(let k in listaDeArquivos) { | |
let stat = fs.statSync(diretorio + '/' + listaDeArquivos[k]); |
This file contains 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
const fs = require('fs'); | |
const ini = require('ini'); | |
const animaisConfig = ini.parse(fs.readFileSync('./animais.ini', 'utf-8')); | |
const nomeAnimais = animaisConfig.animais.nomes; | |
console.log(nomeAnimais); |
This file contains 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
config.desenvolvimento.ip = '127.0.0.1'; | |
config.producao.porta = '3308'; | |
config.producao.novaChave = 'Esta é uma nova chave!' | |
fs.writeFileSync('./config_modified.ini', ini.stringify(config)) |