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
sometimes we don't want to make any usage to the hardisk, when we just want to grab something from remote server, and make a Zip archive for download, and the offical php ZipArchive module don't support this till now, so here is a class to make this(from phpMyAdmin library). | |
Here is sample usage: | |
require_once('zip.lib.php'); | |
//create the zip | |
$zip = new zipfile(); | |
//add files to the zip, passing file contents, not actual 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
'isInFrame': function () { | |
try { | |
return window.self !== window.top; | |
} | |
catch (e) { | |
return true; | |
} | |
} |
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 (url, name, value) { | |
if (url) { | |
var parser = document.createElement('a'); | |
parser.url = url; | |
return url + [(parser.search ? '&' : '?'), name, '=', value].join(''); | |
} | |
else { | |
return ''; | |
} |
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 recursiveCompare(a, b) { | |
if (!(a instanceof Object) && !(b instanceof Object)) { | |
return a === b; | |
} | |
else if (a instanceof Array && b instanceof Array) { | |
for (var i = 0, l = a.length; i < l; i++) { | |
if (recursiveCompare(a[i], b[i]) === false) { | |
return false; | |
} |
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 | |
/** | |
* Created by PhpStorm. | |
* User: Youi | |
* Date: 2015-12-05 | |
* Time: 02:47 | |
*/ | |
// buffer all upcoming output | |
ob_start(); |
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 | |
/** | |
* Convert bytes to human readable format | |
* | |
* @param integer bytes Size in bytes to convert | |
* @return string | |
*/ | |
function bytesToSize($bytes, $precision = 2) | |
{ |
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 | |
$s = preg_replace('^(([ \r\n\t])*( )*)*', '', $s); | |
$s = preg_replace('(([ \r\n\t])*( )*)*$', '', $s); |
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
x+'' //convert to string | |
+x //convert to number | |
!!x //convert to boolean | |
//generate short random string | |
Math.random().toString(36).slice(-5) | |
//generate random ports | |
((Math.random() + 1) / 2 * 65535).toString().slice(0, 5) |
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
google.com | |
youtube.com | |
google.com.hk | |
googleusercontent.com | |
googleapis.com | |
googlesyndication.com | |
google-analytics.com | |
googlevideo.com | |
gstatic.com | |
ggpht.com |
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
//task killer | |
taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t] |