I hereby claim:
- I am xzero707 on github.
- I am xzero707 (https://keybase.io/xzero707) on keybase.
- I have a public key ASAA5Sg7IqA1pGLf3Utp582WPy4O5T-4tXdm5XZ-0QKd3go
To claim this, I am signing this object:
<?php | |
function folderSize ($dir) | |
{ | |
$size = 0; | |
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) { | |
$size += is_file($each) ? filesize($each) : folderSize($each); | |
} |
<?php | |
/** | |
* Compares two arrays and shows exact difference between them. | |
* | |
* !!! IMPORTANT !! | |
* Order of two supplied arrays matters! | |
* | |
* @fix xZero707 <[email protected]>: Pay attention to types as well | |
* |
#!/bin/bash | |
# | |
# git-mv-with-history -- move/rename file or folder, with history. | |
# | |
# Moving a file in git doesn't track history, so the purpose of this | |
# utility is best explained from the kernel wiki: | |
# | |
# Git has a rename command git mv, but that is just for convenience. | |
# The effect is indistinguishable from removing the file and adding another | |
# with different name and the same content. |
<?php | |
namespace NorthernLights\Util; | |
/** | |
* Map/replace string accordingly to supplied character map | |
* Note: | |
* There is certain overhead because we use 4 function calls main -> mapper -> array_keys -> array_values | |
* versus that it can be done with just single str_replace() | |
* However, accordingly to benchmarks, difference becomes noticeable only after 1 000 000 iterations (~300ms slower) |
#!/bin/bash | |
# | |
not_root() { | |
echo "ERROR: You have to be root to execute this script" | |
exit 1 | |
} | |
zram_exists() { | |
echo "ERROR: /etc/init.d/zram already exists" |
<?php | |
/** | |
* We declare $x as init of anonymous class, which implements magic __toString() method | |
* @author Alexander Puharic <[email protected]> | |
*/ | |
$x = new class | |
{ | |
/** @var array */ | |
private $feed; |
<?php | |
var_dump( | |
(empty('' . $x) && ($x == 'FA' && $x == 'LO' && $x == '103' && $x == '208')) | |
); |
<?php | |
if (!function_exists('interface_exists')) { | |
die('PHP version too old'); | |
} | |
$throwables = listThrowableClasses(); | |
$throwablesPerParent = splitInParents($throwables); | |
printTree($throwablesPerParent); | |
if (count($throwablesPerParent) !== 0) { | |
die('ERROR!!!'); |
<?php | |
/** | |
* Uses a binary search algorithm to locate a value in the specified array | |
* Due to internal function call overhead (count, floor), it might be inefficient to use on small arrays | |
* | |
* Original: | |
* @author Nicholas C. Zakas | |
* @see https://www.htmlgoodies.com/beyond/javascript/how-to-search-a-javascript-string-array-using-a-binary-search.html | |
* |
I hereby claim:
To claim this, I am signing this object: