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 | |
$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 | |
// 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
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 | |
class Bitfield | |
{ | |
const FIELD_SIZE = 32; | |
public static function getDistance(array $a, array $b) | |
{ | |
$dist = 0; |
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
Show hidden characters
{ | |
"completion_type": "nix", | |
"folder_permissions": "775", | |
"file_permissions": "775" | |
} |
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
// Case 1 | |
// will display '9223372036854775807 equals 9223372036854775808' | |
// bug https://bugs.php.net/bug.php?id=54547 | |
$a = '9223372036854775807'; | |
$b = '9223372036854775808'; | |
if ($a == $b) | |
echo "$a equals $b\n"; |
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 glob_recursive($pattern, $flags = 0) { | |
$files = glob($pattern, $flags); | |
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { | |
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); | |
} | |
return $files; | |
} |
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 | |
set_time_limit(0); | |
function glob_recursive($pattern, $flags = 0) { | |
$files = glob($pattern, $flags); | |
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { | |
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); | |
} | |
return $files; | |
} |
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 | |
class Singleton { | |
public static $aliases = array(); | |
protected static $_adapters = array(); | |
public function __construct () { | |
throw new LogicException("you cannot instanciate Singleton"); |
OlderNewer