Skip to content

Instantly share code, notes, and snippets.

View andrefrd's full-sized avatar

André Dantas andrefrd

  • Grupo Vista
  • São Paulo -BR
View GitHub Profile
@andrefrd
andrefrd / validaCPF_CNPJ.php
Created April 19, 2017 13:16
Classe para validação de CPF / CNPJ
<?php
//////////////////////////////////////////////////////////
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Data no passado
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Sempre modificado
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- NCM COMPLETO 2017 SQL
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
@andrefrd
andrefrd / gist:ba9ba6c889b55f14f0c5
Created March 26, 2015 21:07
Get last 7 Days PHP
<?php
$today = date("Y-m-d");
for ($i=0; $i <= 7; $i++){
$strData = date('Y-m-d', strtotime( '-'. $i .' days', strtotime($today)));
echo $strData."<br>";
}
?>
@andrefrd
andrefrd / css fix for samsung
Last active August 29, 2015 14:05
Fix for samsung android browser using fixed header/footer
.fixedElements{
position: relative;
-webkit-box-flex: 1;
}
header ('Content-type: text/html; charset=UTF-8');
function generate_sef_urls ( $input, $replace = '-', $remove_words = true, $words_array = array() ){
$return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
return str_replace(' ',$replace,$return);
}
$palavra = "Remoção de Acentos e Criador de SEF";
$comAcentos = array('à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ü', 'ú', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'O', 'Ù', 'Ü', 'Ú');
$semAcentos = array('a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'y', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'o', 'U', 'U', 'U');
$palavra = str_replace($comAcentos, $semAcentos, $palavra);
@andrefrd
andrefrd / Time PHP str
Last active February 15, 2017 12:28
Time DD/MM/AAAA HH,MIN,SEC
$now = date("j, n, Y, G, i, s"); // Dia, Mês, Ano, Hora, Minuto, Segundo
/*
*Função PHP Google +1 Count
*Author: André Dantas
*email: andrefrd (at) gmail (dot) com
*/
function gPlusCount( $url ) {
$contents = file_get_contents( 'https://plusone.google.com/_/+1/fastbutton?url=' . $url );
preg_match( '/window\.__SSR = {c: ([\d]+)/', $contents, $matches );
if( isset( $matches[0] ) )