Skip to content

Instantly share code, notes, and snippets.

View gustavopaes's full-sized avatar

Gustavo Paes gustavopaes

View GitHub Profile
@gustavopaes
gustavopaes / gist:341352
Created March 23, 2010 16:24
Create a temporary cron, to tests
#!/bin/sh
while [ 1 ];
do
/usr/local/bin/php /your/path/to/cron.php >> log-exec.log
sleep 1800
done
@gustavopaes
gustavopaes / gist:341353
Created March 23, 2010 16:26
Find a string on various files with a specific extension
find ./ -name "*.php" -print0 | xargs -0 grep "my query string" >> found.txt
@gustavopaes
gustavopaes / gist:984668
Created May 21, 2011 16:40
A better javascript setInterval
(function(time) {
function again() {
var procede = yourActionFunction();
if(procede)
setTimeout(again, time);
}
again(time);
})(5000);
@gustavopaes
gustavopaes / gist:1125155
Created August 4, 2011 13:34
Adicionar códigos novos em uma função já declarada
oldFunction = (function(temp) {
return function() {
if(typeof temp != 'undefined')
temp();
// your new code here
...
}
})(oldFunction);
@gustavopaes
gustavopaes / placeholder-polyfill.js
Created November 24, 2015 18:22
simple placeholder polyfill
;(function() {
var testInput = document.createElement('input');
if('placeholder' in testInput || 'placeHolder' in testInput) {
return false;
}
var inputs = document.querySelectorAll('input');
for(var i = 0, m = inputs.length; i < m; i++) {
var input = inputs[i];
var inputPlaceholder = input.getAttribute('placeholder');
@gustavopaes
gustavopaes / storageValidation.js
Last active December 19, 2015 22:08
Verifica se o navegador possui suporte ativo / liberado para o uso da API localStorage.
/**
* Valida se o usuário está habilitado para usar a API localStorage.
* https://gist.github.com/gustavopaes/6024904
* @type {Boolean}
*/
var storageValidation = (function(window) {
'use strict';
var validation;
try {
// IE <= 9 e demais navegadores devem retornar TRUE
@gustavopaes
gustavopaes / file.helper.php
Created August 18, 2013 15:36
Classe com métodos encadeados para criar ou ler arquivos.
<?php
/**
* Created on 06/Jan/2010
*
* Classe com métodos encadeados para criar
* ou ler arquivos.
*
* @author Gustavo Paes (http://gustavopaes.net/)
* @version 1.0124.01
**/
@gustavopaes
gustavopaes / phantomjs-printscreen.js
Created September 2, 2013 16:30
Cria um arquivo PNG com a página renderizada. Modo de uso: phantomjs http://www.uol.com.br/
var page = require('webpage').create(),
system = require('system');
page.viewportSize = { width: 1024, height: 768 };
if(system.args.length < 2) {
console.log("Informe a URL para realizar o prinscreen.");
console.log("phantomjs http://www.uol.com.br/");
phantom.exit(1);
}
@gustavopaes
gustavopaes / maker.js
Last active December 22, 2015 06:19
Simples Lib de template para substituir apenas variáveis.Útil para montar URL de Webservices com parâmetros variáveis.
/**
* Simples Lib de template para substituir apenas variáveis. Útil para montar URL
* de Webservices com parâmetros variáveis.
*
* @param {String} template
* @param {Json} obj Objetos que serão adicionados no template
* @returns {String}
*/
function maker(template, obj) {
var attr;
@gustavopaes
gustavopaes / underplate.js
Created September 9, 2013 17:20
underplate it's just the template engine used by underscore Lib. I just removed all underscore code to can use the good template engine. All code here was writed by underscore team, it's not my own. Based at Underscore.js 1.5.2.
/**
* underplate it's just the template lib used by underscore lib. I just
* removed all underscore code to can use just the good template engine.
*
* All code here was writed by underscore team.
*
* Based at Underscore.js 1.5.2
*
* @licence The MIT License (MIT)
*/