Skip to content

Instantly share code, notes, and snippets.

View atannus's full-sized avatar

André Tannús atannus

  • Epungo
  • São Paulo - Brasil
View GitHub Profile
@atannus
atannus / sprintf-mem-hungry-strings.php
Last active December 19, 2015 09:49
Which means generating a string as per make_word takes more memory than it should.
<?php
/**
*
* When using sprintf and mt_rand to generate a random hex-like string, the
* output seems to take more memory than it should.
*
* Changing the output to a string via a (string) cast or by any other mean,
* such as concatenating a string to it seems to fix the memory usage.
*
@atannus
atannus / kohana.php
Created July 6, 2013 19:38
Quick hack to allow Kohana to handle memory_limit and max_execution_time violations.
<?php defined('SYSPATH') or die('No direct script access.');
class Kohana extends Kohana_Core {
/**
* Augments the core method for two reasons:
* 1) Reserve an extra 1M memory to allow handling memory_limit violation.
* 2) Reserve more exec time to allow max_execution_time violation.
*
* Note: keep variable creation at a minimum.
// a.js
//goog.provide('myapp.A');
myapp.A = function() {}
myapp.A.prototype.move = function() {
console.log('moveA');
}
// b.js
//goog.provide('myapp.B');
//goog.require('myapp.A');
@atannus
atannus / README.md
Last active August 29, 2015 14:26
Remarketing AdWords

Remarketring AdWords

Exemplo de como implantar Remarketing para AdWords.

ATENÇÃO:

Não copie-e-cole este código, use-o apenas como referência. Obtenha seu código diretamente da sua conta no AdWords. Basta configurar uma campanha de Remarketing e o sistema gerará um código específico para você. Se insistir em copiar daqui, façao sob sua responsabilidade, e não esqueça de alterar o CONVERSION_ID nos dois lugares onde ele aparece.

Como implantar

Este exemplo é concebido exclusivamente para o mercado imobiliário.

<?php
$path = 'test.xml';
$reader = new XMLReader();
$reader->open($path);
while ( $reader->read() )
{
//$name = $reader->name;
> plot(1:10, 1:10)
Error in (function (display = "", width, height, pointsize, gamma, bg, :
X11 module cannot be loaded
In addition: Warning message:
In (function (display = "", width, height, pointsize, gamma, bg, :
unable to load shared object '/usr/lib/R/modules//R_X11.so':
/usr/lib/x86_64-linux-gnu/libpng12.so.0: version `PNG12_0' not found (required by /usr/lib/R/modules//R_X11.so)
> qplot(1:10, 1:10)
Error in (function (display = "", width, height, pointsize, gamma, bg, :
X11 module cannot be loaded
# npm run dev
> parabol-action@0.3.1 dev /home/atannus/com.parabolinc.action
> NODE_ENV=development node ./src/server/server.babel.js
[Busy] Launching SocketCluster
>> Broker PID: 22307
Creating a pool connected to localhost:28015
>> Worker PID: 22319
[Active] SocketCluster started
// Revela todas as máscaras.
function revealMasks(event) {
event.stopPropagation();
event.preventDefault();
if( typeof dataLayer !== 'undefined') {
dataLayer.push({'event': 'RevealMask'})
dataLayer.push({'ListingPageType': 'conversion'});
dataLayer.push({'event': 'PageTypeChange'})
}
$('.contactMask').fadeOut();
// Em todas as páginas.
if( typeof dataLayer !== 'undefined') {
dataLayer.push({'ListingId': '...'});
dataLayer.push({'ListingTotalValue': ...});
dataLayer.push({'ListingPageType': '...'});
dataLayer.push({'event': 'PageTypeChange'})
}
// Ao digitar 3 caracteres no 1o campo do formulário.
if( typeof dataLayer !== 'undefined') {
dataLayer.push({'ListingPageType': 'conversionintent'});
dataLayer.push({'event': 'PageTypeChange'})
}
// No sucesso do envio do formulário.
if( typeof dataLayer !== 'undefined') {
dataLayer.push({'ListingPageType': 'conversion'});
dataLayer.push({'event': 'PageTypeChange'})