This file contains hidden or 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
function checkFolders($path) { | |
$bits = explode(DIRECTORY_SEPARATOR, $path); | |
$sandbox = ''; | |
foreach($bits as $bit) { | |
$sandbox .= $bit . DIRECTORY_SEPARATOR; | |
if(!is_dir($sandbox)) { | |
mkdir($sandbox); | |
} | |
} |
This file contains hidden or 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
$files = array(); | |
function returnFiles($dir) { | |
global $files; | |
$dh = opendir($dir); | |
while(false !== ($filename = readdir($dh))) { | |
if($filename == '.' || $filename == '..') { | |
continue; | |
} | |
echo $dir.DIRECTORY_SEPARATOR.$filename . "\n"; | |
if(is_file($dir.DIRECTORY_SEPARATOR.$filename)) { |
This file contains hidden or 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
/* | |
** String prototype for clipping text and optionally adding ellipsis | |
** Does not modify original variable | |
** -Example- | |
** var thisStr = 'Some string of text'; | |
** var newStr = thisStr.clip(10, '...', true); // Some... | |
** var newStr = thisStr.clip(15, '...', true); // Some string of... | |
*/ | |
String.prototype.clip = function(len/* Number */, str/* String */, bound/* Boolean */) { | |
var origLen = len; |
This file contains hidden or 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
function foldersToArray($path, $flat = false) { | |
$folderArray = array(); | |
if($handle = opendir($path)) { | |
while (false !== ($file = readdir($handle))) { | |
if($file != '.' && $file != '..') { | |
if(!in_array($path.'/'.$file, $folderArray) && is_file($path.'/'.$file)) { | |
if($flat) { | |
array_push($folderArray, $path.'/'.$file); | |
} else { | |
array_push($folderArray, $file); |
This file contains hidden or 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
function in_array_exclusive($needles, $haystack) { | |
$keys = count($haystack); | |
if(is_array($needles)) { | |
foreach($needles as $needle) { | |
if(!in_array($needle, $haystack)) { | |
return false; | |
} else { | |
$keys = $keys - 1; | |
} | |
} |
This file contains hidden or 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
function removeEmptySubFolders($path) { | |
$empty = true; | |
foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file) { | |
$empty &= is_dir($file) && RemoveEmptySubFolders($file); | |
} | |
return $empty && rmdir($path); | |
} |
This file contains hidden or 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
if(!Array.prototype.unshift) { // if this method does not exist.. | |
Array.prototype.unshift = function(){ | |
this.reverse(); | |
for(var i=arguments.length-1;i>=0;i--){ | |
this[this.length]=arguments[i] | |
} | |
this.reverse(); |
This file contains hidden or 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
if(!Array.prototype.shift) { // if this method does not exist.. | |
Array.prototype.shift = function(){ | |
firstElement = this[0]; | |
this.reverse(); | |
this.length = Math.max(this.length-1,0); | |
this.reverse(); | |
return firstElement; | |
} | |
This file contains hidden or 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
/* | |
** intersect.js | |
** intersect multiple arrays | |
** Usage: | |
var arr1 = ['hey', 'you', 'guys', 'test', 'there']; | |
var arr2 = ['there', 'you']; | |
var arr3 = ['some', 'there', 'you', 'thrice', 'hey', 'huzzah']; | |
intersect(arr1, arr2, arr3); | |
*/ | |
function intersect() { |
This file contains hidden or 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
var getAbsoluteUrl = function(url, path) { | |
if(url.substr(-1) == '/') { | |
url = url.substr(0, url.length-1); | |
} | |
var path = path; | |
if(path !== null) { | |
if(url.substr(-1) == "/") { | |
url = url.substr(0, url.length-1); |
OlderNewer