isNumericByRegExp x 1,316,572 ops/sec ±1.16% (87 runs sampled)
isNumeric x 525,836 ops/sec ±1.34% (85 runs sampled)
Fastest is isNumericByRegExp
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/sh | |
#Here's a little one liner that'll do the trick (for passwordless auth) after you've done the ssh-keygen -d: | |
#how to use: /skey forum@zjm-forum-test10.zjm | |
if [ $# -lt 1 ]; then | |
echo "usage: $0 <username@host>" | |
echo " i.e.: $0 welefen@www.welefen.com" | |
echo |
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 iconvLite = require('iconv-lite'); | |
global.convertEncoding = function(str, encoding){ | |
encoding = encoding || 'utf8'; | |
if (encoding === 'utf8') { | |
return iconvLite.decode(new Buffer(str, 'binary'), 'gb2312'); | |
}else{ | |
return iconvLite.encode(str, 'gb2312').toString('binary'); | |
} | |
}; |
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 rawurlencode(str) { | |
str = (str+'').toString(); | |
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A'); | |
} | |
function urlencode(str) { | |
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40'); | |
} |
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
/** | |
* 动态创建一个类 | |
* 提供了继承、扩展、调用父级别方法等方法 | |
* @return {[type]} [description] | |
*/ | |
global.Class = function (prop) { | |
var cls = function () { | |
function T(args) { | |
if(typeof this.init === 'function'){ |
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
/** | |
* 基于配置的事件代理 | |
* @param {[type]} configs [description] | |
* @return {[type]} [description] | |
*/ | |
$.fn.delegates = function(configs) { | |
el = $(this[0]); | |
for (var name in configs) { | |
var value = configs[name]; | |
if (typeof value == 'function') { |
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 numberReg = /^((\d*\.?\d*(?:e[+-]?\d*(?:\d?\.?|\.?\d?)\d*)?)|(0[0-7]+)|(0x[0-9a-f]+))$/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
<?php | |
$fromYear = 2013; | |
$fromMonth = 10; | |
$endYear = 2015; | |
$endMonth = 5; | |
$months = ($endYear - $fromYear) * 12 + $endMonth - $fromMonth; | |
for($i=-1;$i<$months;$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
<?php | |
/** | |
* 获取内容的编码 | |
* @param string $str | |
*/ | |
function get_encoding($str = "") { | |
$encodings = array ( | |
'ASCII', | |
'UTF-8', |
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 getDict(length, prefix){ | |
length = length || 1; | |
prefix = prefix || ""; | |
var chars = "abcdefghijklmnopqrstuvwxyz".split(""); | |
var result = []; | |
chars.forEach(function(char){ | |
result.push(prefix + char); | |
if(length>1){ | |
result.push.apply(result, getDict(length - 1, char)); | |
} |
NewerOlder