- yum install ntp //安装ntp服务
- systemctl enable ntpd //开机启动服务
- systemctl start ntpd //启动服务
- timedatectl set-timezone Asia/Shanghai //更改时区
- timedatectl set-ntp yes //启用ntp同步
- ntpq -p //同步时间
- date -R // 查看结果
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 retry(func, interval = 1000, times = 6) { | |
return function retryTask(...args) { | |
let innerTimes = times; | |
return new Promise(async function loop(resolve, reject) { | |
innerTimes -= 1; | |
try { | |
const res = await func.apply(this, args); | |
resolve(res); |
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 cloneObj = function(obj){ | |
var str, newobj = obj.constructor === Array ? [] : {}; | |
if(typeof obj !== 'object'){ | |
return; | |
} else if(window.JSON){ | |
str = JSON.stringify(obj), //系列化对象 | |
newobj = JSON.parse(str); //还原 | |
} else { | |
for(var i in obj){ | |
newobj[i] = typeof obj[i] === 'object' ? |
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 arr | |
* @param i {Number} 旧的位置 | |
* @param j {Number} 新的位置 | |
* @returns {*} | |
*/ | |
function swap(arr, i, j) { | |
let tmp = arr[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
/** | |
* 加载script | |
* @param src | |
* @returns {Promise} | |
*/ | |
function scriptLoader(src) { | |
return new Promise((resolve, reject) => { | |
let script = document.createElement('script') | |
script.src = src | |
script.onload = resolve |
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
const sleep = (n) => { | |
let start = Date.now() | |
while(true) if (Date.now() - start > n) break | |
} |
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
::-webkit-scrollbar { | |
width: 6px; | |
height: 8px; | |
} | |
::-webkit-scrollbar-track { | |
-webkit-border-radius: 5px; | |
border-radius: 5px; | |
background: rgba(0, 0, 0, 0.1); | |
} |
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 guid = 0; | |
function run() { | |
guid++; | |
var id = guid; | |
return new Promise(resolve => { | |
// resolve in a random amount of time | |
setTimeout(function () { | |
console.log(id); | |
resolve(id); | |
}, (Math.random() * 1.5 | 0) * 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 debounce(method, context) { | |
clearTimeout(method.tId); | |
method.tId = setTimeout(function() { | |
method.call(context); | |
}, 1000); | |
} | |
var throttle = function (action, delay){ | |
var last = 0; | |
return function(){ |
NewerOlder