This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS _EL_INFORME_DE_LA_MUERTE ( | |
CAMPAIGNID INT UNSIGNED NOT NULL, | |
ADASSETID INT UNSIGNED NOT NULL, | |
COUNTRY_CODE CHAR(2) NOT NULL DEFAULT '', | |
CITY_CODE VARCHAR(50) NOT NULL DEFAULT '', | |
TYPE ENUM('DISPLAY','CLICK','SALE','POST_VIEW','POST_CLICK'), | |
AMOUNT INT UNSIGNED NOT NULL DEFAULT 0, | |
DATE_SAVE DATE, | |
PRIMARY KEY (CAMPAIGNID, ADASSETID, TYPE, DATE_SAVE) | |
) ENGINE=MyISAM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// cet algorithme est d'une telle violence | |
$dim = 3; | |
$d = 32; // lol | |
$v1 = array_randn($dim);32; | |
$v2 = array_randn($dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$campaigns = [ | |
'foo' => ['keywords' => ['a','b','c']], | |
'bar' => ['keywords' => ['b','c','e']], | |
'baz' => ['keywords' => ['d','f','b']], | |
]; | |
$allKeywords = array_unique(call_user_func_array('array_merge', array_map(function($c) { return $c['keywords']; }, $campaigns))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function formatGUID($chars, $uppercase = false, $braces = false, $hyphen = true) | |
{ | |
$c = $chars; | |
$h = $hyphen ? '-' : ''; | |
$g = | |
"{$c[00]}{$c[01]}{$c[02]}{$c[03]}{$c[04]}{$c[05]}{$c[06]}{$c[07]}{$h}". | |
"{$c[08]}{$c[09]}{$c[10]}{$c[11]}{$h}". | |
"{$c[12]}{$c[13]}{$c[14]}{$c[15]}{$h}". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function stumble2url ($url) { | |
$doc = new DOMDocument; | |
if (!@$doc->loadHTMLFile($url)) | |
return null; | |
return ($iframe = $doc->getElementById('tb-stumble-frame')) | |
? $iframe->getAttribute('src') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// quick'n dirty | |
class Fibonacci implements Iterator { | |
public function __construct () { | |
$this->rewind(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// how to reverse the singleton pattern | |
class Service { | |
public static $data; | |
public static function inc () { | |
static::$data++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace CommandLine; | |
class Colors { | |
public static $_backgroundColors = array( | |
'black' => '40', | |
'red' => '41', | |
'green' => '42', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
spl_autoload_register(function($classname) { | |
if (strpos($classname, '\\with') === false) | |
return false; | |
list($namespace, $class) = str_split($classname, strrpos($classname, '\\')); | |
$class = substr($class, 1); | |
$parts = explode('\\with', $classname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage { | |
echo "Usage: $0 [file] [start|stop|status|connect]" | |
} | |
if [ -z $1 ]; then | |
usage | |
exit 0 | |
fi |