Skip to content

Instantly share code, notes, and snippets.

View pedropuppim's full-sized avatar
🎯
Focusing

Pedro Puppim pedropuppim

🎯
Focusing
View GitHub Profile
@pedropuppim
pedropuppim / encoding.php
Created January 14, 2022 19:25
encoding.php
<?php
function detect_encoding($string)
{
//http://w3.org/International/questions/qa-forms-utf-8.html
if (preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] | [\xC2-\xDF][\x80-\xBF] | \xE0[\xA0-\xBF][\x80-\xBF] | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} | \xED[\x80-\x9F][\x80-\xBF] | \xF0[\x90-\xBF][\x80-\xBF]{2} | [\xF1-\xF3][\x80-\xBF]{3} | \xF4[\x80-\x8F][\x80-\xBF]{2} )*$%xs', $string))
return 'UTF-8';
//If you need to distinguish between UTF-8 and ISO-8859-1 encoding, list UTF-8 first in your encoding_list.
//if you list ISO-8859-1 first, mb_detect_encoding() will always return ISO-8859-1.
@pedropuppim
pedropuppim / nosso_numero_sicoob.php
Created October 13, 2021 12:26
Como calcular nosso numero com digito verificador do banco Sicoob em PHP
<?php
$agencia = str_pad("3010", 4, '0', STR_PAD_LEFT);
$convenio = str_pad("1312345", 10, '0', STR_PAD_LEFT);
$nossoNumero = str_pad("0001", 7, '0', STR_PAD_LEFT);
$numeroCalculoDigito = $agencia . $convenio . $nossoNumero;
$peso = "319731973197319731973";
$valorSoma = 0;
@pedropuppim
pedropuppim / puppeteer-ubuntu-1804.md
Last active December 2, 2021 14:00 — forked from winuxue/puppeteer-ubuntu-1804.md
Solution for common dependences issues using puppeteer in ubuntu 18.04 (Bionic)

puppeteer dependeces in ubuntu 18.04 (Bionic)

error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

sudo apt-get install libnss3

error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory

sudo apt-get install libxss1
@pedropuppim
pedropuppim / install_docker.sh
Last active March 13, 2021 13:33
install docker and docker-compose on Ubuntu 20
#!/bin/bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install docker-ce -y
sudo usermod -aG docker ${USER}
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
@pedropuppim
pedropuppim / knex.js
Created February 25, 2020 01:24
knex.js dicas
//Conexão
var knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'your_database_user',
password: 'your_database_password',
database: 'myapp_test'
},
@pedropuppim
pedropuppim / React Native
Last active April 12, 2023 09:18
React Native
Tutorial to start project in react native:
https://vizir.com.br/2018/06/react-native-evoluindo-o-codigo/
KeyboardAvoidingView:
https://medium.com/@nickyang0501/keyboardavoidingview-not-working-properly-c413c0a200d4
Components:
https://shoutem.github.io/
Tutorial for redux:
@pedropuppim
pedropuppim / renomear_arquivos.php
Last active July 31, 2019 01:53
renomeia recursivamente arquivos removendo caracteres especiais
<?php
function tratarNome($string){
$string = iconv( "UTF-8" , "ASCII//TRANSLIT//IGNORE" , $string );
$string = preg_replace( array( '/[ ]/' , '/[^A-Za-z0-9.\-]/' ) , array( '' , '' ) , $string );
return $string;
}
@pedropuppim
pedropuppim / teste_athenas.md
Last active July 31, 2023 12:34
Teste Athenas Online


O desafio é criar um crud simples em PHP e que salve os dados no banco de dados (Firebird, MySQL, Mongo, PostgreSQL etc) através de uma API REST.

Tabela Pessoas

Codigo

Pegar Ip do conteiner:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nomeContainer

Criar Rede:
docker network create nomeDaRede

Build imagem:
docker build -t nomeDaImagem .

Rodar container:

@pedropuppim
pedropuppim / Dockerfile.sh
Last active January 31, 2020 01:32
Dockerfile.sh
FROM ubuntu:bionic
LABEL maintainer="ppuppim@gmail.com"
LABEL description="Apache 2.4 / PHP 7.2"
RUN apt-get update
RUN export DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y tzdata