Compare commits

..

68 Commits

Author SHA1 Message Date
81271ed70d released v1.23.0 2022-11-18 17:29:34 +08:00
35fbc5a3f1 doc: modify README.md. 2022-11-18 09:24:00 +00:00
882fa91ddc doc: modify CONTRIBUTING.md. 2022-11-18 09:23:59 +00:00
4dfc55800c doc: update lua logo. #133 2022-11-18 17:22:47 +08:00
9858796be6 doc: modify README.md. 2022-11-18 09:18:27 +00:00
3d6cde371a doc: modify CONTRIBUTING.md. 2022-11-18 09:18:27 +00:00
48dc6076aa doc: update tar.md #134 2022-11-18 17:12:45 +08:00
b3a11fcbe0 doc: update css.md 2022-11-18 17:05:48 +08:00
cec3afa139 doc: update pytorch.md #138 2022-11-18 17:05:32 +08:00
78929052b2 doc: update lua.md #133 2022-11-18 16:46:21 +08:00
376b40eb7a doc: modify README.md. 2022-11-18 08:45:56 +00:00
beb534d85e doc: modify CONTRIBUTING.md. 2022-11-18 08:45:56 +00:00
Zyj
29df8a3f72 feat: add pytorch.md (#138) 2022-11-18 16:44:58 +08:00
WHB
7f3a01ab23 doc: Update swift.md (#137) 2022-11-18 16:36:40 +08:00
3ce76d3089 feat: add lua.md (#133)
* doc: write lua.md

* update
2022-11-18 16:36:08 +08:00
0486c9c44b doc: modify README.md. 2022-11-18 08:24:39 +00:00
4b4dd754d1 doc: modify CONTRIBUTING.md. 2022-11-18 08:24:38 +00:00
c0c47f3c3d feat: add tar.md (#134) 2022-11-18 16:23:41 +08:00
7320ba5233 doc: modify README.md. 2022-11-18 08:22:10 +00:00
e5a5c5446e doc: modify CONTRIBUTING.md. 2022-11-18 08:22:10 +00:00
e096c08a2c docs: update vue.md (#136) 2022-11-18 16:21:09 +08:00
8a2a3f798f doc: modify README.md. 2022-11-18 07:44:50 +00:00
dfb0bed531 doc: modify CONTRIBUTING.md. 2022-11-18 07:44:49 +00:00
ad4d13de21 docs: update css.md (#132)
* doc: update css.md

* doc: update css.md
2022-11-18 15:43:38 +08:00
138a70b923 doc: modify README.md. 2022-11-18 07:37:08 +00:00
e313d5e63b doc: modify CONTRIBUTING.md. 2022-11-18 07:37:08 +00:00
dee418763a doc: modify README.md. 2022-11-18 07:36:16 +00:00
c905e30b86 doc: modify CONTRIBUTING.md. 2022-11-18 07:36:15 +00:00
1cddd80c03 docs: update vue.md (#130)
wath--->watch
2022-11-18 15:36:01 +08:00
1ddbc5b984 feat: add apt.md (#131) 2022-11-18 15:35:20 +08:00
fe436e287b doc: update cmd.md. #128 2022-11-18 14:51:52 +08:00
e060d26815 website: fix footer timezone bug (#127) 2022-11-18 14:39:30 +08:00
3846b515b5 feat: add cmd.md (#128) 2022-11-18 14:38:07 +08:00
32a3177738 doc: update vue.md (#126)
* fix: 和[Attribute 绑定]的部分重叠了

* doc: 新增自定义指令

* doc: 新增[响应式样式]

* docs: [入门]部分改为vue3写法

* docs: 新增获取事件对象相关内容

* fix: 删除多余文件

* docs: 新增[组件通信]相关内容
2022-11-18 13:29:59 +08:00
37d647eb67 doc: update vue.md #125 2022-11-18 12:39:34 +08:00
84a545cbf6 chore: update scripts. 2022-11-18 12:33:21 +08:00
4505675c8a doc: modify README.md. 2022-11-18 04:32:28 +00:00
d2cd7d94dd doc: modify CONTRIBUTING.md. 2022-11-18 04:32:27 +00:00
7889b77174 doc: update vue.md (#125)
* fix: 和[Attribute 绑定]的部分重叠了

* doc: 新增自定义指令

* doc: 新增[响应式样式]

* docs: [入门]部分改为vue3写法

* docs: 新增获取事件对象相关内容

* fix: 删除多余文件
2022-11-18 12:31:21 +08:00
9005f760d6 doc: modify README.md. 2022-11-18 03:06:09 +00:00
c9936dd525 doc: modify CONTRIBUTING.md. 2022-11-18 03:06:08 +00:00
128da3f03d doc: update vue.md (#123)
* fix: 和[Attribute 绑定]的部分重叠了

* doc: 新增自定义指令
2022-11-18 11:04:56 +08:00
62b0077745 doc: update vue2.md #122 2022-11-18 10:59:15 +08:00
36be2f4226 doc: modify README.md. 2022-11-18 02:53:40 +00:00
8f0dd77829 doc: modify CONTRIBUTING.md. 2022-11-18 02:53:39 +00:00
03d4aedc3d doc: upate vue2.md (#122)
v-for和v-if不推荐一起使用,效率较低.推荐使用computed计算属性.
当两者一起使用时v-for具有较高的优先级.
2022-11-18 10:52:24 +08:00
176bc1af3b doc: modify README.md. 2022-11-18 01:05:55 +00:00
59224651ad doc: modify CONTRIBUTING.md. 2022-11-18 01:05:55 +00:00
32f09fdf5d docs(ansible): update ansible.md (#121) 2022-11-18 09:04:58 +08:00
7e3810b48f doc: modify README.md. 2022-11-17 15:39:14 +00:00
3152b26478 doc: modify CONTRIBUTING.md. 2022-11-17 15:39:13 +00:00
61c3a6e528 doc: Update dockerfile.md #120 2022-11-17 23:37:42 +08:00
c6ac6dcf11 docs(dockerfile):添加用于减小镜像体积的多阶段构建 (#120) 2022-11-17 23:32:17 +08:00
37903965d1 doc: modify README.md. 2022-11-17 14:41:03 +00:00
51d396c119 doc: modify CONTRIBUTING.md. 2022-11-17 14:41:03 +00:00
b38129c127 doc: Update latex.md 添加希腊和希伯来字母 (#119) 2022-11-17 22:39:59 +08:00
bd82b34331 doc: modify README.md. 2022-11-17 09:42:42 +00:00
7ce13da973 doc: modify CONTRIBUTING.md. 2022-11-17 09:42:42 +00:00
8b48dd97c0 doc: update vue.md (#117) 2022-11-17 17:41:39 +08:00
f9073adf32 doc: update ansible.md (#116) 2022-11-17 17:40:52 +08:00
8c29c45622 doc: modify README.md. 2022-11-17 09:09:34 +00:00
db63c34543 doc: modify CONTRIBUTING.md. 2022-11-17 09:09:33 +00:00
764b55045d website: fix search data error. #105 #32 2022-11-17 17:08:26 +08:00
7479c1045c chore: format search data. #105 #32 2022-11-17 16:53:45 +08:00
dab87fc21b doc: update README.md 2022-11-17 16:34:29 +08:00
3263edca0e docs: add string to json array (#114) 2022-11-17 16:22:41 +08:00
d2b0a34e69 chore: compress search data. #105 #32 2022-11-17 16:01:18 +08:00
b034d7970d website: add search data. #105 2022-11-17 15:58:53 +08:00
25 changed files with 1874 additions and 35 deletions

View File

@ -96,6 +96,15 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/Jack-Zhang-1314" title="fw_qaq">
<img src="https://avatars.githubusercontent.com/u/82551626?v=4" width="42;" alt="fw_qaq"/>
</a>
<a href="https://github.com/Alex-Programer" title="Alex">
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
</a>
<a href="https://github.com/expoli" title="expoli">
<img src="https://avatars.githubusercontent.com/u/31023767?v=4" width="42;" alt="expoli"/>
</a>
<a href="https://github.com/partoneplay" title="partoneplay">
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
</a>
@ -108,9 +117,15 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/Smartdousha" title="Anko">
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
</a>
<a href="https://github.com/Brid9e" title="Brid9e">
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Brid9e"/>
</a>
<a href="https://github.com/CharlotteZeng" title="Chart">
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="Chart"/>
</a>
<a href="https://github.com/DaiNing810" title="DaiN">
<img src="https://avatars.githubusercontent.com/u/94962339?v=4" width="42;" alt="DaiN"/>
</a>
<a href="https://github.com/demigodliu" title="DemigodLiu">
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
</a>
@ -120,9 +135,21 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/JetSquirrel" title="JetSquirrel">
<img src="https://avatars.githubusercontent.com/u/20291255?v=4" width="42;" alt="JetSquirrel"/>
</a>
<a href="https://github.com/Lihuagreek" title="Lihuagreek">
<img src="https://avatars.githubusercontent.com/u/51040740?v=4" width="42;" alt="Lihuagreek"/>
</a>
<a href="https://github.com/mariuszmichalowski" title="Mariusz Michalowski">
<img src="https://avatars.githubusercontent.com/u/92091891?v=4" width="42;" alt="Mariusz Michalowski"/>
</a>
<a href="https://github.com/HanaNoryu" title="Noryu">
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
</a>
<a href="https://github.com/whb1998a" title="WHB">
<img src="https://avatars.githubusercontent.com/u/44045064?v=4" width="42;" alt="WHB"/>
</a>
<a href="https://github.com/y52y" title="Zyj">
<img src="https://avatars.githubusercontent.com/u/51304324?v=4" width="42;" alt="Zyj"/>
</a>
<a href="https://github.com/chyok" title="chyok">
<img src="https://avatars.githubusercontent.com/u/32629225?v=4" width="42;" alt="chyok"/>
</a>
@ -144,6 +171,9 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/hweining" title="hweining">
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
</a>
<a href="https://github.com/k983551019" title="k983551019">
<img src="https://avatars.githubusercontent.com/u/48147837?v=4" width="42;" alt="k983551019"/>
</a>
<a href="https://github.com/kdxcxs" title="kdxcxs">
<img src="https://avatars.githubusercontent.com/u/18746192?v=4" width="42;" alt="kdxcxs"/>
</a>
@ -153,8 +183,8 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/liliangrong777" title="liliangrong777">
<img src="https://avatars.githubusercontent.com/u/58727146?v=4" width="42;" alt="liliangrong777"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
<a href="https://github.com/lykjjj" title="lykjjj">
<img src="https://avatars.githubusercontent.com/u/58510058?v=4" width="42;" alt="lykjjj"/>
</a>
<a href="https://github.com/onewesong" title="onewesong">
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>

View File

@ -12,7 +12,7 @@ Quick Reference
[![Quick Reference](https://user-images.githubusercontent.com/1680273/201931931-d8559417-0a15-46af-a009-ec1e56e5b778.png)](https://jaywcjlove.github.io/reference)
<!--rehype:ignore:end-->
为开发人员分享快速参考备忘清单【速查表】。在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造中文版本的轮子使命感突然来了,为了方便自己的技术栈查阅,如果您提供一个清单,我将抽空搬运,立即撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
为开发人员分享快速参考备忘清单【速查表】。这是英文版 [Reference](https://github.com/Randy8080/reference) 的中文版本,目的是为了方便自己的技术栈查阅,如果您提供一个清单,我将抽空搬运,立即撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
## 正在建设中...
@ -25,8 +25,10 @@ Quick Reference
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
[LaTeX](./docs/latex.md)<!--rehype:style=background: rgb(0 128 128/var(\-\-bg\-opacity));&class=contributing-->
[Lua](./docs/lua.md)<!--rehype:style=background: rgb(3 3 128/var(\-\-bg\-opacity));-->
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168/var(\-\-bg\-opacity));&class=contributing-->
[Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
[Vue 3](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
[Pytorch](./docs/pytorch.md)<!--rehype:style=background: rgb(238 76 44/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python&data-info=👆看看还缺点儿什么?-->
<!--rehype:class=home-card-->
## 编程
@ -59,6 +61,8 @@ Quick Reference
[SwiftUI](./docs/swiftui.md)<!--rehype:style=background: rgb(10 127 247/var(\-\-bg\-opacity));&class=tag&data-lang=swift-->
[TOML](./docs/toml.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
[YAML](./docs/yaml.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
[Lua](./docs/lua.md)<!--rehype:style=background: rgb(3 3 128/var(\-\-bg\-opacity));-->
[Pytorch](./docs/pytorch.md)<!--rehype:style=background: rgb(43 91 132/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python&data-info=👆看看还缺点儿什么?-->
<!--rehype:class=home-card-->
## 前端
@ -77,7 +81,7 @@ Quick Reference
[RegEx 正则表达式](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
[TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198/var(\-\-bg\-opacity));-->
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
[Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
[Vue 3](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
<!--rehype:class=home-card-->
## Nodejs
@ -133,6 +137,9 @@ Quick Reference
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[Tmux](./docs/tmux.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[YUM](./docs/yum.md)<!--rehype:style=background: rgb(86 86 123/var(\-\-bg\-opacity));-->
[CMD](./docs/cmd.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[APT](./docs/apt.md)<!--rehype:style=background: rgb(30 144 255/var(\-\-bg\-opacity));-->
[tar](./docs/tar.md)<!--rehype:style=background: rgb(215 89 62/var(\-\-bg\-opacity));-->
<!--rehype:class=home-card-->
## 其它
@ -169,6 +176,15 @@ Quick Reference
<a href="https://github.com/Jack-Zhang-1314" title="fw_qaq">
<img src="https://avatars.githubusercontent.com/u/82551626?v=4" width="42;" alt="fw_qaq"/>
</a>
<a href="https://github.com/Alex-Programer" title="Alex">
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
</a>
<a href="https://github.com/expoli" title="expoli">
<img src="https://avatars.githubusercontent.com/u/31023767?v=4" width="42;" alt="expoli"/>
</a>
<a href="https://github.com/partoneplay" title="partoneplay">
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
</a>
@ -181,9 +197,15 @@ Quick Reference
<a href="https://github.com/Smartdousha" title="Anko">
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
</a>
<a href="https://github.com/Brid9e" title="Brid9e">
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Brid9e"/>
</a>
<a href="https://github.com/CharlotteZeng" title="Chart">
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="Chart"/>
</a>
<a href="https://github.com/DaiNing810" title="DaiN">
<img src="https://avatars.githubusercontent.com/u/94962339?v=4" width="42;" alt="DaiN"/>
</a>
<a href="https://github.com/demigodliu" title="DemigodLiu">
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
</a>
@ -193,9 +215,21 @@ Quick Reference
<a href="https://github.com/JetSquirrel" title="JetSquirrel">
<img src="https://avatars.githubusercontent.com/u/20291255?v=4" width="42;" alt="JetSquirrel"/>
</a>
<a href="https://github.com/Lihuagreek" title="Lihuagreek">
<img src="https://avatars.githubusercontent.com/u/51040740?v=4" width="42;" alt="Lihuagreek"/>
</a>
<a href="https://github.com/mariuszmichalowski" title="Mariusz Michalowski">
<img src="https://avatars.githubusercontent.com/u/92091891?v=4" width="42;" alt="Mariusz Michalowski"/>
</a>
<a href="https://github.com/HanaNoryu" title="Noryu">
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
</a>
<a href="https://github.com/whb1998a" title="WHB">
<img src="https://avatars.githubusercontent.com/u/44045064?v=4" width="42;" alt="WHB"/>
</a>
<a href="https://github.com/y52y" title="Zyj">
<img src="https://avatars.githubusercontent.com/u/51304324?v=4" width="42;" alt="Zyj"/>
</a>
<a href="https://github.com/chyok" title="chyok">
<img src="https://avatars.githubusercontent.com/u/32629225?v=4" width="42;" alt="chyok"/>
</a>
@ -217,6 +251,9 @@ Quick Reference
<a href="https://github.com/hweining" title="hweining">
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
</a>
<a href="https://github.com/k983551019" title="k983551019">
<img src="https://avatars.githubusercontent.com/u/48147837?v=4" width="42;" alt="k983551019"/>
</a>
<a href="https://github.com/kdxcxs" title="kdxcxs">
<img src="https://avatars.githubusercontent.com/u/18746192?v=4" width="42;" alt="kdxcxs"/>
</a>
@ -226,8 +263,8 @@ Quick Reference
<a href="https://github.com/liliangrong777" title="liliangrong777">
<img src="https://avatars.githubusercontent.com/u/58727146?v=4" width="42;" alt="liliangrong777"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
<a href="https://github.com/lykjjj" title="lykjjj">
<img src="https://avatars.githubusercontent.com/u/58510058?v=4" width="42;" alt="lykjjj"/>
</a>
<a href="https://github.com/onewesong" title="onewesong">
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>
@ -265,7 +302,6 @@ Quick Reference
如果你有资源,可以很方便部署 web 版,这非常简单,只需要克隆 gh-pages 分支代码到你的静态服务就可以了,还可以使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版。
<!--rehype:ignore:start-->
## License

View File

@ -397,6 +397,7 @@ $ ansible-pull -U <repository> [options]
另见
---
[Getting started with Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html)
[Introduction to ad hoc commands](https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html)
[Ansible cheatsheet](https://github.com/luckylittle/ansible-cheatsheet/blob/master/ansible-cheatsheet.txt)
- [Getting started with Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html)
- [Introduction to ad hoc commands](https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html)
- [Ansible cheatsheet](https://github.com/luckylittle/ansible-cheatsheet/blob/master/ansible-cheatsheet.txt)
- [Ansible Tutorial for Beginners: Ultimate Playbook & Examples](https://spacelift.io/blog/ansible-tutorial)

206
docs/apt.md Normal file
View File

@ -0,0 +1,206 @@
APT 备忘清单
===
这个 APT 快速参考备忘单显示了它的常用命令使用清单。
APT 清单查询
---
### 介绍
<!--rehype:wrap-class=row-span-2-->
APT`A`dvanced `P`ackaging `T`ools`Debian`及其派生的`Linux`软件包管理器。APT可以自动下载配置安装二进制或者源代码格式的软件包因此简化了Unix系统上管理软件的过程。APT最早被设计成`dpkg的前端`用来处理deb格式的软件包。现在经过`APT-RPM`组织修改APT已经可以安装在支持RPM的系统管理RPM包。
它结合了apt-get和apt-cache工具中最常用的命令以及选项与默认值。`apt`命令必须以具有`sudo`权限的用户运行。
命令语法格式
```bash
$ apt [ OPTIONS ] COMMAND
```
----
相关参考文献
- [APT8 官方网站](https://manpages.debian.org/unstable/apt/apt.8.en.html)
- [apt.conf(5) 官方文档](https://manpages.debian.org/unstable/apt/apt.conf.5.en.html)
- [sources.list(5) 官方文档](https://manpages.debian.org/unstable/apt/sources.list.5.en.html)
### 命令查询
子命令描述和任务,显示 apt 命令和选项。
```bash
$ apt -h or --help
# 或
$ apt
```
查看指令用法
```bash
$ man apt
```
### update
从APT存储库中获取最新索引数据。
```bash
$ sudo apt update
```
在升级或安装新软件包之前,建议始终先运行一次更新软件包索引。
### upgrade
将安装的软件包升级到最新版本,该命令不会升级那些已删除软件包的依赖。
```bash
$ sudo apt upgrade
```
升级单个软件包。
```bash
$ sudo apt upgrade package_name
```
升级整个系统,则会删除当前安装的软件包。
```bash
$ sudo apt full-upgrade
```
### install
安装软件包。
```bash
$ sudo apt install package_name
```
如果只想升级,不要安装
```bash
$ sudo apt install <package_name> --only-upgrade
```
<!--rehype:className=wrap-text -->
安装多个软件包,包名用空格分隔。
```bash
$ sudo apt install package1 package2
```
安装本地deb文件提供文件的完整路径。否则apt命令将尝试从APT存储库中检索并安装软件包。
`Deb是所有基于Debian的发行版使用的安装软件包格式`
```bash
$ sudo apt install /full/path/file.deb
```
### remove和purge
<!--rehype:wrap-class=row-span-2-->
要删除已安装的程序包你可以使用apt子命令`remove``purge`
#### remove
remove子命令将卸载指定的软件包`但可能会留下一些配置文件`
通过remove方式卸载的软件包可以通过重新安装软件包来恢复因为个人配置文件还在本地。
卸载指定的软件包
```bash
$ sudo apt remove package_name
```
指定多个软件包,以空格分隔
```bash
$ sudo apt remove package1 package2
```
#### purge
purge子命令将卸载指定的软件包和配置文件。
```bash
$ sudo apt purge package_name
```
### autoremove自动删除依赖
用于删除自动安装的包,这些包都是为了满足其他包的依赖关系,现在不再需要这些包,因为依赖关系已更改或者同时删除了需要它们的包。
```bash
$ sudo apt autoremove
```
### list
<!--rehype:wrap-class=row-span-2-->
打印所有软件包的列表,包括软件包的版本和结构的信息。
```bash
$ sudo apt list
```
要确定是否安装了指定的软件包可以使用grep命令过滤输出。
```bash
$ sudo apt list | grep package_name
```
仅列出已安装的软件包。
```bash
$ sudo apt list --installed
```
获取可升级软件包的列表。
```bash
$ sudo apt list --upgradeable
```
### 搜索查找软件包详细信息
#### search
在可用软件源列表中搜索指定的软件包。如果找到该软件包,则将返回名称与搜索词匹配的软件包。
```bash
$ sudo apt search package_name
```
#### show
显示有关给定软件包的信息,包括其依赖项、安装、下载大小、软件包可用的来源、软件包内容的描述等。
```bash
$ sudo apt show package_name
```
### edit-sources 快速换源
允许您在首选的文本编辑器中编辑`sources.list(5)` 文件,同时还提供基本的健全性检查。
首次换源可以使用`edit-sources`
```bash
$ sudo apt show edit-sources
```
换源后更新一下软件包索引。
```bash
$ sudo apt update
```
之后可以使用`select-editor`更换默认编辑器
```bash
$ sudo select-editor
```

286
docs/cmd.md Normal file
View File

@ -0,0 +1,286 @@
Cmd 备忘清单
===
cmd 快速参考备忘单含括了常用的 cmd 命令
常用操作
--------
### 磁盘操作
#### format 参数
参数 | action
:-- | :--
`/q` | 快速格式化
`/u` | 不可恢复
`/autotest` | 不提示
`/s` | 创建 MS-DOS 引导盘
#### format 示例
```shell
format c: /q /u /autotest
```
### 目录操作(一)
#### dir 参数
参数 | action
:--- | :---
`/s` | 查找子目录
`/w` | 只显示文件名
`/p` | 分页
`/a` | 显示隐藏文件
#### dir 示例
```shell
dir format.exe /s
```
<!--rehype:className=wrap-text -->
查找该盘的 `format.exe` 文件并报告位置
### 目录操作(二)
#### cd 参数
可以使用相对目录或绝对目录
参数 | action
:--- | :--
`cd …` | 进入上一个文件夹
`cd \` | 返回根目录
`cd c:\windows` | 进入 `c:\windows` 文件夹
#### md(MKDIR) 参数
参数 | action
:--- | :--
`md HELLOWORLD` | 创建 `HELLOWORLD` 目录
#### rd (RMDIR) 参数
参数 | action
:--- | :--
`rd HELLOWORLD` | 删除 `HELLOWORLD` 目录
### 文件操作
#### rmdir 参数
参数 | action
:--- | :--
`rmdir c:\qqdownload/s` | 删除 `C` 盘的 `qqdownload` 目录
#### del 参数
参数 | action
:--- | :--
`/f` | 删除只读文件
`/s` | 删除该目录及其下的所有内容
`/q` | 删除前不确认
#### del 示例
参数 | action
:--- | :--
`del c:\del /s /q` | 自动删除 c 盘的 del 目录
<!--rehype:className=style-list-->
#### copy 参数
参数 | action
:--- | :--
`copy d:\pwin98*.* c:\presetup` | 将d盘的pwin98的所有文件复制到 c 盘的 presetup 下
<!--rehype:className=style-list-->
#### attrib 参数
attrib命令可以列出或修改磁盘上文件的属性
文件属性包括文档A、只读、隐藏(H)、系统(S)
#### attrib 示例
参数 | action
:--- | :--
`attrib -h -r -s io.sys` | io.sys文件的只读、隐藏、系统属性去掉
`attrib +h +r +s autoexec.bat` | 为自动批处理文件增加以上属性
<!--rehype:className=style-list-->
### net 命令(一)
参数 | action
:--- | :--
`net use ipipc$ " " /user:" "` | 建立IPC空链接
`net use ipipc$ " " /user:" "` | 建立IPC空链接
`net use ipipc$ “密码” /user:"` | 用户名" 建立IPC非空链接
`net use h: ipc$ “密码” /user:“用户名”` | 直接登陆后映射对方C到本地为H:
`net use h: ipc$` | 登陆后映射对方C到本地为H:
`net use ipipc$ /del` | 删除IPC链接
`net use h: /del` | 删除映射对方到本地的为H:的映射
`net user 用户名 密码 /add` | 建立用户
`net user guest /active:yes` | 激活guest用户
`net user` | 查看有哪些用户
`net user 帐户名` | 查看帐户的属性
`net localgroup administrators 用户名 /add` | 把“用户”添加到管理员中使其具有管理员权限
<!--rehype:className=style-list-->
### net 命令(二)
参数 | action
:--- | :--
`net start` | 查看开启了哪些服务
`net start 服务名` | 开启服务;(如:net start telnet net start schedule)
`net stop 服务名` | 停止某服务
`net time 目标ip` | 查看对方时间
`net view` | 查看本地局域网内开启了哪些共享
`net view ip` | 查看对方局域网内开启了哪些共享
`net config` | 显示系统网络设置
`net pause 服务名` | 暂停某服务
`net send ip “文本信息”` | 向对方发信息
`net ver` | 局域网内正在使用的网络连接类型和信息
`net share` | 查看本地开启的共享
`net share ipc$ /del` | 删除ipc$共享
`net share c$ /del` | 删除C共享
`net user guest 12345` | 用guest用户登陆后用将密码改为12345
`net password 密码` | 更改系统登陆密码
<!--rehype:className=style-list-->
### ping 命令
<!--rehype:wrap-class=row-span-2 col-span-2-->
参数 | action
:--- | :--
`-d` | 使用 Socket 的 SO_DEBUG 功能
`-c<完成次数>` | 设置完成要求回应的次数
`-f` | 极限检测
`-i<间隔秒数>` | 指定收发信息的间隔时间
`-I<网络界面>` | 使用指定的网络界面送出数据包
`-l<前置载入>` | 设置在送出要求信息之前,先行发出的数据包
`-n` | 只输出数值
`-p<范本样式>` | 设置填满数据包的范本样式
`-q` | 不显示指令执行过程,开头和结尾的相关信息除外
`-r` | 忽略普通的Routing Table直接将数据包送到远端主机上
`-R` | 记录路由过程
`-s<数据包大小>` | 设置数据包的大小
`-t<存活数值>` | 设置存活数值TTL的大小
`-v` | 详细显示指令的执行过程
### tracert 命令
参数 | action
:--- | :--
`-d` | 不将地址解析成主机名
`-h maximum_hops` | 搜索目标的最大跃点数默认30
`-w timeout` | 等待每个回复的超时时间(以毫秒为单位)
`-R` | 跟踪往返行程路径(仅适用于 IPv6)
`-S srcaddr` | 要使用的源地址(仅适用于 IPv6)
`-4` | 强制使用 IPv4
`-6` | 强制使用 IPv6
### netstat 命令
参数 | action
:--- | :--
`netstat -a` | 查看开启了哪些端口,常用netstat -an
`netstat -n` | 查看端口的网络连接情况常用netstat -an
`netstat -v` | 查看正在进行的工作
`netstat -p 协议名` | 例netstat -p tcq/ip 查看某协议使用情况
`netstat -s` | 查看正在使用的所有协议使用情况
`nbtstat -A ip` | 对方136到139其中一个端口开了的话就可查看对方最近登陆的用户名
启动程序
--------
### 启动程序(一)
<!--rehype:wrap-class=row-span-3-->
参数 | action
:--- | :--
`appwiz.cpl` | 程序和功能
`calc` | 启动计算器
`certmgr.msc` | 证书管理实用程序
`charmap` | 启动字符映射表
`chkdsk.exe` | Chkdsk磁盘检查管理员身份运行命令提示符
`cleanmgr` | 打开磁盘清理工具
`cliconfg` | SQL SERVER 客户端网络实用工具
`cmstp` | 连接管理器配置文件安装程序
`compmgmt.msc` | 计算机管理
`omexp.msc` | 打开系统组件服务
`control` | 控制面版
### 启动程序(二)
<!--rehype:wrap-class=row-span-3-->
参数 | action
:--- | :--
`dcomcnfg` | 打开系统组件服务
`devmgmt.msc` | 设备管理器
`diskmgmt.msc` | 磁盘管理
`eventvwr` | 事件查看器
`explorer` | 打开资源管理器
`Firewall.cpl` | Windows防火墙
`fsmgmt.msc` | 共享文件夹管理器
`hdwwiz.cpl` | 设备管理器
`lusrmgr.msc` | 本地用户和组
`Msra` | 远程协助
`mstsc` | 远程桌面连接
`notepad` | 打开记事本
`shrpubw` | 创建共享文件夹
### 自动关机
参数 | action
:--- | :--
`shutdown -s -t 600` | 表示600秒后自动关机
`shutdown -a` | 可取消定时关机
`shutdown -r -t 600` | 表示600秒后自动重启
`rundll32 user32.dll, LockWorkStation` | 表示锁定计算机
<!--rehype:className=style-list-->
其他
--------
### (一)
参数 | action
:--- | :--
`ipconfig (winipcfg)` | 查看本地ip可加/all
`kill -F 进程名` | 加-F参数后强制结束某进程
`del -F 文件名` | 加-F参数可删除只读文件
`move 源路径文件 目的路径` | 移动文件,可修改文件名
`fc one.txt two.txt > 3st.txt` | 对比文件并输出到3st.txt
`finger username @host` | 查看最近用户登陆
`telnet` | 进入本机的telnet
`telnet ip 端口` | 远程登陆服务器,默认端口为23
<!--rehype:className=style-list-->
### (二)
参数 | action
:--- | :--
`copy c:srv.exe ipadmin$` | 复制本地c:srv.exe到对方的admin下
`set` | 显示当前所有的环境变量
`set 环境变量名称=变量的字符` | 添加环境变量
`set p(或其它字符)` | 显示出当前以字符p(或其它字符)开头的所有环境变量
`pause` | 暂停批处理程序,并显示出:请按任意键继续…
`echo on/off` | 打开或关闭echo仅用echo不加参数则显示当前echo设置
`echo 信息` | 在屏幕上显示出信息
<!--rehype:className=style-list-->
### (三)
参数 | action
:--- | :--
`echo 信息 >> pass.txt` | 将"信息"保存到pass.txt文件中
`findstr “Hello” aa.txt` | 在aa.txt文件中寻找字符串hello
`find 文件名` | 查找某文件
`regedit /s` | 注册表文件名 导入注册表;参数/S指安静模式导入无任何提示
`regedit /e` | 注册表文件名 导出注册表
`cacls 文件名` | 查看文件的访问用户权限列表
`REM 文本内容` | 在批处理文件中添加注解
`netsh` | 查看或更改本地网络配置情况
<!--rehype:className=style-list-->

View File

@ -1423,6 +1423,16 @@ div {
通过样式来控制一个元素 `div` 是否可以编辑
### 定义容器的长宽比
```
div {
aspect-ratio: 1/1
}
```
属性 [aspect-ratio](https://developer.mozilla.org/zh-CN/docs/Web/CSS/aspect-ratio) 可以非常容易的定义一个容器的长宽比
另见
---------

View File

@ -207,8 +207,11 @@ temp?
`EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口
<!--rehype:class=auto-wrap-->
Dockerfile 示例
----
<!--rehype:body-class=cols-2-->
### 服务静态网站的最小 Docker 镜像
<!--rehype:wrap-class=col-span-2-->
```dockerfile
FROM lipanski/docker-static-website:latest
@ -223,11 +226,31 @@ COPY ./ .
FROM lipanski/docker-static-website:latest
COPY . .
CMD ["/busybox", "httpd", "-f", "-v", "-p", "3000", "-c", "httpd.conf"]
CMD ["/busybox","httpd","-f","-v","-p","3000","-c","httpd.conf"]
```
缩小镜像过程[查看原文](https://lipanski.com/posts/smallest-docker-image-static-website),镜像 [Dockerfile 源码](https://github.com/lipanski/docker-static-website)。
### Docker 镜像多阶段构建
```dockerfile
FROM golang:alpine as builder
RUN apk --no-cache add git
WORKDIR /go/src/github.com/go/helloworld/
RUN go get -d -v github.com/go-sql-driver/mysql
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM alpine:latest as prod
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/go/helloworld/app .
CMD ["./app"]
```
<!--rehype:className=wrap-text -->
使用多阶段构建能将构建依赖留在 builder 镜像中,只将编译完成后的二进制文件拷贝到运行环境中,大大减少镜像体积。
## 也可以看看
- [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) _(docker.com)_

View File

@ -229,6 +229,25 @@ $ echo '42' | jq '"The input was \(.), which is one less than \(.+1)"'
```
<!--rehype:className=wrap-text -->
### 字符串转 JSON 数组
```bash
$ echo 'a b c d' | jq -R 'split(" ")'
```
<!--rehype:className=wrap-text -->
输出结果
```json
[
"a",
"b",
"c",
"d"
]
```
<!--rehype:className=wrap-text -->
另见
----

View File

@ -90,6 +90,21 @@ Supported Functions
`\right` | `\bigg` | `\biggl` | `\biggm` | `\biggr`
`` | `\Bigg` | `\Biggl` | `\Biggm` | `\Biggr`
### 希腊和希伯来字母 Greek and Hebrew letters
<!--rehype:wrap-class=col-span-3-->
预览 | 方法 | 预览 | 方法 | 预览 | 方法 | 预览| 方法 | 预览 | 方法 | 预览 | 方法
:- | :- | :- | :- | :- | :- | :- | :- | :- | :- | :- | :-
| `KaTex:\alpha` | <pur>`\alpha`</pur> | `KaTex:\kappa` | <pur>`\kappa`</pur> | `KaTex:\psi` | <pur>`\psi`</pur> | `KaTex:\digamma` | <pur>`\digamma`</pur> | `KaTex:\Delta` | <pur>`\Delta`</pur> | `KaTex:\Theta` | <pur>`\Theta`</pur> |
| `KaTex:\beta` | <pur>`\beta`</pur> | `KaTex:\lambda` | <pur>`\lambda`</pur> | `KaTex:\rho` | <pur>`\rho`</pur> | `KaTex:\varepsilon` | <pur>`\varepsilon`</pur> | `KaTex:\Gamma` | <pur>`\Gamma`</pur> | `KaTex:\Upsilon` | <pur>`\Upsilon`</pur> |
| `KaTex:\chi` | <pur>`\chi`</pur> | `KaTex:\mu` | <pur>`\mu`</pur> | `KaTex:\sigma` | <pur>`\sigma`</pur> | `KaTex:\varkappa` | <pur>`\varkappa`</pur> | `KaTex:\Lambda` | <pur>`\Lambda`</pur> | `KaTex:\Xi` | <pur>`\Xi`</pur> |
| `KaTex:\delta` | <pur>`\delta`</pur> | `KaTex:\nu` | <pur>`\nu`</pur> | `KaTex:\tau` | <pur>`\tau`</pur> | `KaTex:\varphi` | <pur>`\varphi`</pur> | `KaTex:\Omega` | <pur>`\Omega`</pur> | |
| `KaTex:\epsilon` | <pur>`\epsilon`</pur> | `KaTex:o` | <pur>`o`</pur> | `KaTex:\theta` | <pur>`\theta`</pur> | `KaTex:\varpi` | <pur>`\varpi`</pur> | `KaTex:\Phi` | <pur>`\Phi`</pur> | `KaTex:\aleph` | <pur>`\aleph`</pur> |
| `KaTex:\eta` | <pur>`\eta`</pur> | `KaTex:\omega` | <pur>`\omega`</pur> | `KaTex:\upsilon` | <pur>`\upsilon`</pur> | `KaTex:\varrho` | <pur>`\varrho`</pur> | `KaTex:\Pi` | <pur>`\Pi`</pur> | `KaTex:\beth` | <pur>`\beth`</pur> |
| `KaTex:\gamma` | <pur>`\gamma`</pur> | `KaTex:\phi` | <pur>`\phi`</pur> | `KaTex:\xi` | <pur>`\xi`</pur> | `KaTex:\varsigma` | <pur>`\varsigma`</pur> | `KaTex:\Psi` | <pur>`\Psi`</pur> | `KaTex:\daleth` | <pur>`\daleth`</pur> |
| `KaTex:\iota` | <pur>`\iota`</pur> | `KaTex:\pi` | <pur>`\pi`</pur> | `KaTex:\zeta` | <pur>`\zeta`</pur> | `KaTex:\vartheta` | <pur>`\vartheta`</pur> | `KaTex:\Sigma` | <pur>`\Sigma`</pur> | `KaTex:\gimel` | <pur>`\gimel`</pur> |
<!--rehype:className=show-header left-align-->
### 分隔符 Delimiters
<!--rehype:wrap-class=col-span-3-->

435
docs/lua.md Normal file
View File

@ -0,0 +1,435 @@
Lua 备忘清单
===
包含最重要概念、函数、方法等的 [Lua](http://www.lua.org) 备忘单。 初学者的完整快速参考。
入门
---
### 下载
macos 使用 homebrew 下载
```bash
$ brew install lua
```
#### 其它下载方式
* [下载地址](https://luabinaries.sourceforge.net/download.html) _(sourceforge.net)_
```bash
# 查看 lua 是否安装成功
$ lua -v
```
### hello world
```lua
#!/usr/bin/env lua
print("Hello World!")
```
#### 运行
```bash
$ lua ./hello.lua
# 或者也可以像 bash 脚本一样
$ chmod +x hello.lua
./hello.lua
```
### 注释
#### 单行注释
```lua
-- 以两个减号开始
```
#### 多行注释
多行注释以 `--[[` 开头, 以 `]]` 结尾
```lua
--[[
]]
```
<!--rehype:className=wrap-text -->
### type() 函数
使用 `type()` 函数可以判断变量或者值的类型
```lua
print(type(true)) -- boolean
print(type(nil)) -- nil
```
### number
Lua 默认只有一种 number 类型 double (双精度) 类型
```lua
print(10)
print(0.3)
print(2e + 10)
```
### string
<!--rehype:wrap-class=row-span-2-->
```lua
-- 使用 ''
local str1 = 'str1'
-- 使用 ""
local str2 = "str2"
```
#### `[[]]`
使用 `[[]]` 跨行表示多个字符串
```lua
local html = [[
<html>
<head></head>
<body>
<a href="https://www.twle.cn/">简单编程</a>
</body>
</html>
]]
print(html)
```
#### 字符串连接(`..`)
```lua
print("a" .. 'b')
-- ab
print(157 .. 428)
-- 157428
```
#### 字符串长度(`#`)
```lua
print(#"string") -- 6
```
### table
```lua
local table = {}
```
#### 迭代 table
默认的初始索引会从 1 开始
```lua
local array = { "apple", "pear", "orange", "grape" }
print(array[1]) -- apple
for k, v in pairs(array) do
print(k .. " : " .. v)
end
-- 1 : apple
-- 2 : pear
-- 3 : orange
-- 4 : grape
```
#### 指定键
```lua
local array = {}
array.one = "apple"
array["two"] = "peach"
print(array.one) -- apple
print(array.two) -- peach
```
### 变量
#### 默认值
变量的默认值均是 nil
```lua
#!/usr/bin/env lua
print(b) -- nil
```
#### 全局和局部变量
Lua 中的变量全是全局变量,那怕是语句块或是函数里,除非用 local 显式声明为局部变量
```lua
#!/usr/bin/env lua
function main()
local b = 12
a = 23
end
main()
print(a) -- 23
print(b) -- nil
```
<!--rehype:className=wrap-text -->
### 赋值
<!--rehype:wrap-class=row-span-2-->
```lua
a = "hello " .. "world" -- 改变 变量
t.n = t.n + 1 -- 改变 table
```
---
```lua
-- 给多个变量赋值
a, b = 10, 2*a --> a=10; b=20
```
#### 交换变量
```lua
local x, y = 1, 3
x, y = y, x
print(x, y) -- 3, 1
```
---
```lua
local tab = {}
tab.one = 2
tab.two = 1
tab["one"], tab["two"] = tab.two, tab.one
print(tab.one, tab.two) -- 1 2
```
#### 赋值个数不一致
* 如果变量个数**大于**值的个数,按变量个数补足 nil
```lua
a, b, c = 1, 3
print(a,b,c) --> 1 3 nil
```
* 如果变量个数**小于**值的个数,多余的值会被忽略
```lua
a = 1
local a, b = a, a + 1, a + 2
print(a, b) --> 1 2
```
<!--rehype:className=style-round-->
<!--rehype:className=wrap-text -->
### 运算符
:- | :-
:- | :-
\+ | 加法
\- | 减法
\* | 乘法
\/ | 除法
\% | 取余,求出除法的余数
\^ | 乘幂,计算次方
\- | 负号,取负值
```lua
local a, b = 4, 3
print(a + b) -- 7
print(a - b) -- 1
print(a / b) -- 1.3333333333333
print(a * b) -- 12
print(a % b) -- 1
print(a ^ b) -- 64.0
```
### 类型转换
* 在算术运算中string 类型会尝试自动转换为 number 时
```lua
local a, b, c = "str", "1", "2"
-- print(a + b) -- error
print(b + c) -- 3
```
* number 类型使用 `..` 会自动转换为 string
```lua
local a, b = 1, 2
print(type(a .. b))
```
* 其它方式的转换
```lua
print(type(tostring(12))) -- string
print(type(tonumber("12"))) -- number
```
<!--rehype:className=style-round-->
<!--rehype:className=wrap-text -->
条件语句
---
### 运算符
<!--rehype:wrap-class=row-span-2-->
#### 关系运算符
符号 | 含义
:- | :-
`==` | 等于
`~=` | 不等于
`>` | 大于
`<` | 小于
`>=` | 大于等于
`<=` | 小于等于
<!--rehype:className=show-header-->
```lua
local a, b = 4, 3
print(a < b) -- false
print(a <= b) -- false
print(a == b) -- false
print(a ~= b) -- true
print(a > b) -- true
print(a >= b)-- true
```
#### 逻辑运算符
符号 | 含义
:- | :-
`and` | 逻辑与
`or` | 逻辑或操作符
`not` | 逻辑非操作符
<!--rehype:className=show-header-->
```lua
local a, b = true, false
print(a and b) -- false
print(a and not b) -- true
print(a or b) -- true
```
### while 循环
```lua
local num = 1
while (num < 5) do
print("num 的值为:", num)
num = num + 1
end
```
### if 语句
<!--rehype:wrap-class=row-span-2-->
```lua
if(0)
then
print("0 为 true")
end
```
#### if .. elseif() .. else
```lua
local age = 27;
if (age < 18)
then
print("age 小于 18")
elseif (age < 25)
then
print("age 小于 25")
elseif (age < 30)
then
print("age 小于 30")
else
print("age 大于 30")
end
print("age 的值为 :", age)
```
<red>注意: </red>`Lua` 中 `0` 为 `true`,但是 `Lua` 中的 `nil` 可以当作 `false`
### for 循环
```lua
for i = 10, 1, -1 do
print(i)
end
```
* lua 中的 for 循环从参数 1 变化到参数 2每次变化以参数 3 为步长递增 i并执行一次表达式
* 参数三,是可选的,如果不指定,默认是 1
* 参数二只会在一开始求值,其后不会再进行运算
```lua
local f = function(x)
print("in f(x) ")
return x * 2
end
for i = 1, f(5) do
print(i)
end
```
<!--rehype:className=style-round wrap-text-->
### repeat...until 循环
```lua
local num = 11
repeat
print("num 的值为: ", num)
num = num + 1
until (num > 10)
-- num 的值为11
```
`repeat...until` 循环的条件语句在当前循环结束后判断
### break
```lua
local num = 11
repeat
print("num 的值为: ", num)
num = num + 1
if (num > 15) then
break
end
until (num > 20)
```
另见
----
* [Lua 官网](http://www.lua.org) _(lua.org)_
* [luatos](https://wiki.luatos.com/luaGuide/introduction.html) _(wiki.luatos.com)_
* [Lua 教程](https://www.twle.cn/l/yufei/lua53/lua-basic-index.html) _(twle.cn)_

263
docs/pytorch.md Normal file
View File

@ -0,0 +1,263 @@
Pytorch 备忘清单
===
Pytorch 是一种开源机器学习框架,可加速从研究原型设计到生产部署的过程,备忘单是 官网
备忘清单为您提供了 [Pytorch](https://pytorch.org/) 基本语法和初步应用参考
入门
-----
### 介绍
- [Pytorch 官网](https://pytorch.org/) _(pytorch.org)_
- [Pytorch 官方备忘清单](https://pytorch.org/tutorials/beginner/ptcheat.html) _(pytorch.org)_
### 认识 Pytorch
```python
from __future__ import print_function
import torch
x = torch.empty(5, 3)
>>> print(x)
tensor([
[2.4835e+27, 2.5428e+30, 1.0877e-19],
[1.5163e+23, 2.2012e+12, 3.7899e+22],
[5.2480e+05, 1.0175e+31, 9.7056e+24],
[1.6283e+32, 3.7913e+22, 3.9653e+28],
[1.0876e-19, 6.2027e+26, 2.3685e+21]
])
```
<!--rehype:className=wrap-text-->
Tensors 张量: 张量的概念类似于Numpy中的ndarray数据结构, 最大的区别在于Tensor可以利用GPU的加速功能.
### 创建一个全零矩阵
```python
x = torch.zeros(5, 3, dtype=torch.long)
>>> print(x)
tensor([[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
```
创建一个全零矩阵并可指定数据元素的类型为long
### 数据创建张量
```python
x = torch.tensor([2.5, 3.5])
>>> print(x)
tensor([2.5000, 3.3000])
```
Pytorch 的基本语法
---------------
### 加法操作(1)
```python
y = torch.rand(5, 3)
>>> print(x + y)
tensor([[ 1.6978, -1.6979, 0.3093],
[ 0.4953, 0.3954, 0.0595],
[-0.9540, 0.3353, 0.1251],
[ 0.6883, 0.9775, 1.1764],
[ 2.6784, 0.1209, 1.5542]])
```
### 加法操作(2)
```python
>>> print(torch.add(x, y))
tensor([[ 1.6978, -1.6979, 0.3093],
[ 0.4953, 0.3954, 0.0595],
[-0.9540, 0.3353, 0.1251],
[ 0.6883, 0.9775, 1.1764],
[ 2.6784, 0.1209, 1.5542]])
```
### 加法操作(3)
```python
# 提前设定一个空的张量
result = torch.empty(5, 3)
# 将空的张量作为加法的结果存储张量
torch.add(x, y, out=result)
>>> print(result)
tensor([[ 1.6978, -1.6979, 0.3093],
[ 0.4953, 0.3954, 0.0595],
[-0.9540, 0.3353, 0.1251],
[ 0.6883, 0.9775, 1.1764],
[ 2.6784, 0.1209, 1.5542]])
```
### 加法操作(4)
```python
y.add_(x)
>>> print(y)
tensor([[ 1.6978, -1.6979, 0.3093],
[ 0.4953, 0.3954, 0.0595],
[-0.9540, 0.3353, 0.1251],
[ 0.6883, 0.9775, 1.1764],
[ 2.6784, 0.1209, 1.5542]])
```
注意: 所有 `in-place` 的操作函数都有一个下划线的后缀。
比如 `x.copy_(y)`, `x.add_(y)`, 都会直接改变x的值
### 张量操作
```python
>>> print(x[:, 1])
tensor([-2.0902, -0.4489, -0.1441, 0.8035, -0.8341])
```
<!--rehype:className=wrap-text-->
### 张量形状
```python
x = torch.randn(4, 4)
# tensor.view()操作需要保证数据元素的总数量不变
y = x.view(16)
# -1代表自动匹配个数
z = x.view(-1, 8)
>>> print(x.size(), y.size(), z.size())
torch.Size([4, 4]) torch.Size([16]) torch.Size([2, 8])
```
<!--rehype:className=wrap-text-->
### 取张量元素
```python
x = torch.randn(1)
>>> print(x)
>>> print(x.item())
tensor([-0.3531])
-0.3530771732330322
```
### Torch Tensor 和 Numpy array互换
```python
a = torch.ones(5)
>>> print(a)
tensor([1., 1., 1., 1., 1.])
```
Torch Tensor和Numpy array共享底层的内存空间, 因此改变其中一个的值, 另一个也会随之被改变
### Torch Tensor 转换为 Numpy array
```python
b = a.numpy()
>>> print(b)
[1. 1. 1. 1. 1.]
```
### Numpy array转换为Torch Tensor
```python
import numpy as np
a = np.ones(5)
b = torch.from_numpy(a)
np.add(a, 1, out=a)
>>> print(a)
>>> print(b)
[2. 2. 2. 2. 2.]
tensor([2., 2., 2., 2., 2.], dtype=torch.float64)
```
<!--rehype:className=wrap-text-->
注意: 所有在CPU上的Tensors, 除了CharTensor, 都可以转换为Numpy array并可以反向转换.
导入 Imports
---
### 一般
```python
# 根包
import torch
# 数据集表示和加载
from torch.utils.data import Dataset, DataLoader
```
<!--rehype:className=wrap-text-->
### 神经网络 API
```python
# 计算图
import torch.autograd as autograd
# 计算图中的张量节点
from torch import Tensor
# 神经网络
import torch.nn as nn
# 层、激活等
import torch.nn.functional as F
# 优化器,例如 梯度下降、ADAM等
import torch.optim as optim
# 混合前端装饰器和跟踪 jit
from torch.jit import script, trace
```
### Torchscript 和 JIT
```python
torch.jit.trace()
```
使用你的模块或函数和一个例子,数据输入,并追溯计算步骤,数据在模型中前进时遇到的情况
```python
@script
```
装饰器用于指示被跟踪代码中的数据相关控制流
### ONNX
```python
torch.onnx.export(model, dummy data, xxxx.proto)
# 导出 ONNX 格式
# 使用经过训练的模型模型dummy
# 数据和所需的文件名
model = onnx.load("alexnet.proto")
# 加载 ONNX 模型
onnx.checker.check_model(model)
# 检查模型IT 是否结构良好
onnx.helper.printable_graph(model.graph)
# 打印一个人类可读的,图的表示
```
<!--rehype:className=wrap-text-->
### Vision
```python
# 视觉数据集,架构 & 变换
from torchvision import datasets, models, transforms
# 组合转换
import torchvision.transforms as transforms
```
<!--rehype:className=wrap-text-->
### 分布式训练
```python
# 分布式通信
import torch.distributed as dist
# 内存共享进程
from torch.multiprocessing import Process
```
<!--rehype:className=wrap-text-->
另见
---
- [Pytorch 官网](https://pytorch.org/) _(pytorch.org)_
- [Pytorch 官方备忘清单](https://pytorch.org/tutorials/beginner/ptcheat.html) _(pytorch.org)_

View File

@ -190,7 +190,7 @@ let isMorning: Bool = true
常量是不可变的。它们的值不能改变:
```swift
numberOfToys: Int = 8
let numberOfToys: Int = 8
numberOfToys += 1
// ❌ 错误numberOfToys 不可变
```

221
docs/tar.md Normal file
View File

@ -0,0 +1,221 @@
tar 备忘清单
===
这是 tar 常用命令的快速参考备忘单。
入门
----
### 介绍
在Linux平台上`tar` 命令是主要的归档实用程序。了解各种 `tar` 命令选项将帮助您掌握归档文件操作。`tar` 代表磁带存档。
#### 语法
```shell
tar [-ABcdgGhiklmMoOpPrRsStuUvwWxzZ][-C <目的目录>][-f <备份文件>][--delete][--totals][文件或目录...]
```
<!--rehype:className=wrap-text -->
以前 unix 系统管理员使用 `tar` 执行磁带机备份。`tar` 命令用于获取文件和目录的集合并生成高度压缩的归档文件在Linux中通常称为 `tarball``tar``gzip``bzip`
### 选项
:- | -
:- | -
`-c` | 建立新的备份文件
`-C` | 切换到指定的目录
`-d` | 对比备份文件内和文件系统上的文件的差异
`-x` | 解压缩归档文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
`-t` | 查看归档文件内容
`-j` | 通过 bzip2 指令处理备份文件
`-z` | 通过 gzip 指令处理备份文件
`-r` | 向现有存档文件追加或更新文件或目录
`-W` | 验证归档文件
`--totals` | 备份文件建立后,列出文件大小
`--delete` | 从备份文件中删除指定的文件
`--wildcards` | 在 unix tar 命令中指定匹配模式
### 创建一个 tar 格式的压缩文件
在当前工作目录的 `/home/cyberpunk/testdir` 目录下创建一个名为 `archive.tar``tar` 归档文件:
```shell
tar -cvf archive.tar /home/cyberpunk/testdir/
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.sh
/home/cyberpunk/testdir/file3.tar
```
本例中使用的选项有:
:- | -
:- | -
`-c` | 建立新的备份文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
### 创建压缩后的 `tar.gz` 存档文件
要创建一个压缩的 `gzip` 归档文件,我们需要使用选项 `z`
```shell
tar cvzf compressedArchive.tar.gz /home/cyberpunk/testdir
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.jpg
/home/cyberpunk/testdir/file3.png
```
本例中使用的选项有:
:- | -
:- | -
`-c` | 建立新的备份文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
`-z` | 通过 `gzip` 指令处理备份文件
### 生成压缩率更高的 `tar.bz2` 文件
`tar``bz2` 压缩,可以创建比 `gzip` 文件小的归档。`Bz2` 模式执行归档压缩和解压所需的时间比 `gzip` 模式多。通常,这个时间差可以忽略不计,但如果文件非常打,或者是文件数量非常多,那么时间差就会非常大。
```shell
tar cvfj Archive.tar.bz2 /home/cyberpunk/testdir
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.txt
/home/cyberpunk/testdir/file3.txt
```
本例中使用的选项有:
:- | -
:- | -
`-c` | 建立新的备份文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
`-j` | 通过 bzip2 指令处理备份文件
### 解压缩 tar 文件
要解压缩(提取)一个tar文件`x` (提取)选项传递给该命令
使用不带 `-C` 选项的命令将在当前工作目录中提取存档。`-C` 选项告诉命令在哪里提取存档文件。
```shell
tar -xvf Archive.tar -C /home/cyberpunk/testdir/
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.txt
/home/cyberpunk/testdir/file3.txt
```
本例中使用的选项有:
:- | -
:- | -
`-x` | 解压缩归档文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
### 解压缩 tar.gz 文件
小知识:使用 `tar` 命令创建的所有归档文件,都可以以相同的方式提取。
```shell
tar -xvf Archive.tar.gz
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.txt
/home/cyberpunk/testdir/file3.txt
```
本例中使用的选项有:
:- | -
:- | -
`-x` | 解压缩归档文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
### 解压缩 tar.bz2 文件
小知识:使用 `tar` 命令创建的所有归档文件,都可以以相同的方式提取。
```shell
tar -xvf Archive.tar.bz2
/home/cyberpunk/testdir/
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.txt
/home/cyberpunk/testdir/file3.txt
```
本例中使用的选项有:
:- | -
:- | -
`-x` | 解压缩归档文件
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
### 列出归档内容
<!--rehype:wrap-class=col-span-1 row-span-2-->
使用 `t` 选项列出 `tar` 归档文件的内容:
```shell
# tar -tvf uploadprogress.tar
-rwxr--r-- root/root 1111 2014-10-19 12:33:42 file1.txt
-rwxr--r-- root/root 1111 2014-10-19 12:33:42 file2.txt
-rwxr--r-- root/root 1111 2014-10-19 12:33:42 file3.txt
-rwxr--r-- root/root 1111 2014-10-19 12:33:42 file4.txt
```
本例中使用的选项有:
:- | -
:- | -
`-t` | 查看归档文件内容
`-v` | 显示指令执行过程
`-f` | 指定归档文件的文件名
### 从 tar 归档文件中提取单个文件
```shell
tar --extract --file=archive.tar file1.txt
file1.txt
```
### 从 tar 归档文件中提取多个文件
```shell
tar -xvf Archive.tar "file 1" "file 2"
```
### 使用通配符提取文件组
```shell
# tar -xvf Archive.tar --wildcards *.txt'
/home/cyberpunk/testdir/file1.txt
/home/cyberpunk/testdir/file2.txt
/home/cyberpunk/testdir/file3.txt
```
### 添加文件或目录到 tar 存档中
要向现有的 `tar` 文件中添加文件或目录,可以使用 `r` 选项。例如,我们将 `xyz.txt` 文件和 `php` 目录添加到现有的 `tecmint-14-09-12.tar` 归档文件中。
```shell
# tar -rvf Archive.tar xyz.txt #add file
or
# tar -rvf Archive.tar php # add directory
```
另见
----
[Linux Tar Commands Cheatsheet](https://neverendingsecurity.wordpress.com/2015/04/13/linux-tar-commands-cheatsheet/)

View File

@ -229,6 +229,7 @@ data() {
<!-- 简写 -->
<a @click="doSomething"> ... </a>
```
<!--rehype:className=wrap-text-->
### 动态参数
@ -331,7 +332,6 @@ export default defineComponent({
```html {1}
<script setup>
// setup语法糖用于简化代码尤其是当需要暴露的状态和方法越来越多时
import { reactive } from 'vue';
const state = reactive({ count: 0 })
@ -348,6 +348,8 @@ function increment() {
</template>
```
**`setup`** 语法糖用于简化代码,尤其是当需要暴露的状态和方法越来越多时
### 用 `ref()` 定义响应式变量
```js
@ -419,6 +421,201 @@ export default defineComponent({
},
});
```
### 响应式样式
```js
<script setup>
import { ref } from 'vue'
const open = ref(false);
</script>
<template>
<button @click="open = !open">Toggle</button>
<div>Hello Vue!</div>
</template>
<style scope>
div{
transition: height 0.1s linear;
overflow: hidden;
height: v-bind(open ? '30px' : '0px');
}
</style>
```
响应式进阶 —— watch和computed
---
### 监听状态
```js
<script setup>
import { ref, watch } from 'vue';
const count = ref(0)
const isEvent = ref(false)
function increment() {
state.count++
}
watch(count, function() {
isEvent.value = count.value % 2 === 0
})
</script>
<template>
<button @click="increment">
{{ count }}
</button>
<p>is event: {{ isEvent ? 'yes' : 'no' }}</p>
</template>
```
### 立即监听状态
```js
watch(count, function() {
isEvent.value = count.value % 2 === 0
}, {
// 上例中的 watch 不会立即执行,导致 isEvent 状态的初始值不准确。配置立即执行,会在一开始的时候立即执行一次
immediate: true
})
```
### 计算状态
```js
<script setup>
import { ref, computed } from 'vue';
const text = ref('')
// computed 的回调函数里,会根据已有并用到的状态计算出新的状态
const capital = computed(function(){
return text.value.toUpperCase();
})
</script>
<template>
<input v-model="text" />
<p>to capital: {{ capital }}</p>
</template>
```
组件通信
---
### defineProps
```js
<script setup>
import { defineProps } from 'vue';
// 这里可以将 `username` 解构出来,但是一旦解构出来再使用,就不具备响应式能力
defineProps({
username: String
})
</script>
<template>
<p>username: {{ username }}</p>
</template>
```
子组件定义需要的参数
```js
<script setup>
const username = 'vue'
</script>
<template>
<children :username="username" />
</template>
```
父组件参入参数
### defineEmits
```js
<script setup>
import { defineEmits, ref } from 'vue';
const emit = defineEmits(['search'])
const keyword = ref('')
const onSearch = function() {
emit('search', keyword.value)
}
</script>
<template>
<input v-model="keyword" />
<button @click="onSearch">search</button>
</template>
```
子组件定义支持 `emit` 的函数
```js
<script setup>
const onSearch = function(keyword){
console.log(keyword)
}
</script>
<template>
<children @search="onSearch" />
</template>
```
父组件绑定子组件定义的事件
### defineExpose
```js
<script setup>
import { defineExpose, ref } from 'vue';
const keyword = ref('')
const onSearch = function() {
console.log(keyword.value)
}
defineExpose({ onSearch })
</script>
<template>
<input v-model="keyword" />
</template>
```
子组件对父组件暴露方法
```js
<script setup>
import { ref } from 'vue'
const childrenRef = ref(null)
const onSearch = function(){
childrenRef.value.onSearch()
}
</script>
<template>
<children ref='childrenRef' />
<button @click="onSearch">search</button>
</template>
```
父组件调用子组件的方法
<!--rehype:className=wrap-text -->
API 参考

View File

@ -17,12 +17,14 @@ Vue 是一套用于构建用户界面的渐进式框架
注意Vue 2.x 版本对应 Vue Router 3.x 路由版本
#### 快速创建 **Vue** 项目 ([Vue CLI](https://cli.vuejs.org/zh/guide/creating-a-project.html))
#### 快速创建 **Vue** 项目
```bash
npx @vue/cli create hello-world
```
参考: [Vue CLI](https://cli.vuejs.org/zh/guide/creating-a-project.html) 创建一个项目
### 声明式渲染
```html
@ -655,6 +657,8 @@ Jane Doe
<p v-else>No todos left!</p>
```
注意: `v-for` 和 `v-if` 不推荐一起使用[参考官方文档](https://v2.cn.vuejs.org/v2/guide/conditional.html#v-if-与-v-for-一起使用)
### 组件上使用 v-for
```html

View File

@ -1,6 +1,6 @@
{
"name": "@wcj/reference",
"version": "1.22.0",
"version": "1.23.0",
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
"author": "jaywcjlove",
"license": "MIT",

4
scripts/assets/cmd.svg Normal file
View File

@ -0,0 +1,4 @@
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="m10.875 7 2.008 5h-.711l-2.008-5h.711zm-5.125.594c-.276 0-.526.041-.75.125a1.542 1.542 0 0 0-.578.375c-.162.166-.287.37-.375.61a2.364 2.364 0 0 0-.133.827c0 .287.04.547.117.781.078.235.196.433.352.594.156.162.346.29.57.383.224.094.48.138.766.133a2.63 2.63 0 0 0 .992-.195l.125.484a1.998 1.998 0 0 1-.492.148 4.381 4.381 0 0 1-.75.07 2.61 2.61 0 0 1-.914-.156 2.207 2.207 0 0 1-.742-.453 1.878 1.878 0 0 1-.485-.742 3.204 3.204 0 0 1-.18-1.023c0-.365.06-.698.18-1 .12-.302.287-.563.5-.782.214-.218.471-.388.774-.507a2.69 2.69 0 0 1 1-.18c.296 0 .536.023.718.07.183.047.315.094.399.14l-.149.493a1.85 1.85 0 0 0-.406-.14 2.386 2.386 0 0 0-.539-.055zM8 8h1v1H8V8zm0 2h1v1H8v-1z"/>
<path d="M15.5 1H.5l-.5.5v13l.5.5h15l.5-.5v-13l-.5-.5zM15 14H1V5h14v9zm0-10H1V2h14v2z"/>
</svg>

After

Width:  |  Height:  |  Size: 892 B

3
scripts/assets/lua.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 32 32" height="1em" width="1em">
<path d="m.505 13.839-.36-.052c-.067.459-.109.927-.135 1.391l.364.02c.027-.452.068-.911.131-1.359zm5.011-9.454-.245-.271c-.344.307-.683.635-.995.973l.265.256c.313-.333.636-.656.975-.959zm2.177-1.64-.199-.313c-.391.251-.781.516-1.145.792l.219.292a14.89 14.89 0 0 1 1.125-.771zM2.432 24.489c.245.396.511.781.792 1.151l.292-.219a15.077 15.077 0 0 1-.771-1.124zm-.927-2.62-.344.141c.172.421.365.844.579 1.255l.005.016.328-.167-.011-.016a15.065 15.065 0 0 1-.557-1.229zM.396 12.412l.359.083c.105-.443.224-.885.365-1.312l-.349-.115a15.9 15.9 0 0 0-.375 1.344zm-.032 4.151L0 16.574c.016.463.052.932.109 1.391l.364-.043a14.992 14.992 0 0 1-.109-1.359zm-.02 2.781c.093.453.213.907.349 1.349l.348-.105c-.129-.437-.244-.88-.344-1.323zM15.432.364 15.416 0c-.463.016-.932.052-1.389.109l.047.364c.448-.057.905-.093 1.359-.109zm15.532 11.057c.129.433.244.881.339 1.324l.359-.079a14.795 14.795 0 0 0-.349-1.355zm-7.469-9.566a15.542 15.542 0 0 0-1.26-.6l-.147.333c.423.177.833.376 1.235.589zM20.921.76a17.402 17.402 0 0 0-1.343-.364l-.084.353c.443.105.885.224 1.317.365zM8.901 2.063c.396-.203.807-.391 1.219-.557l-.141-.344a15.88 15.88 0 0 0-1.244.573l-.021.011.167.328zm22.735 13.39.369-.016a21.153 21.153 0 0 0-.109-1.396l-.365.047c.053.448.089.907.105 1.365zM18.203.14a15.693 15.693 0 0 0-1.391-.129l-.015.364c.453.021.911.068 1.359.131zm-5.479.563-.079-.359c-.452.093-.905.213-1.348.349l.109.348c.432-.129.875-.244 1.317-.339zM2.563 7.292l.307.197c.245-.375.511-.749.787-1.109l-.287-.229c-.287.371-.557.756-.807 1.141zM1.255 9.755l.339.147c.177-.417.376-.833.589-1.235l-.328-.172c-.215.412-.417.833-.6 1.26zm23.042 19.5.192.313c.396-.245.781-.511 1.151-.792l-.219-.292c-.359.271-.739.537-1.124.771zm4.031-3.63.292.229c.287-.365.557-.751.807-1.141l-.301-.197c-.251.38-.516.749-.797 1.109zm-1.855 1.995.245.271c.344-.307.683-.64.995-.973l-.265-.256c-.308.333-.641.651-.975.959zm3.339-4.281.324.172c.219-.412.421-.833.599-1.26l-.339-.141c-.177.417-.369.828-.584 1.229zm1.677-5.167.365.052c.063-.464.109-.927.135-1.391l-.364-.021c-.027.453-.073.912-.136 1.36zm-.614 2.656.355.115c.14-.443.265-.896.369-1.349l-.359-.083c-.1.448-.224.891-.365 1.317zm-.938-11.932c.203.407.396.823.568 1.244l.339-.14c-.172-.427-.371-.86-.584-1.271zM11.063 31.224c.443.14.891.265 1.344.369l.083-.353a15.487 15.487 0 0 1-1.312-.365zm2.718.631c.459.063.927.109 1.391.135l.016-.369a15.064 15.064 0 0 1-1.36-.131zm9.318-1.923c-.401.204-.812.396-1.235.563l.141.344c.421-.177.855-.365 1.26-.579l.005-.005-.161-.328zM6.151 28.625c.365.281.751.557 1.141.801l.197-.301c-.38-.251-.755-.516-1.115-.792zm10.406 3.011.011.364c.463-.021.932-.052 1.396-.115l-.047-.359c-.448.057-.907.093-1.36.109zM8.495 30.14c.407.215.833.417 1.26.6l.141-.339a17.761 17.761 0 0 1-1.229-.589zm-4.386-3.421c.312.349.64.683.979.995l.251-.265a15.397 15.397 0 0 1-.953-.975zm15.151 4.584.079.359c.453-.099.907-.219 1.355-.355l-.109-.348a21.46 21.46 0 0 1-1.324.344zM28.24.172a3.583 3.583 0 0 0-3.584 3.583 3.584 3.584 0 0 0 3.584 3.589c4.781 0 4.781-7.172 0-7.172zm-7.808 20.421c0 .631.417.88 1.136.88.896 0 1.729-.525 1.729-1.353v-.86c-.308.147-.505.188-1.475.324-.979.145-1.391.405-1.391 1.009zM16 3.755c-6.76 0-12.24 5.48-12.24 12.24S9.24 28.24 16 28.24s12.24-5.485 12.24-12.245c0-6.755-5.48-12.24-12.24-12.24zM12.683 22.12H7.694v-8.032h1.025v7.125h3.969v.907zm5.51 0h-.829v-.896c-.541.76-1.077 1.057-1.927 1.057-1.125 0-1.839-.62-1.839-1.579v-4.359h.912v4c0 .692.463 1.135 1.192 1.135.959 0 1.573-.771 1.573-1.948v-3.187h.917zm-.709-11.193a3.583 3.583 0 1 1 7.166 0 3.583 3.583 0 0 1-7.166 0zm7.423 10.474v.692c-.297.079-.437.1-.625.1a.976.976 0 0 1-.953-.761 2.695 2.695 0 0 1-1.959.849c-1.172 0-1.896-.615-1.896-1.661 0-.703.339-1.224 1.011-1.5.36-.141.552-.188 1.855-.349.729-.088.959-.255.959-.64v-.245c0-.547-.464-.859-1.287-.859-.865 0-1.276.323-1.36 1.025h-.921c.057-1.333.916-1.869 2.312-1.869 1.423 0 2.167.547 2.167 1.572v3.219c0 .287.177.448.5.448.052 0 .099 0 .199-.02z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
<path d="M12.005 0 4.952 7.053a9.865 9.865 0 0 0 0 14.022 9.866 9.866 0 0 0 14.022 0c3.984-3.9 3.986-10.205.085-14.023l-1.744 1.743c2.904 2.905 2.904 7.634 0 10.538s-7.634 2.904-10.538 0-2.904-7.634 0-10.538l4.647-4.646.582-.665zm3.568 3.899a1.327 1.327 0 0 0-1.327 1.327 1.327 1.327 0 0 0 1.327 1.328A1.327 1.327 0 0 0 16.9 5.226 1.327 1.327 0 0 0 15.573 3.9z"/>
</svg>

After

Width:  |  Height:  |  Size: 479 B

27
scripts/assets/tar.svg Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" height="1em" width="1em"
viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">
<g>
<g>
<path d="M47.987,21.938c-0.006-0.091-0.023-0.178-0.053-0.264c-0.011-0.032-0.019-0.063-0.033-0.094
c-0.048-0.104-0.109-0.202-0.193-0.285c-0.001-0.001-0.001-0.001-0.001-0.001L42,15.586V10c0-0.022-0.011-0.041-0.013-0.063
c-0.006-0.088-0.023-0.173-0.051-0.257c-0.011-0.032-0.019-0.063-0.034-0.094c-0.049-0.106-0.11-0.207-0.196-0.293l-9-9
c-0.086-0.086-0.187-0.148-0.294-0.196c-0.03-0.014-0.06-0.022-0.091-0.032c-0.085-0.03-0.172-0.047-0.263-0.052
C32.039,0.01,32.021,0,32,0H7C6.448,0,6,0.448,6,1v14.586l-5.707,5.707c0,0-0.001,0.001-0.002,0.002
c-0.084,0.084-0.144,0.182-0.192,0.285c-0.014,0.031-0.022,0.062-0.033,0.094c-0.03,0.086-0.048,0.173-0.053,0.264
C0.011,21.96,0,21.978,0,22v19c0,0.552,0.448,1,1,1h5v5c0,0.552,0.448,1,1,1h34c0.552,0,1-0.448,1-1v-5h5c0.552,0,1-0.448,1-1V22
C48,21.978,47.989,21.96,47.987,21.938z M44.586,21H42v-2.586L44.586,21z M38.586,9H33V3.414L38.586,9z M8,2h23v8
c0,0.552,0.448,1,1,1h8v5v5H8v-5V2z M6,18.414V21H3.414L6,18.414z M40,46H8v-4h32V46z M46,40H2V23h5h34h5V40z"/>
<path d="M33.86,32.143c0.221-0.153,0.422-0.354,0.604-0.603c0.181-0.249,0.332-0.552,0.451-0.91
c0.119-0.357,0.179-0.767,0.179-1.232c0-0.601-0.085-1.116-0.255-1.547c-0.17-0.431-0.405-0.788-0.706-1.071
c-0.3-0.283-0.66-0.49-1.079-0.621c-0.419-0.13-0.878-0.195-1.377-0.195h-3.434V38h1.972v-5.134h1.139L33.222,38h2.142
l-2.159-5.542C33.421,32.401,33.639,32.297,33.86,32.143z M32.602,30.902c-0.323,0.312-0.734,0.468-1.233,0.468h-1.156v-3.706
h1.156c0.204,0,0.408,0.028,0.612,0.085s0.388,0.153,0.552,0.289s0.298,0.323,0.4,0.561s0.153,0.538,0.153,0.901
C33.086,30.123,32.925,30.591,32.602,30.902z"/>
<path d="M21.441,25.964L18.449,38h2.04l0.612-2.55h3.162L24.858,38h2.125l-2.941-12.036H21.441z M21.357,33.852l1.309-5.967h0.068
l1.275,5.967H21.357z"/>
<polygon points="18.756,25.964 12.227,25.964 12.227,27.698 14.488,27.698 14.488,38 16.494,38 16.494,27.698 18.756,27.698 "/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -3,6 +3,7 @@ import rehypeDocument from 'rehype-document';
import remarkGemoji from 'remark-gemoji';
import rehypeRaw from 'rehype-raw';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import { getCodeString } from 'rehype-rewrite';
import rehypeSlug from 'rehype-slug';
import { htmlTagAddAttri } from './nodes/htmlTagAddAttri.mjs';
import { footer } from './nodes/footer.mjs';
@ -26,6 +27,14 @@ export function create(str = '', options = {}) {
.replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1')
.replace(/\n/, '');
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & ` : '';
/** 用于搜索数据 */
const detailData = {
title: title.replace(/\n/g, ''),
path: '',
intro: description,
icon: '',
sections: [],
};
const mdOptions = {
showLineNumbers: false,
hastNode: false,
@ -66,7 +75,10 @@ export function create(str = '', options = {}) {
return plugins;
},
rewrite: (node, index, parent) => {
rehypeTitle(node, options.filename);
const iconName = rehypeTitle(node, options.filename);
if (iconName) {
detailData.icon = iconName;
}
homeCardIcons(node, parent, options.isHome);
tooltips(node, index, parent);
htmlTagAddAttri(node, options);
@ -77,6 +89,19 @@ export function create(str = '', options = {}) {
if (!options.isHome) {
const tocsMenus = getTocsTitleNode([...tocsData]);
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
tocsMenus.forEach((menu, idx) => {
const level = menu?.properties['data-num'];
if (idx + 1 === tocsMenus.length && level === 2) {
return;
}
if (level < 4) {
detailData.sections.push({
a: menu?.properties?.href,
t: getCodeString(menu.children),
l: menu?.properties['data-num'],
});
}
});
} else {
node.children = tocsData;
}
@ -87,6 +112,6 @@ export function create(str = '', options = {}) {
}
},
};
return markdown(str, mdOptions);
const htmlStr = markdown(str, mdOptions);
return { html: htmlStr, data: detailData };
}

View File

@ -5,6 +5,9 @@ import { create } from './create.mjs';
export const OUTOUT = path.resolve(process.cwd(), 'dist');
export const DOCS = path.resolve(process.cwd(), 'docs');
/** 搜索数据路径 */
export const SEARCH_DATA = path.resolve(OUTOUT, 'data.json');
export const SEARCH_DATA_CACHE = path.resolve(process.cwd(), 'node_modules/.cache/reference/data.json');
export async function createHTML(files = [], num = 0) {
const dataFile = files[num];
@ -25,8 +28,7 @@ export async function createHTML(files = [], num = 0) {
.replace(/.md$/, '.html');
await fs.ensureDir(path.dirname(outputHTMLPath));
const html = create(mdstr.toString(), {
const options = {
filename: path.basename(outputHTMLPath, '.html'),
isHome: /README.md$/.test(path.relative(process.cwd(), dataFile.path)),
githubURL,
@ -35,16 +37,32 @@ export async function createHTML(files = [], num = 0) {
path.relative(path.dirname(outputHTMLPath), path.resolve(OUTOUT, 'style/style.css')),
path.relative(path.dirname(outputHTMLPath), path.resolve(OUTOUT, 'style/katex.css')),
],
});
};
const { html, data } = create(mdstr.toString(), options);
if (!options.isHome) {
const searchData = await fs.readJSON(SEARCH_DATA_CACHE);
data.path = path.relative(OUTOUT, outputHTMLPath);
searchData[options.filename] = data;
searchData.name = options.filename;
await fs.writeJSON(SEARCH_DATA_CACHE, searchData);
const resultSearchData = Object.keys({ ...searchData })
.map((name) => searchData[name])
.filter((item) => typeof item !== 'string');
await fs.writeJSON(SEARCH_DATA, resultSearchData);
}
await fs.writeFile(outputHTMLPath, html);
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`);
createHTML(files, num);
}
export async function run() {
try {
await fs.ensureDir(OUTOUT);
await fs.emptyDir(OUTOUT);
await fs.ensureDir(path.resolve(OUTOUT, 'style'));
await fs.ensureFile(SEARCH_DATA_CACHE);
await fs.writeFile(SEARCH_DATA_CACHE, '{}');
await fs.writeFile(SEARCH_DATA, '[]');
await fs.copy(path.resolve(process.cwd(), 'scripts/style'), path.resolve(OUTOUT, 'style'));
const files = await recursiveReaddirFiles(process.cwd(), {
ignored: /\/(node_modules|\.git)/,
@ -52,4 +70,7 @@ export async function run() {
filter: (item) => item.ext === 'md',
});
createHTML(files);
} catch (error) {
console.log('ERR:', error);
}
}

View File

@ -3,7 +3,10 @@ import formatter from '@uiw/formatter';
export function footer(options = {}) {
let footerText = '© 2022 Kenny Wang.';
if (options.isHome) {
footerText += ` Updated on ${formatter('YYYY/MM/DD HH:mm:ss', new Date())}`;
const now = new Date();
const utc = now.getTime() + now.getTimezoneOffset() * 60000;
const cst = new Date(utc + 3600000 * 8);
footerText += ` Updated on ${formatter('YYYY/MM/DD HH:mm:ss', cst)}`;
}
return {
type: 'element',

View File

@ -10,7 +10,12 @@ export function getTocsTitleNode(arr = [], result = []) {
arr.forEach(({ tagName, type, properties, children }) => {
if (/^h[23456]/.test(tagName)) {
const num = titleNum(tagName);
const props = { 'aria-hidden': 'true', class: `leve${num} tocs-link`, href: '#' + (properties.id || '') };
const props = {
'aria-hidden': 'true',
class: `leve${num} tocs-link`,
'data-num': num,
href: '#' + (properties.id || ''),
};
const title = getCodeString(children || []);
result.push({ tagName: 'a', type, properties: props, children: [{ type: 'text', value: title || ' ' }] });
} else if (children?.length > 0) {

View File

@ -10,6 +10,8 @@ export function rehypeTitle(node, iconName) {
if (iconExist) {
const svgNode = getSVGNode(iconPath);
node.children = [...svgNode, ...node.children];
// 如果存在返回图标名称
return iconName;
} else {
const svgNode = getSVGNode(iconDefaultPath);
node.children = [...svgNode, ...node.children];