Skip to content

Instantly share code, notes, and snippets.

@bytefade
bytefade / gmapsRapido.php
Created October 23, 2014 12:29
Forma rápida e mediocre de pegar latitude longitude
<?php
$address = 'avenida+gustavo+paiva,maceio,alagoas,brasil';
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false');
$output= json_decode($geocode);
@bytefade
bytefade / SQL_alternative_Distinct.sql
Last active August 29, 2015 14:08
Alternative distinc SQL
SELECT MIN(ID) as id, label as label_alt
FROM table
GROUP BY label
ORDER BY MIN(ID)
@bytefade
bytefade / sqlin.sql
Created November 6, 2014 19:26
SQL IN
SELECT * FROM table where id IN('74', '75', '76', '77', '78', '79', '80', '81')
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="valor">Qual o valor senhor?</label>
<input id="valor" type="text" name="valor">
@bytefade
bytefade / erroAddDomainSuperdominios
Created December 19, 2014 16:02
alterar dns, erro
Fatal error: Uncaught exception 'Exception' with message 'Falha ao alterar servidores DNS código 2308: mensagem 'Violação na política de gerência
Fatal error: Uncaught exception 'Exception' with message 'Falha ao alterar servidores DNS código 2308: mensagem 'Violação na política de gerência de dados' motivo 'Domínio desconhecido'' in /home/super/public_html/home/modules/registrars/registrobr/RegistroEPP/RegistroEPPDomain.class.php:108 Stack trace: #0 /home/super/public_html/home/modules/registrars/registrobr/registrobr.php(324): RegistroEPPDomain->updateNameServers(Array, Array) #1 /home/super/public_html/home/includes/classes/WHMCS/Module.php(0): registrobr_SaveNameservers(Array) #2 /home/super/public_html/home/includes/classes/WHMCS/Module/Registrar.php(0): WHMCS_Module->call() #3 /home/super/public_html/home/includes/classes/WHMCS/Domains.php(0): WHMCS_Module_Registrar->call() #4 /home/super/public_html/home/clientarea.php(0): WHMCS_Domains->moduleCall() #5 {main} Next exception 'Exception' with message
@bytefade
bytefade / ExemploBuscaCep.js
Created December 22, 2014 18:56
Busca Cep Via Correios Mobile
function buscarCep (cep) {
cep = cep.replace(/\D/g, "");
var end = '';
var path = path_site();
// console.log("p" + path);
// -- a busca
$.getJSON( path + '/cep.php?cep='+cep,
function (dados){
@bytefade
bytefade / ano.php
Created December 29, 2014 16:23
ano
// --Retorna ano para select
function ano_select(){
//The 60 value here is the amount of years to go back
$year = date("Y") - 100;
//The 60 value here is the amount of years to go forward
//because i went back 50 years, i'm going forward 50 years so the dropdown will always have the current year.
for ($i = 0; $i <= 82; ++$i)
{
$year2[] = $year;
@bytefade
bytefade / messageSuccessSession.php
Created January 31, 2015 14:21
Mensagem de sucesso com session
<?php
session_start();
//The second parameter on print_r returns the result to a variable rather than displaying it
$RequestSignature = md5($_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'].print_r($_POST, true));
if ($_SESSION['LastRequest'] == $RequestSignature)
{
echo 'This is a refresh.';
}
else
<?php # -*- coding: utf-8 -*-
// function remove_accents()
/**
* Unaccent the input string string. An example string like `ÀØėÿᾜὨζὅБю`
* will be translated to `AOeyIOzoBY`. More complete than :
* strtr( (string)$str,
* "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
* "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn" );
*
@bytefade
bytefade / composeUso.md
Last active August 29, 2015 14:16
Composer uso básico do básico
1 - Instalando via cURL:
curl -sS https://getcomposer.org/installer | php

Instalando via PHP:
php -r “readfile(‘https://getcomposer.org/installer’);” | php

*dentro do diretorio do projeto

2 - Ter o composer.json