Skip to content

Instantly share code, notes, and snippets.

View franciscopessoa's full-sized avatar
🎯
Focusing

Francisco Pessoa franciscopessoa

🎯
Focusing
View GitHub Profile
<?php
$url = "https://fcm.googleapis.com/fcm/send";
$token = "your device token";
$serverKey = 'your server token of FCM project';
$title = "Notification title";
$body = "Hello I am from Your php server";
$notification = array('title' =>$title , 'text' => $body, 'sound' => 'default', 'badge' => '1');
$arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high');
$json = json_encode($arrayToSend);
$headers = array();
#!/usr/bin/php
<?php
$stdin = fopen('php://stdin', 'r');
echo "Entre com o número de apostas desejadas: " . "\n";
$nrApostas = trim(fgets($stdin));
if (!is_numeric($nrApostas)) {
echo "Número inválido"."\n";
} else {
@franciscopessoa
franciscopessoa / gist:9e72587e339cc7d35497ca9a7c3d7ff1
Created January 16, 2020 13:41
select points inside polygon mysql
select
*
from
revan_vendas.teste_localizacao
where
st_within(point(lg,
lt),
ST_GeomFromText('Polygon(
(-38.498775 -6.197860,
-38.498612 -6.197349,
@franciscopessoa
franciscopessoa / CPF_CNPJ.php
Created January 23, 2020 13:29
Validador CPF e CNPJ php
<?php
function __validaCPF($cpf)
{
# Retira da string tudo que não estiver entre 0 e 9
$cpf = preg_replace('/[^0-9]/', '', (string) $cpf);
# Verifica tamano da string e se todos os digitos são iguais
if (strlen($cpf) !== 11 or preg_match('/(\d)\1{10}/', $cpf)) {
return false;
@franciscopessoa
franciscopessoa / mesComercial.php
Created January 31, 2020 18:59
Calcular mês comercial, 26 a 25
<?php
function dataCompetencia($data)
{
$dia = (int) substr($data, 8, 2);
$AnoMes = substr($data, 0, 7);
if ($dia >= 26) {
$date['inicial'] = $AnoMes . '-26';
$date['final'] = date('Y-m', strtotime('+ 1 Month', strtotime($AnoMes))) . '-25';
} else {
@franciscopessoa
franciscopessoa / Geometry MySQL
Last active February 28, 2020 17:38
Search point in Polygn MySQL
CREATE TABLE `municipal_border` (
`boundary` polygon NOT NULL,
`municipalID` int(10) NOT NULL)
SET @g = 'POLYGON((22.367582117085913 70.71181669186944, 22.225161442616514 70.65582486840117, 22.20736264867434 70.83229276390898, 22.18701840565626 70.9867880031668, 22.22452581029355 71.0918447658621, 22.382709129816103 70.98884793969023, 22.40112042636022 70.94078275414336, 22.411912121843205 70.7849142238699, 22.367582117085913 70.71181669186944))';
INSERT INTO municipal_border (boundary,municipalID) VALUES (ST_GeomFromText(@g),2)
set @p = GeomFromText('POINT(22.4053386588057 70.86240663480157)');
select * FROM municipal_border where ST_Contains(boundary, @p);
@franciscopessoa
franciscopessoa / brlToWords.php
Last active April 27, 2020 15:43
convert BRL to words (array) php
<?php
function calcula($valor)
{
$retorno = [];
$divisao = explode('.', $valor);
$reais = isset($divisao[0]) ? $divisao[0] : null;
$centavos = isset($divisao[1]) ? $divisao[1] : null;
if (strlen($reais) <= 6 and !is_null($reais)) {
$retorno = array_merge($retorno, calculaReais($reais));
@franciscopessoa
franciscopessoa / bcrypt.php
Created September 22, 2020 20:22
bcrypt.php
$hash = password_hash("teste", PASSWORD_DEFAULT);
$hash = '$2y$10$5JRstzQuO6kd8xeb4fcsyutF7mWwbWw1kX3SpmwcClLfRGp6Y.V2G';
if (password_verify('teste', $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}