A Pen by huang.xinghui on CodePen.
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
function defaultHasher() { | |
return JSON.stringify(arguments); | |
} | |
function asyncMemoize(fn, hasher=defaultHasher) { | |
async function memozie() { | |
let cache = memozie.cache; | |
const key = hasher(arguments); | |
if (!cache.hasOwnProperty(key)) { |
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
function createArrayIterator(coll) { | |
var i = -1; | |
var len = coll.length; | |
return function next() { | |
return ++i < len ? {value: coll[i], key: i} : null; | |
} | |
} | |
function eachLimit(coll, limit, iteratee) { | |
if (limit <= 0 || !coll) return Promise.resolve(); |
cron is a utility that you can use to schedule and automate tasks. By defining items in the cron table, called crontab, you can schedule any script or program to run on almost any sort of schedule. For example, Research [Flagship Merchant Services][1] on Thursday at 6:30pm.
For example, run a [program][2] each day 5 minutes after midnight on mondays, wednesdays and fridays. Or schedule something to run every five minutes, or once a month.
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
// 摘自Secrets of the JavaScript Ninja | |
function argumentNames(fn) { | |
var found = /^[\s\(]*function[^(]*\(\s*([^)]*?)\s*\)/.exec(fn.toString()); | |
return found && found[1] ? found[1].split(/,\s*/) : []; | |
} | |
argumentNames(function(x){})[0] === "x" |
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
// 摘自http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html | |
function globalEval(data) { | |
data = data.replace(/^\s*|\s*$/g, ""); | |
if (data) { | |
var head = document.getElementsByTagName("head")[0] || | |
document.documentElement, | |
script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.text = data; | |
head.appendChild(script); |
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
// 摘自Secrets of the JavaScript Ninja | |
Function.prototype.partial = function() { | |
var fn = this, args = Array.prototype.slice.call(arguments); | |
return function() { | |
var arg = 0; | |
for (var i = 0; i < args.length && arg < arguments.length; i++) { | |
if (args[i] === undefined) { | |
args[i] = arguments[arg++]; | |
} | |
} |
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
curl -w "TCP handshake: %{time_connect}, SSL handshake: %{time_appconnect}\n" -so /dev/null https://www.alipay.com | |
#上面命令中的w参数表示指定输出格式,timeconnect变量表示TCP握手的耗时,timeappconnect变量表示SSL握手的耗时(更多变量请查看文档和实例),s参数和o参数用来关闭标准输出。 | |
#摘自http://www.ruanyifeng.com/blog/2014/09/ssl-latency.html |
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
# 查看当前目录文件总数 | |
find ./ -name "*.js" | wc -l | |
# 查看当前目录文件总行数 | |
find ./ -name "*.js" | xargs cat | wc -l | |
# 查看当前目录文件总行数,不包含空行 | |
find ./ -name "*.js" | xargs cat | grep -v ^$ | wc -l |
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
//使g()(‘al’)返回字符串”goal”; | |
//g()()(‘al’)输出”gooal”; | |
//代码g()()()(‘al’)返回goooal; | |
// 各个语言版本参考链接 https://github.com/eatnumber1/goal | |
// 一开始自己想的一个版本 | |
function g() { | |
var stack = ['g']; | |
if (arguments.length === 0) { |
NewerOlder