

2026年4月16日小于 1 分钟


具有内置负载均衡的的Node.js应用进程管理器。
使用hexo时,hexo进程总会无辜挂掉(可能是服务器内存不够),所以就需要一个能监控hexo挂掉,就自动重启的小工具。
$ pm2 start --name hexo /opt/hexo/auto-start-hexo.js
var arr = [];
var arrayProto = Array.prototype,
arrayMethods = Object.create(arrayProto),
newArrProto = [];
['push'].forEach(method => {
let original = arrayMethods[method];
newArrProto[method] = function mutator() {
console.log(arguments[0]);
return original.apply(this, arguments);
}
});
arr.__proto__ = newArrProto;
arr.push('111');
arr.push('222');
arr.push('333');
忍无可忍,必须改变,去写看着舒服的代码,而非云云。。。
缩进层级
语句结尾(加分号)
行的长度、换行
空行(大段逻辑前边加空行)
代码看起来应当像一系列可读的段落,而不是一大段揉在一起的连续文本。
命名(驼峰命名)
计算机科学只存在两个难题:缓存失效和命名。
变量和函数
变量名:驼峰命名,命名的前缀应该为名词;
函数名:驼峰命名,函数名前缀应当为动词。
| 动词 | 含义 |
|---|---|
| can | 函数返回一个布尔值 |
| has | 函数返回一个布尔值 |
| is | 函数返回一个布尔值 |
| get | 函数返回一个非布尔值 |
| set | 函数用来保存一个值 |
命名尽可能短,抓住要点,尽量在变量名中体现出值的数据类型。
避免使用没有意义的命名,foo、bar、tmp之类
常量(大写字母 + 下换线分隔)
构造函数
原始变量(字符串、数字、布尔值、null、undefined)
字符串(单引号和双引号没啥区别,但你的代码应从头到尾只保持一种风格)
多行字符串要用+分隔
数字(只有一种数字类型——不区分整数、浮点数)
null(用来初始化变量、相当于一个占位符)
undefined
直接声明对象
{
"editor.wordWrap": "on",
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.tree.indent": 24,
"vetur.format.options.tabSize": 2,
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"files.associations": {
"*.wxml": "xml",
"*.wxss": "css",
"*.sass": "css",
"*.wpy": "vue",
"*.vue": "vue"
},
"emmet.includeLanguages": {
"vue-html": "html",
"javascript": "javascriptreact",
"postcss": "css"
},
"emmet.triggerExpansionOnTab": true,
"emmet.showSuggestionsAsSnippets": true,
"vetur.validation.template": false,
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-expand-multiline"
},
"prettyhtml": {
"printWidth": 100,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
},
"prettier": {
"semi": false,
"singleQuote": true
}
},
"eslint.enable": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
{ "language": "html", "autoFix": true },
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true },
{ "language": "vue", "autoFix": true }
],
"prettier.singleQuote": true,
"prettier.semi": false,
"prettier.disableLanguages": ["markdown"],
"extensions.autoUpdate": false,
"breadcrumbs.enabled": true,
"window.zoomLevel": 0,
"javascript.updateImportsOnFileMove.enabled": "always",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"explorer.confirmDelete": false,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tabSize": 2,
"git.autofetch": true,
"git.confirmSync": false,
"diffEditor.ignoreTrimWhitespace": false,
"window.restoreWindows": "all",
"terminal.integrated.rendererType": "dom"
}
<page-frame :fatherData='data'></page-frame>
data: {
name: 'xiaomi',
users: ['amos', 'yuan']
}
node.js的安装:下载msi文件,傻瓜式安装
// 定位到table上
var parNode = document.getElementById("tab_content");
var print = "";
for (var i = 1; i < parNode.rows.length; i++) {
print += "第" + i + "行:";
var con = parNode.rows[i].cells[1];
print += con.innerHTML;
}
if ("" == print) {
alert("您还没添加内容");
} else {
alert(print);
}