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 | |
if [ ! $(whoami) = 'root' ]; then | |
echo "This script should be run as root." > /dev/stderr | |
exit 1 | |
fi | |
spinner() | |
{ | |
local pid=$! |
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 | |
if [ ! $(whoami) = 'root' ]; then | |
echo "This script should be run as root." > /dev/stderr | |
exit 1 | |
fi | |
if [ ! -f "/opt/local/bin/port" ] ; then | |
echo "This script requires macports to be installed" | |
exit 1 |
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
AddType application/json .shrunk | |
AddType application/javascript .shrunk.jsonp | |
<IfModule mod_rewrite.c> | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.+.q(?:[0-9]+).shrunk)$ shrinkimage.php?file=$1 [QSA,L] | |
RewriteRule ^(.+.q(?:[0-9]+).shrunk.jsonp)$ shrinkimage.php?file=$1&jsonp=1 [QSA,L] | |
</IfModule> | |
<Ifmodule mod_deflate.c> |
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
getFiles($directory, $recursive = false, $pattern = NULL, $absolute = false) { | |
$return = array(); | |
$iterator = ($recursive === false) ? new \FilesystemIterator($directory, \FilesystemIterator::SKIP_DOTS) : new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::SELF_FIRST); | |
$iterator = ($pattern !== NULL) ? new \RegexIterator($iterator, '/' . $pattern . '/i') : $iterator; | |
$directory = preg_quote($directory . '/', '/'); | |
foreach($iterator as $path) { | |
if($path->isFile() === true) { | |
$return[] = ($absolute !== false) ? $path->getPathname() : preg_replace('/^' . $directory . '/', '', $path->getPathname()); | |
} |
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
function convertCharset($value, $characterset = NULL) { | |
return (mb_check_encoding($value, $characterset) === true) ? $value : mb_convert_encoding($value, $characterset); | |
} |
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
function sanitize($value) { | |
$value = preg_replace('/[\x00-\x1f\?*:";|\/°^!§$%&\\()=´`+#\':,<>]/', '', trim($value)); | |
$value = preg_replace('/^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d)(?:\.*)(.*)/', '\1', $value); | |
return $value; | |
} |
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
function sluggify($value) { | |
return trim(strtolower(preg_replace('/([^\w]|-)+/', '-', trim(strtr(str_replace('\'', '', trim($value)), array( | |
'À'=>'A','Á'=>'A','Â'=>'A','Ã'=>'A','Å'=>'A','Ä'=>'A','Æ'=>'AE', | |
'à'=>'a','á'=>'a','â'=>'a','ã'=>'a','å'=>'a','ä'=>'a','æ'=>'ae', | |
'Þ'=>'B','þ'=>'b','Č'=>'C','Ć'=>'C','Ç'=>'C','č'=>'c','ć'=>'c', | |
'ç'=>'c','Ď'=>'D','ð'=>'d','ď'=>'d','Đ'=>'Dj','đ'=>'dj','È'=>'E', | |
'É'=>'E','Ê'=>'E','Ë'=>'E','è'=>'e','é'=>'e','ê'=>'e','ë'=>'e', | |
'Ì'=>'I','Í'=>'I','Î'=>'I','Ï'=>'I','ì'=>'i','í'=>'i','î'=>'i', | |
'ï'=>'i','Ľ'=>'L','ľ'=>'l','Ñ'=>'N','Ň'=>'N','ñ'=>'n','ň'=>'n', | |
'Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O','Ø'=>'O','Ö'=>'O','Œ'=>'OE', |
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
function transliterate($value, $characterset) { | |
return iconv(mb_detect_encoding($value, NULL, true), $characterset . '//IGNORE//TRANSLIT', trim($value)); | |
} |
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
function isValidPath($value) { | |
return (preg_match('/^(\/(?:(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:\/(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))$/', (string) $value) > 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
function isValidFilename($value) { | |
return (strlen($value) <= 255 && preg_match('/^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\?*:"";|\/]+$/', $value) > 0); | |
} |