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 | |
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php | |
function human_filesize($bytes, $decimals = 2) { | |
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; | |
} | |
echo human_filesize(filesize('example.zip')); |
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
$('#stream-items-id').delegate('.js-tweet-text a[data-expanded-url]', 'click', function(e){ | |
this.href = $(this).attr('data-expanded-url'); | |
}); |
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
/* from http://www.alloyteam.com/wp-content/themes/alloyteam/style.css */ | |
::-webkit-scrollbar-track-piece { | |
background-color:#f5f5f5; | |
border-left:1px solid #d2d2d2; | |
} | |
::-webkit-scrollbar { | |
width:13px; | |
height:13px; | |
} | |
::-webkit-scrollbar-thumb { |
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 | |
/** | |
* Script to check link validity | |
* | |
* @author Satya Prakash | |
* | |
*/ | |
$links = array(); | |
$links[] = 'http://www.satya-weblog.com/2007/04/dynamically-populate-select-list-by.html'; |
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
var _ = function(obj) { | |
if (obj instanceof _) return obj; | |
if (!(this instanceof _)) return new _(obj); | |
this._wrapped = obj; | |
}; |
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
/* | |
list: the array | |
fn: sort fn | |
start: the start index of the sorted range, included | |
end: the end index of the sorted range, excluded | |
means range: [start, end) | |
modify the array itself and return nothing | |
*/ |
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
/* | |
* 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 | |
* @param fn {function} 需要调用的函数 | |
* @param delay {number} 延迟时间,单位毫秒 | |
* @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 | |
* @return {function} 实际调用函数 | |
*/ | |
var throttle = function (fn,delay, immediate, debounce) { | |
var curr = +new Date(),//当前时间 | |
last_call = 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
/* | |
10 x 10 | |
A-Z ( 65 -> 90) | |
output something like this | |
* * * * * * * * * * | |
* * * * * * * * * * | |
* * * * * * * * * * | |
* J I * * * * * * * |
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
var supports = (function() { | |
var div = document.createElement('div'), | |
vendors = 'Khtml Ms O Moz Webkit'.split(' '), | |
len = vendors.length; | |
return function(prop) { | |
if ( prop in div.style ) return true; | |
prop = prop.replace(/^[a-z]/, function(val) { | |
return val.toUpperCase(); |
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
# http://stackoverflow.com/questions/6393787/php-url-to-link-with-regex | |
$str = preg_replace('#(\A|[^=\]\'"a-zA-Z0-9])(http[s]?://(.+?)/[^()<>\s]+)#i', '\\1<a href="\\2">\\3</a>', $str); |
NewerOlder