Skip to content

Instantly share code, notes, and snippets.

View gabrielgilini's full-sized avatar
🍻

Gabriel Gilini gabrielgilini

🍻
View GitHub Profile
<?php
class Zip extends Object
{
private $_file;
private $_errors = false;
private $_dirName;
private $_extracted = array();
public function __construct($path)
{
App::import('Lib', 'Zip');
$zipFile = new Zip($caminho_absoluto_do_arquivo);
if(!$zipFile->hasErrors())
{
$zipFile->extract(); // Se não passar parâmetro, extrai pro mesmo diretório
}
@gabrielgilini
gabrielgilini / debug.php
Created May 18, 2011 18:05
PHP debug to file
<?php
function debug()
{
$args = func_get_args();
ob_start();
$dbt = reset(debug_backtrace(false));
echo date('[d/m/Y H:i:s] ');
echo end(explode('/', $dbt['file'])) . ':' . $dbt['line'] . "\n";
foreach($args as &$arg)
{
@gabrielgilini
gabrielgilini / kamael.js
Created August 2, 2011 21:04
Remove os posts do Kamael do tópico atual
// Copie o código abaixo e cole na barra de endereços com "javascript:" antes.
// Ex: javascript:(function(){var c=document.getElementsByClassName("bigusername");for(var[...]
// Ou adicione em seus bookmarks e cliquem quando quiserem remover.
(function(){var c=document.getElementsByClassName("bigusername");for(var a=c.length;--a>=0;){if(c[a].href.indexOf("member.php?u=7569")!=-1){var b=c[a].parentNode;while(b&&b.className!="page"){b=b.parentNode}if(b){b.parentNode.parentNode.removeChild(b.parentNode)}}}})();
Appetizer sources:
http://leotrivial.blogspot.com/2011/02/almoco-nordestino-entre-amigos.html (sweet chilli sauuuuuuuuuuce)
http://www.buzzle.com/articles/appetizers-and-finger-foods.html
@gabrielgilini
gabrielgilini / xhr.js
Created September 22, 2011 13:53
Simple XMLHttpRequest example
(function()
{
var global = this;
var createXmlHttpRequest = (function()
{
var i,
fs = [// for legacy eg. IE 5
function()
{
@gabrielgilini
gabrielgilini / PartialReader.php
Created December 13, 2011 21:07
A class to partially read Excel worksheets with PHPExcel
<?php
/**************************
* Author: Gabriel Gilini *
**************************/
/*****************************************************
// Usage example:
$columns = array('A', 'C', 'J', 'K', 'M', 'N', 'O');
@gabrielgilini
gabrielgilini / procedure-result-set.sql
Created January 3, 2012 18:14
Example of non-working code
DELIMITER //
CREATE PROCEDURE p1()
BEGIN
DECLARE ids INT;
SELECT id FROM t4 WHERE t5_id = 8 INTO @ids;
SELECT
t3.*
FROM
attachDrag = (function() {
var i, c, m;
var elDrag, elDragHandle, docNode, win, mode, ondrag, ondraginit, ondragterminate, ondragstart, ondragover, ondragout, ondrop, ghost, speed, accelerate, revert, axes, constrain, constraint, keyboardOnly, callbackContext;
var targets, targetPositions, targetDimensions, targetsOver, targetObstacles, obstaclesFatal, collision;
var mouse, dim, pos, dimO, posO, scrollPos, oldStyle = {};
var initialized;
var oldMouseDown, oldKeyDown, oldKeyUp;
var oldSpeed;
Delivered-To: lucas.gameiro+fb1@ppivot.com.br
Received: by 10.182.171.102 with SMTP id at6cs101300obc;
Thu, 9 Feb 2012 08:28:56 -0800 (PST)
Received: by 10.236.184.131 with SMTP id s3mr3453039yhm.32.1328804935928;
Thu, 09 Feb 2012 08:28:55 -0800 (PST)
Return-Path: <apache@samsung-prod.localdomain>
Received: from samsung-prod.localdomain (50-56-189-151.static.cloud-ips.com. [50.56.189.151])
by mx.google.com with ESMTPS id u30si2907789yhm.128.2012.02.09.08.28.55
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 09 Feb 2012 08:28:55 -0800 (PST)