Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Luís Dalmolin luisdalmolin

🏠
Working from home
View GitHub Profile
@luisdalmolin
luisdalmolin / adwords.js
Created May 5, 2014
Adwords Conversion
View adwords.js
function adwords_conversion(google_conversion_id, google_value, google_conversion_label) {
var img = new Image();
img.src = 'https://www.googleadservices.com/pagead/conversion/' + google_conversion_id + '/?value='+google_value+'&label='+google_conversion_label+'&script=0';
img.height = 1;
img.width = 2;
document.body.appendChild(img);
}
@luisdalmolin
luisdalmolin / Gruntfile.js
Created Nov 19, 2014
Exemplo de utilização do Grunt
View Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
options: {
mangle: false
},
app: {
files: {
'public/assets/javascripts/js/main.min.js': [ // arquivo minificado
@luisdalmolin
luisdalmolin / ufs.html
Created Jan 8, 2015
Select com estados brasileiros
View ufs.html
<select name="uf" id="uf" class="input input-uf" required>
<option value="">UF</option>
<option value="AC" {{ Input::old('city') == 'AC' ? 'selected="selected"' : null }}>AC</option>
<option value="AL" {{ Input::old('city') == 'AL' ? 'selected="selected"' : null }}>AL</option>
<option value="AP" {{ Input::old('city') == 'AP' ? 'selected="selected"' : null }}>AP</option>
<option value="AM" {{ Input::old('city') == 'AM' ? 'selected="selected"' : null }}>AM</option>
<option value="BA" {{ Input::old('city') == 'BA' ? 'selected="selected"' : null }}>BA</option>
<option value="CE" {{ Input::old('city') == 'CE' ? 'selected="selected"' : null }}>CE</option>
<option value="DF" {{ Input::old('city') == 'DF' ? 'selected="selected"' : null }}>DF</option>
<option value="ES" {{ Input::old('city') == 'ES' ? 'selected="selected"' : null }}>ES</option>
View gist:1106838
POST /servico/nododoarquivo.asmx HTTP/1.1
Host: sofis.servehttp.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://servidor/NomeDaFuncao"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Credenciais xmlns="http://sofis.com.br/">
@luisdalmolin
luisdalmolin / SoapHeader.php
Created Jul 26, 2011
Solução SOAP Header
View SoapHeader.php
<?php
$xml = '<Credenciais xmlns="http://sofis.com.br/"><codigo>'.self::CODIGO.'</codigo><senha>'.self::SENHA.'</senha></Credenciais>';
$soapAuthVar = new SoapVar($xml, XSD_ANYXML, null, null, null);
$soapAuthHeader = new SoapHeader(self::WSDL, 'Credenciais', $soapAuthVar);
$this->soap->__setSoapHeaders( array($soapAuthHeader) );
View gist:1446953
<?php
$Produto = EscapeWork::getClass('Produto');
@luisdalmolin
luisdalmolin / gravatar.php
Created Dec 15, 2011
Pegando imagem do Gravatar com PHP
View gravatar.php
<?php
function getAvatar() {
$email = 'seu@email.com.br'; // e-mail de cadastro para pegar as imagens
$default = '_img/sem-imagem-perfil.png'; // imagem alternativa para se não existir
$size = 25; // tamanho da imagem
$grav_url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) .
"?d=" . urlencode( $default ) . "&s=" . $size;
return $grav_url;
}
@luisdalmolin
luisdalmolin / gist:1657650
Created Jan 22, 2012
Chamando a função pra limitar
View gist:1657650
<?php
$texto = 'Lorem Ipsum is simply dummy text of the printin';
echo limitar($texto, 15);
// Escreve na tela "<strong>Lorem Ipsum i...</strong>"
@luisdalmolin
luisdalmolin / limitar.php
Created Jan 22, 2012
Limitando caracteres sem erros de caracteres
View limitar.php
<?php
function limitar($string, $tamanho, $encode = 'UTF-8') {
if( strlen($string) > $tamanho )
$string = mb_substr($string, 0, $tamanho - 3, $encode) . '...';
else
$string = mb_substr($string, 0, $tamanho, $encode);
return $string;
}
View gist:1672557
<?php
$cep = new Cep('SEU CEP');
echo $cep->uf;
echo $cep->cidade;
echo $cep->bairro;
echo $cep->logradouro;
You can’t perform that action at this time.