Skip to content

Instantly share code, notes, and snippets.

var trimInfo =
{ basic: / /
// vb中的简单空白字符过滤
, classic: /\s/
// 传统的js空白字符过滤
, ecmascript5: /[\s\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
// ECMAScript 5中对/s的补充定义
, ex: /[\s\xA0\u2028\u2029]/
// 印象中是和js中的标识符或者字符串有关,忘了从哪来的了XD
, control: /[\x00-\x1F\x7F-\x9F]/
//俄罗斯方块 http://js1k.com/2010-first/demo/663
w=document.body.children.c,
E=4099,
C=8191,
e=l=n=L=0;
R=eval(localStorage['x'])||[];
with(w.getContext('2d')){
// Get block
I=function(a,c,d){return(i=[[[2,7],[2,6,2],[0,7,2],[2,3,2]],[[1,3,2],[6,3]],[[2,3,1],[3,6]],[[2,2,6],[0,7,1],[3,2,2],[4,7]],[[2,2,3],[1,7],[6,2,2],[0,7,4]],[[2,2,2,2],[0,15]],[[3,3]]][a%7])[(a+c)%i.length]};
$.each(
{
Y: 'FullYear',
m: 'Month',
d: 'Date',
D: 'Day',
H: 'Hours',
M: 'Minutes',
S: 'Seconds',
echo 'http://www.bmw.com/com/en/newvehicles/3series/coupe/2010/showroom/highlights/../../../../../../../../_common/files/js/jquery.js'|perl -pe 'while(s{/(?>[^/]+)/\.\./}{/}){}'
# trip .. in path
//old
return style.filter && style.filter.indexOf("opacity=") >= 0 ?
(parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
"";
//new
return style.filter &&
(value = style.filter.match(/^\s*alpha\s*\(\s*opacity\s*=\s*(['"]?)\s*([0-9.]+)\s*\1\s*\)\s*$/i)) ?
(parseFloat( value[2] ) / 100) + '':
"";
//trim vs
var t = 10, txt='\n adf '+document.body.innerHTML;
txt += txt + 'a \t';
console.time(1);
for (var i=0;i<t;i++){
(function( text ) {
return (text || "").replace( /^\s+|\s+$/g, "" );
})(txt);
var o = "", bd = document.body, h = bd.innerHTML;
h += h;h += h;h += h;
console.time(1);
h.replace(
/(?:<img[^>]*?)(?:src *?= *?("[^"]+"|'[^']+'|[^ >]+))/ig,
function(m, src) {
src = src.replace(/^['"]/,'').replace(/['"]$/,'');
o += "<li>" + src + ' <img src="' + src + '" /></li>';
});
ps -eo pid,comm,rss|grep httpd|grep -v grep|awk '{print $3}'|perl -e '$s = 0;while (<>){chomp;$s += $_;}print $s/1024,"M\n";'
#!/usr/bin/perl
use strict;
use warnings;
use LWP;
use LWP::UserAgent ;
use LWP::Simple;
use HTML::Tree;
use URI::Escape;
use URI::QueryParam;
#Recipe 325205: Cache decorator in python 2.4
#http://code.activestate.com/recipes/325205/, http://www.python.org/peps/pep-0318.html
def memoize(f, cache={}):
def g(*args, **kwargs):
key = ( f, tuple(args), frozenset(kwargs.items()) )
if key not in cache:
cache[key] = f(*args, **kwargs)
return cache[key]
return g