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
/** | |
* @source: http://codeaid.net/php/convert-size-in-bytes-to-a-human-readable-format-(php) | |
*/ | |
function bytesToSize1024($bytes, $precision = 2) | |
{ | |
$unit = array('B','KB','MB','GB','TB','PB','EB'); | |
return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i]; | |
} |
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
// Source: http://stackoverflow.com/a/356431 | |
class B { | |
public function method_from_b($s) { | |
echo $s; | |
} | |
} | |
class C { | |
public function method_from_c($s) { |
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
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $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
/** | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* @source: http://www.webtoolkit.info/javascript-base64.html | |
* | |
*/ | |
var Base64 = { | |
/** | |
* Base 64 char set | |
*/ |
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
@source: http://php.net/manual/en/function.readfile.php | |
<?php | |
$file = 'monkey.gif'; | |
if (file_exists($file)) { | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Disposition: attachment; filename='.basename($file)); | |
header('Expires: 0'); |
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
@source: http://www.php.net/manual/en/function.filesize.php#112996 | |
<?php | |
/** | |
* Converts bytes into human readable file size. | |
* | |
* @param string $bytes | |
* @return string human readable file size (2,87 Мб) | |
* @author Mogilev Arseny | |
*/ |
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
@source: http://www.naveen.com.au/javascript/jquery/encode-or-decode-html-entities-with-jquery/289 | |
function htmlEncode(value){ | |
if (value) { | |
return jQuery('<div />').text(value).html(); | |
} else { | |
return ''; | |
} | |
} | |
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
<?php | |
/* | |
* @source http://stackoverflow.com/questions/1147931/how-do-i-determine-the-extensions-associated-with-a-mime-type-in-php | |
*/ | |
function system_extension_mime_types() { | |
# Returns the system MIME type mapping of extensions to MIME types, as defined in /etc/mime.types. | |
$out = array(); | |
$file = fopen('/etc/mime.types', 'r'); |
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
<?php | |
/** | |
* List of Microsoft office file MIME types | |
* @date 2014-07-09 | |
*/ | |
return array( | |
'doc'=>'application/msword', | |
'dot'=>'application/msword', |