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 pipe(data, ...args) { | |
return args.reduce((r, f) => f(r), data); | |
} | |
//test | |
function f1(a) { | |
a.pop(); | |
return a; | |
} | |
function f2(a) { |
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
1、安装openssl:http://slproweb.com/products/Win32OpenSSL.html。 | |
2、设置环境变量 | |
a)新建变量:OPENSSL_HOME => C:\OpenSSL-Win64\bin; | |
b)Path变量添加:%OPENSSL_HOME%。 | |
3、创建私钥 | |
C:\nginx\ssl> openssl genrsa -des3 -out [name].key 1024 | |
[name]为文件名,任意 | |
输入密码,完成 |
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) { | |
var script = document.createElement("script"); | |
script.src = url; | |
var n = document.getElementsByTagName("script")[0]; | |
n.parentNode.insertBefore(script, n); | |
})(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
// scrollHeight 内容完整高度 | |
scrollHeight = document.compatMode === "CSS1Compat" ? document.documentElement.scrollHeight : document.body.scrollHeight; | |
// or | |
scrollHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight); | |
// scrollTop 滚动高度 | |
scrollTop = document.documentElement.scrollTop || document.body.scrollTop; | |
// clientHeight 可视高度 | |
clientHeight = document.compatMode === "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight; |
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 tco(f) { | |
var value; | |
var active = false; | |
var accumulated = []; | |
return function accumulator() { | |
accumulated.push(arguments); | |
if (!active) { | |
active = true; | |
while (accumulated.length) { |
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 thousandfy(value) { | |
let re = /\d{1,3}(?=(\d{3})+$)/g; | |
return String(value).replace(/^(\d+)((\.\d+)?)$/, (s, s1, s2) => s1.replace(re, "$&,") + s2) | |
} | |
thousandfy('24426295.93') // => 24,426,295.93 |
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 remainingTime (rt) { | |
var hour = (rt | 0)/(3600*1000) | 0, | |
minute = ((rt | 0)%(3600*1000))/(60*1000) | 0, | |
second = ((rt | 0)%(3600*1000)%(60*1000))/1000 | 0; | |
if (rt <= 0) { | |
return; | |
} else { | |
setTimeout(function(){ | |
remainingTime(rt - 1000); |
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 isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); | |
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 mapToObj (map) { | |
let obj = Object.create(null) | |
for (let [k,v] of map) { | |
obj[k] = v | |
} | |
return obj | |
} | |
function mapToObjArray (map) { | |
let objArray = [] |