Compare commits
77 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6d24b1b957 | ||
![]() |
72d3bd8d42 | ||
![]() |
2d4a9604cf | ||
![]() |
7a22e7cda2 | ||
![]() |
85071d3204 | ||
![]() |
c4694ed832 | ||
![]() |
906cbdd152 | ||
![]() |
a38f6d8f85 | ||
![]() |
2037e0f6b9 | ||
![]() |
bb2cff4f9b | ||
![]() |
b3c47e2b2d | ||
![]() |
5701da6e5b | ||
![]() |
ea80136db3 | ||
![]() |
aa26be4186 | ||
![]() |
2b1d33a5db | ||
![]() |
dbf8ac4fb2 | ||
![]() |
f2f1ef8c52 | ||
![]() |
748ed480f4 | ||
![]() |
7c2338ea76 | ||
![]() |
90c9fefa51 | ||
![]() |
29f3b971d2 | ||
![]() |
b2aabe4291 | ||
![]() |
04e6e16a97 | ||
![]() |
3db12d6cce | ||
![]() |
3f0b60187c | ||
![]() |
bead2f0e3b | ||
![]() |
816f49004f | ||
![]() |
12b84b8368 | ||
![]() |
56b4b78d7d | ||
![]() |
f28c93b918 | ||
![]() |
0bfe15e4dc | ||
![]() |
c1394813bc | ||
![]() |
06c6229cac | ||
![]() |
04dd94d6f8 | ||
![]() |
5f19d3feee | ||
![]() |
e48fd74c38 | ||
![]() |
7c7f25bf9f | ||
![]() |
2dde0c4408 | ||
![]() |
a2d7cd6e7b | ||
![]() |
10366e3317 | ||
![]() |
4bf8a55bf3 | ||
![]() |
0101ef71d0 | ||
![]() |
aa38a0e765 | ||
![]() |
4a1eb6964d | ||
![]() |
f6ff51be15 | ||
![]() |
6c89718254 | ||
![]() |
8c79a648a4 | ||
![]() |
f021d73b77 | ||
![]() |
c060c36559 | ||
![]() |
39aa2c4387 | ||
![]() |
aeca8351bd | ||
![]() |
d7d6b0d447 | ||
![]() |
4d69a0ef24 | ||
![]() |
bafc15d17e | ||
![]() |
68069fbf01 | ||
![]() |
ca3cf85666 | ||
![]() |
040af8095f | ||
![]() |
d1dea83330 | ||
![]() |
4503b28837 | ||
![]() |
02d0a495a6 | ||
![]() |
c66d1c0294 | ||
![]() |
f2d43d65df | ||
![]() |
009c50760c | ||
![]() |
f683ca5294 | ||
![]() |
04369f05d3 | ||
![]() |
ae04c01eb4 | ||
![]() |
e66c1c57fd | ||
![]() |
c7df917009 | ||
![]() |
a5744c23b7 | ||
![]() |
d8ab87b0e0 | ||
![]() |
e87ce59a88 | ||
![]() |
428d8488f3 | ||
![]() |
e84c69f8b9 | ||
![]() |
3cdc2685e6 | ||
![]() |
df3e04ba92 | ||
![]() |
4662fb8071 | ||
![]() |
600dbc6fef |
27
.dockerignore
Normal file
@@ -0,0 +1,27 @@
|
||||
.github
|
||||
.husky
|
||||
docs
|
||||
scripts
|
||||
node_modules
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
|
||||
.DS_Store
|
||||
.cache
|
||||
.vscode
|
||||
.idea
|
||||
.snap
|
||||
.env
|
||||
|
||||
*.bak
|
||||
*.tem
|
||||
*.temp
|
||||
#.swp
|
||||
*.*~
|
||||
~*.*
|
||||
|
||||
# IDEA
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
7
.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
||||
root = true
|
||||
|
||||
[./docs/*.md]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
2
.gitignore
vendored
@@ -2,6 +2,8 @@ build
|
||||
dist
|
||||
node_modules
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
|
||||
.DS_Store
|
||||
.cache
|
||||
|
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": ["prettier --write"]
|
||||
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": ["prettier --write"],
|
||||
"./docs/*.md": ["npx markdownlint-cli --fix ./docs"]
|
||||
}
|
||||
|
12
.markdownlint.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"MD003": false,
|
||||
"MD013": false,
|
||||
"MD014": false,
|
||||
"MD024": false,
|
||||
"MD033": false,
|
||||
"MD040": false,
|
||||
"MD010": {
|
||||
"code_blocks": true,
|
||||
"spaces_per_tab": 2
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@ Contributing 贡献
|
||||
这是您可以在 Quick Reference 备忘清单上使用的样式参考!【备忘清单介绍】
|
||||
```
|
||||
|
||||
只需要 `标题<h1>` 和`介绍`(标题下面)。脚本会自动识别,通过 GitHub Actions 自动发布 [`Quick Reference`](https://jaywcjlove.github.io/reference) 网站。
|
||||
只需要 `标题<h1>` 和 `介绍` (标题下面)。脚本会自动识别,通过 GitHub Actions 自动发布 [`Quick Reference`](https://jaywcjlove.github.io/reference) 网站。
|
||||
|
||||
## 目录结构
|
||||
|
||||
@@ -38,7 +38,7 @@ Contributing 贡献
|
||||
|
||||
## CSS 类注释
|
||||
|
||||
[`Quick Reference`](https://jaywcjlove.github.io/reference) 使用 [`@wcj/markdown-to-html`](https://github.com/jaywcjlove/markdown-to-html) 转换 `Markdown`,并使用 [`rehype-attr`](https://github.com/jaywcjlove/rehype-attr) 插件让其支持通过其注释语法添加类和样式。 此外,您可以在 Quick Reference 备忘清单上使用样式参考:https://jaywcjlove.github.io/reference/docs/quickreference.html
|
||||
[`Quick Reference`](https://jaywcjlove.github.io/reference) 使用 [`@wcj/markdown-to-html`](https://github.com/jaywcjlove/markdown-to-html) 转换 `Markdown`,并使用 [`rehype-attr`](https://github.com/jaywcjlove/rehype-attr) 插件让其支持通过其注释语法添加类和样式。此外,您可以在 Quick Reference 备忘清单上使用样式参考:<https://jaywcjlove.github.io/reference/docs/quickreference.html>
|
||||
|
||||
最后,参考现有备忘清单的源代码是一个好习惯!
|
||||
|
||||
@@ -61,14 +61,13 @@ Contributing 贡献
|
||||
- SVG 图标尺寸 `<svg height="1em" width="1em"`
|
||||
- SVG 图标颜色使用继承颜色值 `<svg fill="currentColor"`
|
||||
|
||||
#### 提示配置
|
||||
### 提示配置
|
||||
|
||||
```markdown
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing-->
|
||||
```
|
||||
|
||||
添加 `contributing` 类名,会在卡片下方添加 _`👆待完善需要您的参与`_
|
||||
|
||||
添加 `contributing` 类名,会在卡片下方添加 _`👆待完善需要您的参与`_,添加 `data-info=👆看看还缺点儿什么?`,更换默认提示文本。
|
||||
|
||||
```markdown
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=tag&data-lang=Python-->
|
||||
@@ -83,3 +82,5 @@ npm i # 安装依赖
|
||||
npm run build # 编译输出 HTML
|
||||
npm run start # 监听 md 文件编译输出 HTML
|
||||
```
|
||||
|
||||
- 或者你也可以使用 `pnpm` 或者 `yarn` 做为包管理器
|
||||
|
62
README.md
@@ -9,10 +9,23 @@ Quick Reference
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
<!--rehype:ignore:start-->
|
||||
[](https://jaywcjlove.github.io/reference)
|
||||
[](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) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
|
||||
## 正在建设中...
|
||||
|
||||
坑已挖,需要您的参与完善和贡献!🙏
|
||||
<!--rehype:style=padding-bottom: 23px;-->
|
||||
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(238 0 0/var(\-\-bg\-opacity));&class=contributing tag&data-lang=RedHad&data-info=👆看看还缺点儿什么?-->
|
||||
[CMake](./docs/cmake.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[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-->
|
||||
[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-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 编程
|
||||
|
||||
@@ -22,12 +35,17 @@ Quick Reference
|
||||
[Dockerfile](./docs/dockerfile.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));&class=tag&data-lang=Docker-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
|
||||
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193/var(\-\-bg\-opacity));-->
|
||||
[GraphQL](./docs/graphql.md)<!--rehype:style=background: rgb(214 66 146/var(\-\-bg\-opacity));-->
|
||||
[INI](./docs/ini.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
|
||||
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));&class=tag&data-lang=SQL-->
|
||||
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Python](./docs/python.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[PostgreSQL](./docs/postgres.md)<!--rehype:style=background: rgb(43 109 163/var(\-\-bg\-opacity));&class=tag&data-lang=SQL-->
|
||||
[Ruby](./docs/ruby.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));-->
|
||||
[Rust](./docs/rust.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));-->
|
||||
[Swift](./docs/swift.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[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));-->
|
||||
@@ -45,61 +63,71 @@ Quick Reference
|
||||
[Sass](./docs/sass.md)<!--rehype:style=background: rgb(207 100 154/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39/var(\-\-bg\-opacity));-->
|
||||
[JavaScript](./docs/javascript.md)<!--rehype:style=background: rgb(203 183 31/var(\-\-bg\-opacity));-->
|
||||
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[Less.js](./docs/lessjs.md)<!--rehype:style=background: rgb(29 54 93/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[React](./docs/react.md)<!--rehype:style=background: rgb(34 143 173/var(\-\-bg\-opacity));-->
|
||||
[RegEx](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
|
||||
[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-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Nodejs
|
||||
|
||||
[Express.js](./docs/expressjs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
|
||||
[Koa.js](./docs/koajs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(33 136 182/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 工具
|
||||
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(98 36 134/var(\-\-bg\-opacity));-->
|
||||
[Gmail](./docs/gmail.md)<!--rehype:style=background: rgb(234 67 54/var(\-\-bg\-opacity));-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 153 0/var(\-\-bg\-opacity));-->
|
||||
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
[Sublime Text](./docs/sublime-text.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
[VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[Vim](./docs/vim.md)<!--rehype:style=background: rgb(9 150 8/var(\-\-bg\-opacity));-->
|
||||
[WebStorm](./docs/webstorm.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[WebStorm](./docs/webstorm.md)<!--rehype:style=background: rgb(32 148 220/var(\-\-bg\-opacity));-->
|
||||
[XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[Xcode](./docs/xcode.md)<!--rehype:style=background: rgb(24 151 233/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Linux 命令
|
||||
## 命令
|
||||
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(238 0 0/var(\-\-bg\-opacity));&class=contributing tag&data-lang=RedHad&data-info=👆看看还缺点儿什么?-->
|
||||
[Awk](./docs/awk.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Conan](./docs/conan.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=tag&data-lang=C/C++-->
|
||||
[Cargo](./docs/cargo.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));&class=tag&data-lang=Rust-->
|
||||
[Curl](./docs/curl.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Chmod](./docs/chmod.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Cron](./docs/cron.md)<!--rehype:style=background: rgb(239 68 68/var(\-\-bg\-opacity));-->
|
||||
[CMake](./docs/cmake.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62/var(\-\-bg\-opacity));-->
|
||||
[Grep](./docs/grep.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));-->
|
||||
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
[Netstat](./docs/netstat.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[jq](./docs/jq.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=JSON-->
|
||||
[Lsof](./docs/lsof.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135/var(\-\-bg\-opacity));-->
|
||||
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Systemd](./docs/systemd.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
|
||||
[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));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 其它
|
||||
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=排版说明-->
|
||||
[Github Actions](./docs/github-actions.md)<!--rehype:style=background: rgb(121 184 255/var(\-\-bg\-opacity));-->
|
||||
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
|
402
docs/ansible.md
Normal file
@@ -0,0 +1,402 @@
|
||||
Ansible 备忘清单
|
||||
====
|
||||
|
||||
此快速参考备忘单提供了使用 [Ansible](https://ansible.com) 的各种方法。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 安装
|
||||
|
||||
安装命令 | 环境
|
||||
:-|-
|
||||
`brew install ansible` | macos
|
||||
`yum install -y ansible` | centos
|
||||
`pip install ansible` | python
|
||||
|
||||
---
|
||||
|
||||
- [Ansible 官方文档](https://docs.ansible.com)
|
||||
|
||||
### 配置位置
|
||||
|
||||
文件路径 | 说明
|
||||
:-|-
|
||||
`/etc/ansible/ansible.cfg` | 系统范围的配置
|
||||
`~/ansible.cfg` | 用户特定的配置
|
||||
`$pwd/ansible.cfg` | 当前目录下的配置
|
||||
|
||||
### Inventory文件(hosts列表)
|
||||
|
||||
#### 静态Inventory
|
||||
|
||||
`/etc/ansible/hosts`
|
||||
|
||||
```INI
|
||||
mail.example.com
|
||||
|
||||
[webservers]
|
||||
foo.example.com
|
||||
bar.example.com
|
||||
```
|
||||
|
||||
### Inventory 主机组使用多个IP和域名
|
||||
|
||||
```
|
||||
[web]
|
||||
172.18.12.5[1:4]
|
||||
[webservers]
|
||||
www[01:50].example.com
|
||||
```
|
||||
|
||||
### Inventory 主机组使用子主机组
|
||||
|
||||
```ini
|
||||
[usa:children]
|
||||
southeast
|
||||
northeast
|
||||
southwest
|
||||
northwest
|
||||
```
|
||||
|
||||
### 给多台主机设置变量
|
||||
|
||||
`group variables`
|
||||
如果组中的所有主机共享一个变量值,则可以一次将该变量应用于整个组
|
||||
|
||||
```ini
|
||||
[atlanta]
|
||||
host1
|
||||
host2
|
||||
|
||||
[atlanta:vars]
|
||||
ntp_server=ntp.atlanta.example.com
|
||||
proxy=proxy.atlanta.example.com
|
||||
|
||||
```
|
||||
|
||||
## 命令行(ad-hoc)
|
||||
|
||||
### ansible
|
||||
|
||||
检查Inventory是否生效
|
||||
|
||||
```shell
|
||||
$ ansible all --list-hosts
|
||||
```
|
||||
|
||||
ping所有目标
|
||||
|
||||
```shell
|
||||
$ ansible all -m ping
|
||||
```
|
||||
|
||||
ping本地(不使用SSH连接)
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m ping
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
本地执行命令
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -a 'hostname'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
获取本地主机的信息
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m setup
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
获取远程到本地
|
||||
|
||||
```shell
|
||||
$ ansible target -m fetch -a "src=/tmp/seq dest=/tmp/seq"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
拷贝本地到远程
|
||||
|
||||
```shell
|
||||
$ ansible target -m copy -a "src=/tmp/seq dest=/tmp/seq"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### Ansible 命令帮助
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```bash
|
||||
$ ansible
|
||||
$ ansible <host-pattern> [options]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-a MODULE_ARGS`, `--args=MODULE_ARGS` | 模块参数
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-B SECONDS`, `--background=SECONDS` | 异步运行,X 秒后失败 (默认=N/A)
|
||||
`-C`, `--check` | 不要做任何改变;相反,尝试预测可能发生的一些变化
|
||||
`-D`, `--diff` | 更改(小)文件和模板时,显示这些文件中的差异; 与 `--check` 配合使用效果很好
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`-f FORKS`, `--forks=FORKS` | 指定要使用的并行进程数 (default=5)
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`-m MODULE_NAME`, `--module-name=MODULE_NAME` | 要执行的模块名称 (default=command)
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径 (default=None)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`-o`, `--one-line` | 压缩输出
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名; 使用 - 用于标准输出
|
||||
`-P POLL_INTERVAL`, `--poll=POLL_INTERVAL` | 如果使用 -B 则设置轮询间隔(default=15)
|
||||
`--syntax-check` | 对 playbook 执行语法检查,但不要执行它
|
||||
`-t TREE`, `--tree=TREE` | 将输出记录到此目录
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
|
||||
控制谁以及如何连接到主机,连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(default=None)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型 (default=smart)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时 (default=10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数 (e.g. ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数 (e.g. -f, -l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 `scp` 的额外参数 (e.g. -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 `ssh` 的额外参数 (e.g. -R)
|
||||
|
||||
控制您成为目标主机上的用户的方式和用户,特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-s`, `--sudo` | 使用 sudo (nopasswd) 运行操作(已弃用,使用 become)
|
||||
`-U SUDO_USER`, `--sudo-user=SUDO_USER` | 所需的 sudo 用户(默认=root)(已弃用,使用 become)
|
||||
`-S`, `--su` | 使用 su 运行操作(已弃用,使用 become)
|
||||
`-R SU_USER`, `--su-user=SU_USER` | 以该用户身份使用 su 运行操作(默认 = root)(已弃用,使用 become)
|
||||
`-b`, `--become` | 使用 become 运行操作(不暗示密码提示)
|
||||
`--become-method=BECOME_METHOD` | 要使用的权限提升方法(默认=sudo),有效选择:[ sudo | su | pbrun | pfexec | runas | doas | dzdo ]
|
||||
`--become-user=BECOME_USER` | 以该用户身份运行操作(默认=root)
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用 become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用 become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
|
||||
### Ansible Galaxy 工具
|
||||
|
||||
```bash
|
||||
$ ansible-galaxy [delete|import|info|init|install|list|login|remove|search|setup] [--help] [options] ...
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
$ ansible-galaxy search --author <AUTHOR>
|
||||
$ ansible-galaxy search --platforms <PLATFORM>
|
||||
$ ansible-galaxy search --galaxy-tags <TAG>
|
||||
$ ansible-galaxy info <ROLE>
|
||||
$ ansible-galaxy install <ROLE> -p <ROLE_DIRECTORY>
|
||||
$ ansible-galaxy install -r <ROLE1> <ROLE2> <ROLE3> ...
|
||||
$ ansible-galaxy list
|
||||
$ ansible-galaxy remove <ROLE>
|
||||
$ ansible-galaxy init <ROLE>
|
||||
$ ansible-galaxy init --offline <ROLE>
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### ansible-doc
|
||||
|
||||
在本地访问文档
|
||||
|
||||
```bash
|
||||
$ ansible-doc
|
||||
$ ansible-doc [options] [module...]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-l`, `--list` | 列出可用模块
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径 (default=None)
|
||||
`-s`, `--snippet` | 显示指定模块的剧本片段
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### ansible-vault
|
||||
|
||||
```bash
|
||||
$ ansible-vault
|
||||
$ ansible-vault [create|decrypt|edit|encrypt|rekey|view] [--help] [options] vaultfile.yml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名; 使用 - 用于标准输出
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### ansible-playbook
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ansible-playbook
|
||||
$ ansible-playbook playbook.yml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-C`, `--check` | 不要做任何改变;相反,尝试预测可能发生的一些变化
|
||||
`-D`, `--diff` | 更改(小)文件和模板时,显示这些文件中的差异;与 `--check` 配合使用效果很好
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`--flush-cache` | 清除事实缓存
|
||||
`--force-handlers` | 即使任务失败也运行处理程序
|
||||
`-f FORKS`, `--forks=FORKS` | 指定要使用的并行进程数(默认值=5)
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`--list-tags` | 列出所有可用的标签
|
||||
`--list-tasks` | 列出所有将要执行的任务
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径(默认=无)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名;使用 - 用于标准输出
|
||||
`--skip-tags=SKIP_TAGS` | 只运行标签与这些值不匹配的播放和任务
|
||||
`--start-at-task=START_AT_TASK` | 在匹配此名称的任务处启动剧本
|
||||
`--step` | 一步一步:在运行前确认每个任务
|
||||
`--syntax-check` | 对 playbook 执行语法检查,但不要执行它
|
||||
`-t TAGS`, `--tags=TAGS` | 只运行带有这些值标记的播放和任务
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(默认=None)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型(默认=smart)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时(默认值 = 10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数(例如 ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数(例如 -f、-l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 scp 的额外参数(例如 -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 ssh 的额外参数(例如 -R)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-s`, `--sudo` | 使用 sudo (nopasswd) 运行操作(已弃用,使用 become)
|
||||
`-U SUDO_USER`, `--sudo-user=SUDO_USER` | 所需的 sudo 用户(默认=root)(已弃用,使用become)
|
||||
`-S`, `--su` | 使用 su 运行操作(已弃用,使用 become)
|
||||
`-R SU_USER`, `--su-user=SU_USER` | 以该用户身份使用 su 运行操作(默认 = root)(已弃用,使用become)
|
||||
`-b`, `--become` | 使用 become 运行操作(不暗示密码提示)
|
||||
`--become-method=BECOME_METHOD` | 要使用的权限提升方法(默认=sudo),有效选择:[ sudo \| su \| pbrun \| pfexec \| runas \| doas \| dzdo ]
|
||||
`--become-user=BECOME_USER` | 以该用户身份运行操作(默认=root)
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用 become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用 become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### ansible-pull
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ansible-pull
|
||||
$ ansible-pull -U <repository> [options]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--accept-host-key` | 如果尚未添加,则添加 repo url 的主机密钥
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-C CHECKOUT`, `--checkout=CHECKOUT` | 分支/标签/提交结帐。默认为存储库模块的行为。
|
||||
`-d DEST`, `--directory=DEST` | 签出存储库的目录
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`-f`, `--force` | 即使无法更新存储库也运行 playbook
|
||||
`--full` | 做一个完整的克隆,而不是一个浅的
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`-m MODULE_NAME`, `--module-name=MODULE_NAME` | 存储库模块名称,ansible 将使用它来签出 repo。默认是 git
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径(默认=无)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`-o`, `--only-if-changed` | 仅在存储库已更新时才运行 playbook
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名;使用 - 用于标准输出
|
||||
`--purge` | 剧本运行后清除结帐
|
||||
`--skip-tags=SKIP_TAGS` | 只运行标签与这些值不匹配的播放和任务
|
||||
`-s SLEEP`, `--sleep=SLEEP` | 在开始之前休眠随机间隔(在 0 到 n 秒之间)。这是分散 git 请求的有用方法
|
||||
`-t TAGS`, `--tags=TAGS` | 只运行带有这些值标记的播放和任务
|
||||
`-U URL`, `--url=URL` | 剧本存储库的 URL
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--verify-commit` | 验证签出提交的 GPG 签名,如果失败则中止运行 playbook。这就需要对应的VCS模块来支持这样的操作
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(默认=无)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型(默认=智能)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时(默认值 = 10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数(例如 ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数(例如 -f、-l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 scp 的额外参数(例如 -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 ssh 的额外参数(例如 -R)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
<!-- ### ansible-playbook -->
|
||||
<!-- todo -->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
[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)
|
@@ -59,7 +59,8 @@ $0/NR ▶ │ 1 │ baidu.com │ awk │
|
||||
$0/NR ▶ │ 2 │ google.com │ 25 │
|
||||
└──────┴──────────────┴───────┘
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```shell
|
||||
# 第一个和最后一个字段
|
||||
@@ -253,7 +254,6 @@ awk -v varName="$PWD" '
|
||||
END {print varName}' </dev/null
|
||||
```
|
||||
|
||||
|
||||
Awk 运算符
|
||||
---------
|
||||
|
||||
@@ -366,7 +366,6 @@ Awk 函数
|
||||
`toupper(s)` | 字符串 `s` 转大写
|
||||
`getline` | 将 `$0` 设置为当前输入文件中的下一个输入记录
|
||||
|
||||
|
||||
### 用户定义函数
|
||||
|
||||
```shell
|
||||
@@ -424,7 +423,6 @@ awk 'BEGIN {
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### 带拆分的数组
|
||||
|
||||
```shell
|
||||
@@ -536,7 +534,6 @@ awk -F: '{
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
Awk 循环
|
||||
----------
|
||||
|
||||
@@ -744,6 +741,7 @@ daemon /sbin
|
||||
-------------
|
||||
|
||||
### 正则表达式元字符
|
||||
|
||||
- `\`
|
||||
- `^`
|
||||
- `$`
|
||||
|
27
docs/bash.md
@@ -64,7 +64,6 @@ NAME = "John" # => Error (关于空间)
|
||||
|
||||
见:[特殊参数](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables)
|
||||
|
||||
|
||||
### 函数
|
||||
|
||||
```bash
|
||||
@@ -265,7 +264,9 @@ for e in "${Fruits[@]}"; do
|
||||
echo $e
|
||||
done
|
||||
```
|
||||
|
||||
#### With index
|
||||
|
||||
```bash
|
||||
for i in "${!Fruits[@]}"; do
|
||||
printf "%s\t%s\n" "$i" "${Fruits[$i]}"
|
||||
@@ -443,7 +444,6 @@ fi
|
||||
`[[ f1 -ot f2 ]]` | f2 早于 f1
|
||||
`[[ f1 -ef f2 ]]` | 相同的文件
|
||||
|
||||
|
||||
### 更多条件
|
||||
|
||||
条件 | 描述
|
||||
@@ -570,7 +570,6 @@ while :; do
|
||||
done
|
||||
```
|
||||
|
||||
|
||||
### 正在读取行
|
||||
|
||||
```bash
|
||||
@@ -720,7 +719,6 @@ Bash 历史
|
||||
|
||||
`!!` 可以替换为任何有效的扩展,即 `!cat`、`!-2`、`!42` 等。
|
||||
|
||||
|
||||
各种各样的
|
||||
-------------
|
||||
|
||||
@@ -741,7 +739,6 @@ $(($RANDOM%200)) # Random number 0..199
|
||||
pwd # still in first directory
|
||||
```
|
||||
|
||||
|
||||
### 检查命令
|
||||
|
||||
```bash
|
||||
@@ -765,7 +762,6 @@ python hello.py &>/dev/null # 标准输出和标准错误到(空null)
|
||||
python hello.py < foo.txt # 将 foo.txt 提供给 python 的标准输入
|
||||
```
|
||||
|
||||
|
||||
### 来源相对
|
||||
|
||||
```bash
|
||||
@@ -791,7 +787,6 @@ case "$1" in
|
||||
esac
|
||||
```
|
||||
|
||||
|
||||
### 陷阱错误
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -862,7 +857,6 @@ fi
|
||||
|
||||
见[特殊参数](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables)。
|
||||
|
||||
|
||||
### grep 检查
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -872,7 +866,6 @@ if grep -q 'foo' ~/.bash_history; then
|
||||
fi
|
||||
```
|
||||
|
||||
|
||||
### 反斜杠转义
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -963,11 +956,11 @@ echo "${args[@]}"
|
||||
另见
|
||||
----
|
||||
|
||||
* [Shell 教程](https://jaywcjlove.github.io/shell-tutorial) _(jaywcjlove.github.io)_
|
||||
* [Devhints](https://devhints.io/bash) _(devhints.io)_
|
||||
* [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_
|
||||
* [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
|
||||
* [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
|
||||
* [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
|
||||
* [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_
|
||||
* [shell - Standard Shell](https://devmanual.gentoo.org/tools-reference/bash/index.html) _(devmanual.gentoo.org)_
|
||||
- [Shell 教程](https://jaywcjlove.github.io/shell-tutorial) _(jaywcjlove.github.io)_
|
||||
- [Devhints](https://devhints.io/bash) _(devhints.io)_
|
||||
- [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_
|
||||
- [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
|
||||
- [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
|
||||
- [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
|
||||
- [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_
|
||||
- [shell - Standard Shell](https://devmanual.gentoo.org/tools-reference/bash/index.html) _(devmanual.gentoo.org)_
|
||||
|
21
docs/c.md
@@ -565,8 +565,8 @@ printf("Line 6 - c 的值是 %d\n", c );
|
||||
`\|` | 按位或运算符,按二进制位进行"或"运算 | `(A \| B)` 将得到 `61` 即为 0011 1101
|
||||
`^` | 异或运算符,按二进制位进行"异或"运算 | `(A ^ B)` 将得到 `49` 即为 0011 0001
|
||||
`~` | 取反运算符,按二进制位进行"取反"运算 | `(~A)` 将得到 `-61` 即为 1100 0011
|
||||
`<<` | 二进制左移运算符 | `A << 2` 将得到 `240` 即为 1111 0000
|
||||
`>>` | 二进制右移运算符 | `A >> 2` 将得到 `15` 即为 0000 1111
|
||||
`<<` | 二进制左移运算符 | `A << 2` 将得到 `240` 即为 1111 0000
|
||||
`>>` | 二进制右移运算符 | `A >> 2` 将得到 `15` 即为 0000 1111
|
||||
|
||||
数据类型 Data Types
|
||||
---
|
||||
@@ -608,7 +608,7 @@ printf("%c\n", myLetter);
|
||||
printf("%lf\n", myDouble);
|
||||
```
|
||||
|
||||
---
|
||||
----
|
||||
|
||||
数据类型 | 说 明
|
||||
:- | :-
|
||||
@@ -620,7 +620,6 @@ printf("%lf\n", myDouble);
|
||||
`double` | 双精度浮点型
|
||||
`void` | 无类型
|
||||
|
||||
|
||||
### 基本格式说明符
|
||||
|
||||
| 格式说明符 | 数据类型 |
|
||||
@@ -743,8 +742,6 @@ Carole 和 Debra: 我们爱你!
|
||||
|
||||
需要把一个宏的参数转换为字符串常量时,使用字符串常量化运算符 `#`
|
||||
|
||||
|
||||
|
||||
### 标记粘贴运算符(##)
|
||||
|
||||
```c
|
||||
@@ -821,12 +818,12 @@ void myFunction() { // 声明 declaration
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
----
|
||||
|
||||
- `Declaration` 声明函数名称、返回类型和参数 _(如果有)_
|
||||
- `Definition` 函数体 _(要执行的代码)_
|
||||
|
||||
---
|
||||
----
|
||||
|
||||
```c
|
||||
// 函数声明
|
||||
@@ -949,7 +946,7 @@ printf("%f", floor(1.4)); // 四舍五入 (舍)
|
||||
printf("%f", pow(4, 3)); // x(4)的y(3)次方
|
||||
```
|
||||
|
||||
---
|
||||
----
|
||||
|
||||
- `abs(x)` 绝对值
|
||||
- `acos(x)` 反余弦值
|
||||
@@ -1304,16 +1301,21 @@ void main (){
|
||||
|
||||
- 安装 [`Docker`](./docker.md)
|
||||
- 创建 [`Dockerfile`](./dockerfile.md) 文件
|
||||
|
||||
```dockerfile
|
||||
FROM alpine:3.14
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
RUN apk add --no-cache g++
|
||||
```
|
||||
|
||||
- 生成本地 myalpine 镜像
|
||||
|
||||
```bash
|
||||
docker build -t myalpine .
|
||||
```
|
||||
|
||||
- 运行映像,把当前路径 `($PWD)` 映射至容器的 `/test` 目录,用 `gcc` 编译程序,`exit`返回
|
||||
|
||||
```bash
|
||||
docker run -it -v $PWD:/test myalpine
|
||||
root@b1a38bd7107a:/# cd test
|
||||
@@ -1324,7 +1326,6 @@ void main (){
|
||||
```
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
432
docs/cargo.md
Normal file
@@ -0,0 +1,432 @@
|
||||
Cargo 备忘清单
|
||||
===
|
||||
|
||||
此快速参考备忘清单 [Cargo](https://conan.io/) 提供了编译 [Rust](./rust.md) 常用命令和示例
|
||||
|
||||
入门
|
||||
--------
|
||||
|
||||
### 安装/升级 Rust 和 Cargo
|
||||
|
||||
```bash
|
||||
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
在 Linux 和 macOS 系统上,这可以通过以上方命令完成
|
||||
|
||||
- [Cargo 开源仓库](https://github.com/rust-lang/cargo) _(github.com)_
|
||||
- [Cargo 官网](https://doc.rust-lang.org/cargo) _(doc.rust-lang.org)_
|
||||
- [Cargo 官网(中文)](https://www.rustwiki.org.cn/zh-CN/cargo/index.html) _(rustwiki.org.cn)_
|
||||
- [Rust 社区的 crate 仓库](https://crates.io/) _(crates.io)_
|
||||
|
||||
### 命令说明
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`cargo version` | 显示版本信息以确认 Cargo 已安装
|
||||
`cargo new` | 创建一个新项目
|
||||
`cargo test` | 在项目中运行单元测试
|
||||
`cargo check` | 快速编译项目,无需生成二进制文件来检查错误
|
||||
`cargo fmt` | 自动格式化代码
|
||||
`cargo build` | 编译一个项目
|
||||
`cargo run` | 一步编译和运行项目
|
||||
`cargo clippy --all-targets -- --D warnings` | Linter 检查错误
|
||||
`cargo tarpaulin --ignore-tests` | 检查代码覆盖率
|
||||
|
||||
### 切换源
|
||||
<!--rehype:wrap-class=col-span-2&style=background:#e91e63;--->
|
||||
|
||||
```bash
|
||||
$ touch ~/.cargo/config # 添加配置文件
|
||||
$ vim ~/.cargo/config # 编辑配置文件
|
||||
```
|
||||
|
||||
配置文件 `config` 内容
|
||||
|
||||
```toml
|
||||
[source.crates-io]
|
||||
registry = "https://github.com/rust-lang/crates.io-index"
|
||||
replace-with = 'tuna' # 👈 如果需要提交包注释配置源
|
||||
|
||||
[source.tuna]
|
||||
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
|
||||
# registry = "git://mirrors.ustc.edu.cn/crates.io-index"
|
||||
```
|
||||
|
||||
💥 注意切换源需要删除缓存目录
|
||||
|
||||
```bash
|
||||
$ rm -rf ~/.cargo/.package-cache # ⚠️ 删除缓存目录内容
|
||||
```
|
||||
|
||||
### 创建新项目
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```bash
|
||||
$ cargo new hello_world --bin
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `--bin` 正在制作一个二进制程序
|
||||
- `--lib` 正在创建一个库(lib)
|
||||
|
||||
得到如下目录:
|
||||
|
||||
```bash
|
||||
$ cd hello_world
|
||||
$ tree .
|
||||
.
|
||||
├── Cargo.toml
|
||||
└── src
|
||||
└── main.rs
|
||||
```
|
||||
|
||||
`Cargo.toml` 被称为一个 `manifest` 元清单,它包含了 `Cargo` 编译项目所需的所有元数据
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "hello_world"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
|
||||
入口文件 `src/main.rs`
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
```
|
||||
|
||||
运行编译生成 `hello_world` 二进制文件
|
||||
|
||||
```bash
|
||||
$ cargo build
|
||||
# 文件放入 `target/release` 目录
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
然后运行它:
|
||||
|
||||
```bash
|
||||
$ ./target/debug/hello_world
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
也可以直接使用 `cargo run`,它会自行`编译`并`运行`它:
|
||||
|
||||
```bash
|
||||
$ cargo run
|
||||
Running `target/hello_world`
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
### 项目目录
|
||||
|
||||
```bash
|
||||
.
|
||||
├── Cargo.lock
|
||||
├── Cargo.toml
|
||||
├── benches # 基准目录
|
||||
│ └── large-input.rs
|
||||
├── examples # 示例
|
||||
│ └── simple.rs
|
||||
├── src # 源代码
|
||||
│ ├── bin
|
||||
│ │ └── another_executable.rs
|
||||
│ ├── lib.rs # 默认库
|
||||
│ └── main.rs # 入口文件
|
||||
└── tests # 集成测试
|
||||
└── some-integration-tests.rs
|
||||
```
|
||||
|
||||
### 编译测试
|
||||
|
||||
```bash
|
||||
# 编译输出二进制文件,放入 `target/debug` 目录
|
||||
$ cargo build
|
||||
# 输出二进制文件,放入 `target/release` 目录
|
||||
$ cargo build --release
|
||||
$ cargo run # 编译并运行
|
||||
$ cargo test # 运行您的测试
|
||||
$ cargo test foo # 传递过滤器,来运行特定测试
|
||||
```
|
||||
|
||||
### 配置目标
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```toml
|
||||
[package]
|
||||
# ...
|
||||
[lib]
|
||||
# 生成目标与库的名称. 本该默认是包名, 替换所有破折号为 下划线. (Rust `extern crate` 声明会参考该名;因此,该值必须是可用的有效Rust标识符)
|
||||
name = "foo"
|
||||
# 该字段,指向 crate 的入口(位置), 路径相对于 `Cargo.toml`.
|
||||
path = "src/lib.rs"
|
||||
# 一个给目标启用单元测试 的 标志. 会被 `cargo test`使用.
|
||||
test = true
|
||||
# 一个给目标启用文档测试 的 标志. 只与库相关, 不会影响其他部分。会被 `cargo test`使用.
|
||||
doctest = true
|
||||
# 一个给目标启用基准 的 标志. 会被 `cargo bench`使用.
|
||||
bench = true
|
||||
# 一个给目标启用文档 的 标志. 会被 `cargo doc`使用.
|
||||
doc = true
|
||||
# 若该目标为 编译器扩展, 那要把该字段设为 true,以让 Cargo 正确编译和,可用于所有依赖项.
|
||||
plugin = false
|
||||
# 若该目标为 "macros 1.1" 程序宏, 那要把该字段设为 true
|
||||
proc-macro = false
|
||||
# 若设为 false, `cargo test` 会为 rustc 省略 `--test` 标志, 这阻止它生成测试工具 这在二进制存在,构建管理测试运行器本身的情况下,有用.
|
||||
harness = true
|
||||
# 若设置了,那 目标会使用一个与`[package]`配置不同的版本, 也许是,编译一个库 2018年版本或,编译单元测试的2015年版本. 默认情况下所有目标都使用`[package]`中指定的版本进行编译。
|
||||
edition = '2015'
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### 来源配置
|
||||
|
||||
```toml
|
||||
# `source` 表下,就是存储有关要更换的来源名称
|
||||
[source]
|
||||
|
||||
# 在`source` 表格之下的,可为一定数量的有关来源名称. 示例下面就,定义了一个新源, 叫 `my-awesome-source`,其内容来自本地,`vendor`目录 ,其相对于包含 `.cargo/config` 文件的目录
|
||||
[source.my-awesome-source]
|
||||
directory = "vendor"
|
||||
|
||||
# Git sources 也指定一个 branch/tag/rev
|
||||
git = "https://example.com/path/to/repo"
|
||||
# branch = "master"
|
||||
# tag = "v1.0.1"
|
||||
# rev = "313f44e8"
|
||||
|
||||
# crates.io 默认源 在"crates-io"名称下,且在这里我们使用 `replace-with` 字段指明 默认源更换成"my-awesome-source"源
|
||||
[source.crates-io]
|
||||
replace-with = "my-awesome-source"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 配置
|
||||
|
||||
```toml
|
||||
# 每个源都有自己的表格,名称即是表名
|
||||
[source.the-source-name]
|
||||
|
||||
# 命令 `the-source-name` 会被 `another-source`取代
|
||||
replace-with = "another-source"
|
||||
|
||||
# 有几种可用的源定义(接下来有所描述)
|
||||
registry = "https://example.com/path/to/index"
|
||||
local-registry = "path/to/registry"
|
||||
directory = "path/to/vendor"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
更换源的配置通过完成 `.cargo/config`,上面是全套可用字段
|
||||
|
||||
包相关命令
|
||||
---
|
||||
|
||||
### init/new
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
创建一个新的 `cargo` 包
|
||||
|
||||
```bash
|
||||
$ cargo init [options] [path]
|
||||
$ cargo new [options] [path]
|
||||
```
|
||||
|
||||
- `--bin` 创建具有二进制目标 (src/main.rs) 的包(默认行为)
|
||||
- `--lib` 使用库目标 (src/lib.rs) 创建一个包
|
||||
- `--edition edition` 指定要使用的 Rust 版本。默认值为 `2021`。可能的值:2015、2018、2021
|
||||
- `--name name` 设置包名。默认为目录名称
|
||||
- `--vcs vcs` 为给定的版本控制系统(git、hg、pijul 或fossil)初始化一个新的 VCS 存储库,或者根本不初始化任何版本控制(无)
|
||||
- `--registry registry` 限制仅发布到该注册表
|
||||
<!--rehype:className=style-arrow-->
|
||||
|
||||
```bash
|
||||
$ cargo new foo
|
||||
```
|
||||
|
||||
### 安装包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
# 从 crates.io 安装或升级软件包:
|
||||
$ cargo install ripgrep
|
||||
# 在当前目录安装或重新安装包:
|
||||
$ cargo install --path .
|
||||
# 查看已安装包的列表:
|
||||
$ cargo install --list
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `--vers version`
|
||||
- `--version version` 指定要安装的版本
|
||||
- `--git url` 用于安装指定 crate 的 Git URL
|
||||
- `--branch branch` 从 git 安装时要使用的分支
|
||||
- `--tag tag` 从 git 安装时使用的标记
|
||||
- `--rev sha` 从 git 安装时使用的特定提交
|
||||
- `--path path` 要安装的本地 crate 的文件系统路径
|
||||
- `--list` 列出所有已安装的软件包及其版本
|
||||
- `-f`, `--force` 强制覆盖现有的 crate 或二进制文件
|
||||
|
||||
### 搜索包
|
||||
|
||||
```bash
|
||||
$ cargo search [options] [query...]
|
||||
```
|
||||
|
||||
- `--limit limit` 限制结果数量(默认值:10,最大值:100)
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要使用的注册表的名称
|
||||
|
||||
```bash
|
||||
$ cargo search serde
|
||||
```
|
||||
|
||||
### 卸载包
|
||||
|
||||
```bash
|
||||
$ cargo uninstall [options] [spec...]
|
||||
```
|
||||
|
||||
- `-p`, `--package spec...` 要卸载的软件包
|
||||
- `--bin name...` 仅卸载二进制名称
|
||||
- `--root dir` 从中卸载软件包的目录
|
||||
|
||||
```bash
|
||||
$ cargo uninstall ripgrep
|
||||
```
|
||||
|
||||
发布命令
|
||||
---
|
||||
|
||||
### 登录
|
||||
|
||||
```bash
|
||||
$ cargo login [options] [token]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`--registry` | 要使用的注册表的名称
|
||||
|
||||
---
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`-v`, `--verbose` | 启用更加详细的输出
|
||||
`-q`, `--quiet` | 不输出Cargo的日志信息
|
||||
`--color when` | 输出内容的颜色 `auto`, `always`, `never`
|
||||
|
||||
### 所有者
|
||||
|
||||
```bash
|
||||
# 列出包的所有者:
|
||||
$ cargo owner --list foo
|
||||
# 邀请所有者加入包:
|
||||
$ cargo owner --add username foo
|
||||
# 从包中删除所有者:
|
||||
$ cargo owner --remove username foo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`--token token` | 身份验证时使用的 API 令牌
|
||||
`--index index` | 要使用的注册表索引的 URL
|
||||
|
||||
### 打包 & 发布公共选项
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
选择包
|
||||
|
||||
- `-p spec...`, `--package spec...` Package 指定包
|
||||
- `--workspace` Package 工作区中的全体成员
|
||||
- `--exclude SPEC...` 排除指定包
|
||||
|
||||
编译选项
|
||||
|
||||
- `--target triple` 为指定架构执行 Package
|
||||
- `--target-dir directory` 用于存放生成的工件以及中间文件的目录
|
||||
|
||||
特性选择
|
||||
|
||||
- `--features features` 传递以空格或者逗号分隔的列表,其中给出要启用的特性
|
||||
- `--all-features` 为给定的包启用全部可用特性
|
||||
- `--no-default-features` 不启用给定包的default特性
|
||||
|
||||
清单选项
|
||||
|
||||
- `--manifest-path path` 用于指定 Cargo.toml 文件的路径
|
||||
- `--frozen`, `--locked` 这两个选项用于保证Cargo.lock文件是最新的
|
||||
- `--offline` 禁止Cargo访问网络
|
||||
|
||||
混杂选项
|
||||
|
||||
- `-j N`, `--jobs N` 要并行运行的作业数量
|
||||
|
||||
### 打包
|
||||
|
||||
将本地包打包为可分发的压缩文件
|
||||
|
||||
```bash
|
||||
$ cargo package [options]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `-l`, `--list` 输出包中包含的文件(不实际进行打包)。
|
||||
- `--no-verify` 构建包时不进行校验。
|
||||
- `--no-metadata` 忽略 缺少可读的元信息(如描述信息或采用的授权协议) 时产生的警告。
|
||||
- `--allow-dirty` 允许打包 在版本控制系统中仍有未提交内容 的包。
|
||||
|
||||
### 发布
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ cargo publish [options]
|
||||
```
|
||||
|
||||
发布选项
|
||||
|
||||
- `--dry-run` 在不上传的情况下执行所有检查
|
||||
- `--token token` 身份验证时使用的 API 令牌
|
||||
- `--no-verify` 不要通过构建内容来验证内容
|
||||
- `--allow-dirty` 允许打包具有未提交的 VCS 更改的工作目录
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要发布到的注册表的名称
|
||||
|
||||
打包选择
|
||||
|
||||
- `-p spec`, `--package spec` 要发布的包
|
||||
|
||||
### yank
|
||||
|
||||
从服务器的索引中删除以前发布的 crate 版本
|
||||
|
||||
```bash
|
||||
$ cargo yank --vers 1.0.7 foo
|
||||
```
|
||||
|
||||
- `--vers version` 要 yank 或 un-yank 的版本
|
||||
- `--undo` 撤消 yank,将版本放回索引中
|
||||
- `--token token` 身份验证时使用的 API 令牌
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要使用的注册表名称
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [The Cargo Book](https://doc.rust-lang.org/stable/cargo/) _(doc.rust-lang.org)_
|
||||
- [Cargo 手册 中文版](https://www.rustwiki.org.cn/zh-CN/cargo/index.html) _(rustwiki.org.cn)_
|
@@ -107,7 +107,6 @@ d rwx r-x r-x
|
||||
| `a` | 全部,和 ugo 一样 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 权限
|
||||
|
||||
| 缩写 | 权限 | 值 |
|
||||
@@ -138,7 +137,6 @@ Chmod 示例
|
||||
| `-` | 删除 |
|
||||
| `=` | 设置 |
|
||||
|
||||
|
||||
### chmod 600
|
||||
|
||||
```shell
|
||||
|
114
docs/cmake.md
Normal file
@@ -0,0 +1,114 @@
|
||||
CMake 备忘清单
|
||||
===
|
||||
|
||||
本清单提供了对 CMake 的入门简要概述,以及 CMake 常用示例
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello CMake
|
||||
|
||||
CMake 是一个用于配置跨平台源代码项目应该如何配置的工具建立在给定的平台上。
|
||||
|
||||
```bash
|
||||
├┈ CMakeLists.txt # 希望运行的 CMake 命令
|
||||
╰┈ main.cpp # 带有 main 的源文件
|
||||
```
|
||||
|
||||
在此项目上运行 `CMake` 时,系统会要求您提供二进制目录,运行 `CMake` 不会创建最终的可执行文件,而是会为 `Visual Studio`、`XCode` 或 `makefile` 生成项目文件。 使用这些工具构建该项目
|
||||
|
||||
#### CMakeLists.txt
|
||||
|
||||
```cmake
|
||||
# 设置可以使用的最低 CMake 版本
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
# 设置项目名称
|
||||
project (hello_cmake)
|
||||
# 添加可执行文件
|
||||
add_executable(hello_cmake main.cpp)
|
||||
```
|
||||
|
||||
#### main.cpp
|
||||
|
||||
```c
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << "Hello CMake!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
#### 编译示例
|
||||
|
||||
```bash
|
||||
$ mkdir build # 创建 build 目录
|
||||
$ cd build # 进入目录
|
||||
$ cmake .. # 目录的上一级目录运行命令
|
||||
$ ./hello_cmake # 运行生成的 hello_cmake
|
||||
Hello CMake!
|
||||
```
|
||||
|
||||
### cmake
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
生成项目构建系统
|
||||
|
||||
```bash
|
||||
$ cmake [<options>] <path-to-source | path-to-existing-build>bash
|
||||
$ cmake [<options>] -S <path-to-source> -B <path-to-build>
|
||||
```
|
||||
|
||||
建立一个项目
|
||||
|
||||
```bash
|
||||
$ cmake --build <dir> [<options>] [-- <build-tool-options>]
|
||||
```
|
||||
|
||||
安装项目
|
||||
|
||||
```bash
|
||||
$ cmake --install <dir> [<options>]
|
||||
```
|
||||
|
||||
打开一个项目
|
||||
|
||||
```bash
|
||||
$ cmake --open <dir>
|
||||
```
|
||||
|
||||
运行脚本
|
||||
|
||||
```bash
|
||||
$ cmake [-D <var>=<value>]... -P <cmake-script-file>
|
||||
```
|
||||
|
||||
运行命令行工具
|
||||
|
||||
```bash
|
||||
$ cmake -E <command> [<options>]
|
||||
```
|
||||
|
||||
运行查找包工具
|
||||
|
||||
```bash
|
||||
$ cmake --find-package [<options>]
|
||||
```
|
||||
|
||||
运行工作流预设
|
||||
|
||||
```bash
|
||||
$ cmake --workflow [<options>]
|
||||
```
|
||||
|
||||
查看帮助
|
||||
|
||||
```bash
|
||||
$ cmake --help[-<topic>]
|
||||
```
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [CMake Examples](http://ttroy50.github.io/cmake-examples/) _(ttroy50.github.io)_
|
@@ -6,6 +6,8 @@ CSS 定义了一大组[命名颜色](https://www.w3.org/TR/css-color-4/#named-co
|
||||
Named Colors
|
||||
---
|
||||
|
||||
<!-- markdownlint-disable MD038 -->
|
||||
|
||||
### 颜色列表
|
||||
<!--rehype:wrap-class=col-span-3&style=display:none;&wrap-style=padding-top: 0;-->
|
||||
|
||||
@@ -760,7 +762,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 150° Green-Cyans
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -880,7 +881,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 180° Cyans
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1000,7 +1000,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 210° Cyan-Blues
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1120,7 +1119,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 240° blues
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1240,7 +1238,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 270° Blue-Magentas
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1360,7 +1357,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 300° Magentas
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1480,7 +1476,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 330° Magenta-Reds
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -1600,7 +1595,6 @@ HSL 颜色示例
|
||||
</table>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
227
docs/conan.md
Normal file
@@ -0,0 +1,227 @@
|
||||
Conan 备忘清单
|
||||
===
|
||||
|
||||
这个 [Conan](https://conan.io/) 快速参考备忘清单显示了它的常用命令使用清单
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
Conan 是开源、去中心化和多平台的软件包,管理器来创建和共享您的所有本机二进制文件
|
||||
|
||||
- [Conan 官网](https://conan.io/)
|
||||
|
||||
#### 安装
|
||||
|
||||
```bash
|
||||
$ pip install conan
|
||||
$ pip install conan --upgrade
|
||||
```
|
||||
|
||||
初始化配置文件
|
||||
|
||||
```bash
|
||||
$ conan config init
|
||||
```
|
||||
|
||||
### 显示本地客户端配置
|
||||
|
||||
Conan 应用配置
|
||||
|
||||
```bash
|
||||
# 查看 Conan 主目录
|
||||
$ conan config home
|
||||
# 显示部分或全部配置项
|
||||
$ conan config get [<section>.<config>]
|
||||
# 显示完整的 conan.conf 文件
|
||||
$ conan config get
|
||||
# 在“日志”部分显示“级别”项
|
||||
$ conan config get log.level
|
||||
```
|
||||
|
||||
配置文件的内容(例如默认值)
|
||||
|
||||
```bash
|
||||
$ conan profile show default
|
||||
```
|
||||
|
||||
远程存储库
|
||||
|
||||
```bash
|
||||
$ conan remote list
|
||||
```
|
||||
|
||||
### 添加和修改配置
|
||||
|
||||
安装配置集合
|
||||
|
||||
```bash
|
||||
$ conan config install <url>
|
||||
$ conan config install ./my_config.conf
|
||||
```
|
||||
|
||||
更改单个配置值
|
||||
|
||||
```bash
|
||||
$ conan config set general.revisions_enabled=1
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
添加遥控器
|
||||
|
||||
```bash
|
||||
$ conan remote add my_remote <url>
|
||||
```
|
||||
|
||||
提供远程凭据
|
||||
|
||||
```bash
|
||||
$ conan user -p <password> -r my_remote <username>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 显示来自 inspect 或 reference 的信息
|
||||
|
||||
显示 `conanfile.py` 的属性
|
||||
|
||||
```bash
|
||||
$ conan inspect <path> -a <attribute>
|
||||
```
|
||||
|
||||
显示 `conanfile.py` 的内容以供参考
|
||||
|
||||
```bash
|
||||
$ conan get <reference>
|
||||
```
|
||||
|
||||
显示 `recipe` 的依赖关系图信息
|
||||
|
||||
```bash
|
||||
$ conan info <path_or_reference>
|
||||
```
|
||||
|
||||
### 搜索包
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
在远程搜索包
|
||||
|
||||
```bash
|
||||
# 列出本地缓存中的包名称
|
||||
$ conan search
|
||||
$ conan search <package>/<revision>@<user>/<channel> # 输出取决于给出了多少包引用。
|
||||
# 支持通配符
|
||||
[--table=file.html] # 将输出保存在 HTML 文件中
|
||||
[-r=<remote>] # 查看远程存储库(默认为本地缓存)
|
||||
|
||||
$ conan search mylib/1.0@user/channel # 显示本地缓存中 mylib/1.0@user/channel 的所有包
|
||||
$ conan search "zlib/*" -r=all # 在所有远程中显示所有版本的 zlib
|
||||
|
||||
$ conan search zlib -r conan-center
|
||||
|
||||
# 显示包的修订:
|
||||
$ conan search <package>/<revision>@<user>/<channel> --revisions
|
||||
```
|
||||
|
||||
### 安装包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
仅使用参考安装包
|
||||
|
||||
```bash
|
||||
$ conan install <package_reference>
|
||||
```
|
||||
|
||||
从 conanfile 安装软件包列表
|
||||
|
||||
```bash
|
||||
$ cat conanfile.txt
|
||||
[requires]
|
||||
zlib/1.2.11
|
||||
$ conan install <path_to_conanfile>
|
||||
```
|
||||
|
||||
通过生成器在构建系统中使用包
|
||||
|
||||
```bash
|
||||
$ cat conanfile.txt
|
||||
[requires]
|
||||
zlib/1.2.11
|
||||
[generators]
|
||||
cmake_find_package
|
||||
msbuild
|
||||
make
|
||||
```
|
||||
|
||||
安装需求并生成文件
|
||||
|
||||
```bash
|
||||
$ mkdir build && cd build
|
||||
$ conan install ..
|
||||
```
|
||||
|
||||
运行您的构建系统(以下之一)
|
||||
|
||||
```bash
|
||||
$ cmake .. && cmake --build .
|
||||
$ msbuild myproject.sln
|
||||
$ make
|
||||
```
|
||||
|
||||
### 创建一个包
|
||||
|
||||
从模板创建配方 (conanfile.py)
|
||||
|
||||
```bash
|
||||
$ conan new <reference> -m <template>
|
||||
```
|
||||
|
||||
只需将配方导出到本地缓存
|
||||
|
||||
```bash
|
||||
$ conan export <path_to_conanfile>
|
||||
```
|
||||
|
||||
从 recipe 为一种配置创建包
|
||||
也隐含地安装和导出步骤
|
||||
|
||||
```bash
|
||||
$ conan create . -pr <profile>
|
||||
```
|
||||
|
||||
### 检查包裹
|
||||
|
||||
完整打印包装配方:
|
||||
|
||||
```bash
|
||||
$ conan get <package>/<revision>@<user>/<channel>
|
||||
$ conan get boost/1.74.0
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
包装配方的打印属性:
|
||||
|
||||
```bash
|
||||
$ conan inspect <package>/<revision>@<user>/<channel>
|
||||
$ conan inspect boost/1.74.0
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
请参阅 [conan get](https://docs.conan.io/en/latest/reference/commands/consumer/get.html) 和 [conan inspect](https://docs.conan.io/en/latest/reference/commands/misc/inspect.html) 参考
|
||||
|
||||
### Lockfiles
|
||||
|
||||
创建一个锁文件:
|
||||
|
||||
```bash
|
||||
$ conan lock create <package>/conanfile.py --user=<user> --channel=<channel>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
在 `conan create` 或 `conan install` 期间使用 lockfile:
|
||||
|
||||
```bash
|
||||
$ conan <command> --lockfile conan.lock
|
||||
```
|
||||
|
||||
查看 [conan lock](https://docs.conan.io/en/latest/reference/commands/misc/lock.html) 参考
|
16
docs/cron.md
@@ -1,7 +1,6 @@
|
||||
Cron 备忘清单
|
||||
===
|
||||
|
||||
|
||||
[Cron](https://en.wikipedia.org/wiki/Cron) 最适合安排重复性任务。 可以使用关联的 at 实用程序来完成一次性任务的调度。
|
||||
|
||||
Crontab 格式
|
||||
@@ -27,7 +26,7 @@ Min Hour Day Mon Weekday
|
||||
└───────────────────── 分钟 (0..59)
|
||||
```
|
||||
|
||||
------
|
||||
-------
|
||||
|
||||
| 字段 | 范围 | 特殊字符 |
|
||||
|--------------|--------|--------------------|
|
||||
@@ -38,7 +37,6 @@ Min Hour Day Mon Weekday
|
||||
| 星期几 | 0 - 6 | , - * ? / L # |
|
||||
<!--rehype:className=show-header -->
|
||||
|
||||
|
||||
### 示例
|
||||
|
||||
| Example | Description |
|
||||
@@ -56,7 +54,6 @@ Min Hour Day Mon Weekday
|
||||
| `0 0 0 1 1 *` | 每年 1 月 1 日(每年) |
|
||||
| `@reboot` | 每次重启 _(非标准)_ |
|
||||
|
||||
|
||||
### 特殊字符串
|
||||
|
||||
| 特殊字符串 | 意义 |
|
||||
@@ -64,14 +61,13 @@ Min Hour Day Mon Weekday
|
||||
| @reboot | 运行一次,在系统启动时 _(非标准)_ |
|
||||
| @yearly | 每年运行一次,“0 0 1 1 *” _(非标准)_ |
|
||||
| @annually | (与@yearly 相同)_(非标准)_ |
|
||||
| @monthly | 每月运行一次,“0 0 1 * *” _(非标准)_ |
|
||||
| @weekly | 每周运行一次,“0 0 * * 0” _(非标准)_ |
|
||||
| @daily | 每天运行一次,“0 0 * * *” _(非标准)_ |
|
||||
| @monthly | 每月运行一次,“0 0 1 \* \*” _(非标准)_ |
|
||||
| @weekly | 每周运行一次,“0 0 \* \* 0” _(非标准)_ |
|
||||
| @daily | 每天运行一次,“0 0 \* \* \*” _(非标准)_ |
|
||||
| @midnight | (与@daily 相同)_(非标准)_ |
|
||||
| @hourly | 每小时运行一次,“0 * * * *” _(非标准)_ |
|
||||
| @hourly | 每小时运行一次,“0 \* \* \* \*” _(非标准)_ |
|
||||
<!--rehype:className=show-header -->
|
||||
|
||||
|
||||
### Crontab 命令
|
||||
|
||||
| - | - |
|
||||
@@ -82,7 +78,6 @@ Min Hour Day Mon Weekday
|
||||
| `crontab -v` | 显示您上次编辑 crontab 文件的时间。 _(非标准)_ |
|
||||
| `echo "@reboot echo hi" | crontab` | 轻松添加任务 |
|
||||
|
||||
|
||||
### 特殊字符
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -97,7 +92,6 @@ Min Hour Day Mon Weekday
|
||||
`问号(?)` | 可以代替“*”并允许用于月份和星期几。使用仅限于 cron 表达式中的 `月份中的某天` 或 `星期几`。
|
||||
<!--rehype:className=show-header auto-wrap-->
|
||||
|
||||
|
||||
## Also see
|
||||
|
||||
* [Devhints](https://devhints.io/cron) _(devhints.io)_
|
||||
|
70
docs/css.md
@@ -149,14 +149,14 @@ div {
|
||||
}
|
||||
```
|
||||
|
||||
查看: [Flexbox](#css-flexbox) | [Flex Tricks](#css-flexbox-tricks)
|
||||
查看: [Flexbox](#css-flexbox) | [Flex Tricks](#css-flexbox-技巧)
|
||||
|
||||
### Grid 布局
|
||||
|
||||
```css
|
||||
#container {
|
||||
display: grid;
|
||||
grid: repeat(2, 60px) / auto-flow 80px;
|
||||
s grid: repeat(2, 60px) / auto-flow 80px;
|
||||
}
|
||||
#container > div {
|
||||
background-color: #8ca0ff;
|
||||
@@ -165,7 +165,7 @@ div {
|
||||
}
|
||||
```
|
||||
|
||||
查看: [Grid Layout](#css-grid-layout)
|
||||
查看: [Grid Layout](#grid-布局)
|
||||
|
||||
### 变量和计数器
|
||||
|
||||
@@ -244,7 +244,6 @@ p:first-child {
|
||||
|
||||
另见: [元素](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Type_selectors) / [类](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Class_selectors) / [ID](https://developer.mozilla.org/zh-CN/docs/Web/CSS/ID_selectors) / [通配](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Universal_selectors) 选择器
|
||||
|
||||
|
||||
### 组合器
|
||||
|
||||
选择器 | 说明
|
||||
@@ -277,10 +276,10 @@ p:first-child {
|
||||
|
||||
选择器 | 说明
|
||||
:- | :-
|
||||
`a:link ` | 链接正常 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:link)
|
||||
`a:active ` | 链接处于点击状态 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:active)
|
||||
`a:hover ` | 鼠标悬停链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:hover)
|
||||
`a:visited ` | 访问链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:visited)
|
||||
`a:link` | 链接正常 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:link)
|
||||
`a:active` | 链接处于点击状态 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:active)
|
||||
`a:hover` | 鼠标悬停链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:hover)
|
||||
`a:visited` | 访问链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:visited)
|
||||
|
||||
---
|
||||
|
||||
@@ -565,7 +564,6 @@ CSS 盒子模型
|
||||
|
||||
另见: [Visibility](https://developer.mozilla.org/zh-CN/docs/Web/CSS/visibility)
|
||||
|
||||
|
||||
### Auto 关键字
|
||||
|
||||
```css
|
||||
@@ -577,7 +575,6 @@ div {
|
||||
|
||||
另见: [边距(margin)](https://developer.mozilla.org/zh-CN/docs/Web/CSS/margin)
|
||||
|
||||
|
||||
### 溢出(Overflow)
|
||||
|
||||
```css
|
||||
@@ -804,7 +801,7 @@ flex-wrap: nowrap | wrap | wrap-reverse;
|
||||
flex-direction: row | row-reverse | column | column-reverse;
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```bash
|
||||
╭┈┈╮ ▲ ╭┈┈╮ ┆
|
||||
@@ -825,7 +822,7 @@ column-reverse column row row-reverse
|
||||
align-items: flex-start | flex-end | center | baseline | stretch;
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```css
|
||||
▶ flex-start(起点对齐) ▶ flex-end(终点对齐)
|
||||
@@ -863,7 +860,7 @@ align-content: flex-start | flex-end | center | space-between | space-around | s
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```css
|
||||
▶ flex-start(起点对齐) ▶ flex-end(终点对齐)
|
||||
@@ -903,7 +900,7 @@ align-content: flex-start | flex-end | center | space-between | space-around | s
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```css
|
||||
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮ ╭┈┈┈┈┈┈┈┈┈╮
|
||||
@@ -927,7 +924,7 @@ align-content: flex-start | flex-end | center | space-between | space-around | s
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```css
|
||||
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
|
||||
@@ -983,7 +980,6 @@ CSS Flexbox 技巧
|
||||
|
||||
### 移动布局
|
||||
|
||||
|
||||
```css
|
||||
.container {
|
||||
display: flex;
|
||||
@@ -1116,7 +1112,7 @@ grid-row-gap: length;
|
||||
### minmax() 函数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```css {.wrap}
|
||||
```css
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 100px minmax(100px, 500px) 100px;
|
||||
@@ -1166,7 +1162,6 @@ grid-row-end: span 2;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Justify Self
|
||||
|
||||
```css
|
||||
@@ -1374,10 +1369,10 @@ a[href^="http"]:empty::before {
|
||||
}
|
||||
```
|
||||
|
||||
如果你的 `<a>` 标签里面没有内容,将 `href` 的值作为内容展示
|
||||
|
||||
如果 `<a>` 标签里面没有内容,将 `href` 的值作为内容展示
|
||||
|
||||
### 使用 :root 表示灵活类型
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
响应式布局中的字体大小应该能够根据每个视口进行调整,您可以使用 `:root` 根据视口高度和宽度计算字体大小
|
||||
|
||||
@@ -1387,7 +1382,7 @@ a[href^="http"]:empty::before {
|
||||
}
|
||||
```
|
||||
|
||||
现在您可以根据 `:root` 计算的值使用根 `em` 单位:
|
||||
您可以根据 `:root` 计算的值使用根 `em` 单位:
|
||||
|
||||
```css
|
||||
body {
|
||||
@@ -1395,6 +1390,39 @@ body {
|
||||
}
|
||||
```
|
||||
|
||||
### 吸附滚动
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```css {5,12}
|
||||
.container {
|
||||
height: 250px;
|
||||
overflow-x: scroll;
|
||||
display: flex;
|
||||
scroll-snap-type: x mandatory;
|
||||
column-gap: 10px;
|
||||
}
|
||||
.child {
|
||||
flex: 0 0 66%;
|
||||
width: 250px;
|
||||
background-color: #663399;
|
||||
scroll-snap-align: center;
|
||||
}
|
||||
```
|
||||
|
||||
可用于 `轮播图` 效果,[效果预览](https://codesandbox.io/embed/pensive-leftpad-w9p8rk?fontsize=14&hidenavigation=1&theme=dark)
|
||||
|
||||
### 类似 contenteditable 的样式
|
||||
|
||||
```css
|
||||
div {
|
||||
-webkit-user-modify:
|
||||
read-write-plaintext-only;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
通过样式来控制一个元素 `div` 是否可以编辑
|
||||
|
||||
另见
|
||||
---------
|
||||
|
||||
|
56
docs/curl.md
@@ -13,7 +13,6 @@ Curl 是一种在服务器之间传输数据的工具,支持协议,包括 HT
|
||||
- [Curl GitHub 源码仓库](https://github.com/curl/curl) _(github.com)_
|
||||
- [Curl 官方网站](https://curl.se/) _(curl.se)_
|
||||
|
||||
|
||||
### Options
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
@@ -228,3 +227,58 @@ curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp"
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
下载一系列文件(输出`foo_file1.webp`、`foo_file2.webp…bar_file1_webp`等)
|
||||
|
||||
### 将输出重定向到文件
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
$ curl http://url/file > file
|
||||
```
|
||||
|
||||
### 基本认证
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
$ curl --user username:password http://example.com/
|
||||
$ curl -u username:password http://example.com/
|
||||
```
|
||||
|
||||
### 写入文件而不是标准输出
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -o file http://url/file
|
||||
$ curl --output file http://url/file
|
||||
```
|
||||
|
||||
### 下载头信息
|
||||
|
||||
```bash
|
||||
$ curl -I url
|
||||
# 显示头信息
|
||||
```
|
||||
|
||||
### 将输出写入名为远程文件的文件
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -o file http://url/file
|
||||
$ curl --output file http://url/file
|
||||
```
|
||||
|
||||
### 执行远程脚本
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -s http://url/myscript.sh
|
||||
```
|
||||
|
||||
### 配置文件
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
curl -K file
|
||||
# 从文件中读取配置
|
||||
curl --config file
|
||||
$HOME/.curlrc # 类 UNIX 系统中的默认配置文件
|
||||
```
|
||||
|
@@ -17,17 +17,20 @@ $ pip --version
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
如果你没有安装 PIP,你可以从这个页面下载并安装它:https://pypi.org/project/pip/
|
||||
如果你没有安装 PIP,你可以从这个页面下载并安装它:<https://pypi.org/project/pip/>
|
||||
|
||||
### 入门
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
- 创建虚拟环境
|
||||
|
||||
```bash
|
||||
$ py -m venv myproject # Windows
|
||||
$ python -m venv myproject # Unix/MacOS
|
||||
```
|
||||
|
||||
- 其中包含子文件夹和文件,如下所示
|
||||
|
||||
```bash
|
||||
myproject
|
||||
├┈Include
|
||||
@@ -35,21 +38,27 @@ $ pip --version
|
||||
├┈Scripts
|
||||
╰┈pyvenv.cfg
|
||||
```
|
||||
|
||||
- 以下命令来激活环境
|
||||
|
||||
```bash
|
||||
# Windows:
|
||||
myproject\Scripts\activate.bat
|
||||
# Unix/MacOS:
|
||||
source myproject/bin/activate
|
||||
```
|
||||
|
||||
- 提示符中看到以下结果:
|
||||
|
||||
```bash
|
||||
# Windows:
|
||||
(myproject) C:\Users\Your Name>
|
||||
# Unix/MacOS:
|
||||
(myproject) ... $
|
||||
```
|
||||
|
||||
- 安装 Django
|
||||
|
||||
```bash
|
||||
# Windows:
|
||||
(myproject) C:\Users\Name>py -m pip install Django
|
||||
@@ -762,9 +771,6 @@ function myFunction() {
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
@@ -21,7 +21,6 @@ $ docker run -d -p 80:80 docker/getting-started
|
||||
- `-p 80:80` - 将端口 80 映射到容器中的端口 80
|
||||
- `docker/getting-started` - 要使用的镜像
|
||||
|
||||
|
||||
在前台创建并运行容器
|
||||
|
||||
```shell
|
||||
@@ -86,7 +85,6 @@ Docker 容器
|
||||
`docker stats nginx-server` | 容器资源使用
|
||||
`docker diff nginx-server` | 列出对容器所做的更改
|
||||
|
||||
|
||||
### 创建容器
|
||||
|
||||
```shell
|
||||
@@ -134,6 +132,7 @@ Docker 镜像
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 操控
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
| `Example` | Description |
|
||||
|-----------|-----------|
|
||||
@@ -159,6 +158,12 @@ $ docker build -f myOtherDockerfile .
|
||||
$ curl example.com/remote/Dockerfile | docker build -f - .
|
||||
```
|
||||
|
||||
### 删除 \<none> 镜像
|
||||
|
||||
```bash
|
||||
$ docker rmi -f $(docker images | grep "none" | awk '{print $3}')
|
||||
```
|
||||
|
||||
Docker 网络
|
||||
----
|
||||
<!--rehype:body-class=cols-2-->
|
||||
@@ -228,9 +233,9 @@ docker network create -d overlay \
|
||||
| Docker 语法 | 说明 |
|
||||
|------------|------|
|
||||
`docker search search_word` | 在 docker hub 中搜索镜像。
|
||||
`docker pull user/image ` | 从 docker hub 下载镜像。
|
||||
`docker login ` | 向 docker hub 进行身份验证
|
||||
`docker push user/image ` | 将镜像上传到 docker hub。
|
||||
`docker pull user/image` | 从 docker hub 下载镜像。
|
||||
`docker login` | 向 docker hub 进行身份验证
|
||||
`docker push user/image` | 将镜像上传到 docker hub。
|
||||
|
||||
### 镜像仓库命令
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
@@ -618,8 +623,8 @@ $ docker run --name my-nginx \
|
||||
```bash
|
||||
$ docker run --name my-postgres \
|
||||
-e POSTGRES_PASSWORD=mysecretpassword \
|
||||
-e PGDATA=/var/lib/postgresql/data/pgdata \
|
||||
-v $HOME/nginx/mount:/var/lib/postgresql/data \
|
||||
-e PGDATA=/var/lib/postgresql/data/pgdata \
|
||||
-v $HOME/nginx/mount:/var/lib/postgresql/data \
|
||||
-d postgres
|
||||
```
|
||||
|
||||
|
@@ -3,7 +3,6 @@ Electron 备忘清单
|
||||
|
||||
此快速参考备忘单提供了 Electron v21 API 说明和使用示例。
|
||||
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
@@ -15,11 +14,14 @@ Electron 备忘清单
|
||||
#### 创建你的应用程序
|
||||
|
||||
- 安装
|
||||
|
||||
```bash
|
||||
mkdir my-app && cd my-app
|
||||
npm init
|
||||
```
|
||||
|
||||
在项目根目录会生成 `package.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-app",
|
||||
@@ -30,22 +32,30 @@ Electron 备忘清单
|
||||
"license": "MIT"
|
||||
}
|
||||
```
|
||||
|
||||
- 安装依赖包
|
||||
|
||||
```bash
|
||||
npm install --save-dev electron
|
||||
```
|
||||
|
||||
- 添加开发模式打开您的应用命令
|
||||
|
||||
```js
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
}
|
||||
```
|
||||
|
||||
- 运行命令,启动应用程序
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
入口都是 `main` 文件。这个文件控制了主进程,它运行在一个完整的Node.js环境中
|
||||
- 创建 `index.html` 页面
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -60,7 +70,9 @@ Electron 备忘清单
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
- 窗口中打开您的页面
|
||||
|
||||
```js
|
||||
const {
|
||||
app,
|
||||
@@ -385,8 +397,8 @@ BrowserWindow
|
||||
`useContentSize` _boolean_ | _(宽)_ 和 _(高)_ 设置为web页面的尺寸。默认值 _(false)_
|
||||
`center` _boolean_ | 窗口是否在屏幕居中。默认值 _(false)_
|
||||
`minHeight` _整数_ | 窗口的最小高度。默认值 _(0)_
|
||||
`maxWidth ` _整数_ | 窗口的最大宽度。默认值不限
|
||||
`maxHeight ` _整数_ | 窗口的最大高度。默认值不限
|
||||
`maxWidth` _整数_ | 窗口的最大宽度。默认值不限
|
||||
`maxHeight` _整数_ | 窗口的最大高度。默认值不限
|
||||
`resizable` _boolean_ | 窗口大小是否可调整。默认值 _(true)_
|
||||
`movable` _boolean_ _(win/mac)_ | 窗口是否可移动。默认值 _(true)_
|
||||
`minimizable` _boolean_ _(win/mac)_ | 窗口是否可最小化。默认值 _(true)_
|
||||
@@ -417,14 +429,14 @@ BrowserWindow
|
||||
`transparent` _boolean_ | 使窗口 <a href="/zh/docs/latest/tutorial/window-customization#create-transparent-windows">透明</a>。 默认值 _(false)_. 在Windows上,仅在无边框窗口下起作用。
|
||||
`type` _string_ | 窗口的类型, 默认为普通窗口. 更多信息见下文
|
||||
`visualEffectState` _string_ _(mac)_ | 在 macOS 上指定外观应如何响应窗口活动状态。 必须与 _(vibrancy)_ 属性一起使用。 可能的值有
|
||||
` visualEffectState.followWindow` | 当窗口处于激活状态时,后台应自动显示为激活状态,当窗口处于非激活状态时,后台应自动显示为非激活状态。 默认为该值。
|
||||
` visualEffectState.active` | 后台应一直显示为激活状态。
|
||||
` visualEffectState.inactive` | 后台应一直显示为非激活状态。
|
||||
`visualEffectState.followWindow` | 当窗口处于激活状态时,后台应自动显示为激活状态,当窗口处于非激活状态时,后台应自动显示为非激活状态。 默认为该值。
|
||||
`visualEffectState.active` | 后台应一直显示为激活状态。
|
||||
`visualEffectState.inactive` | 后台应一直显示为非激活状态。
|
||||
`titleBarStyle` _string_ _(win/mac)_ | 窗口标题栏样式。默认值 _(default)_
|
||||
` titleBarStyle.default` | 分别返回 _mac_ 或者 _win_ 的标准标题栏
|
||||
` titleBarStyle.hidden` | 在一个隐藏的标题栏和一个全尺寸大小的内容窗口中取得结果。 在 macOS 内, 窗口将一直拥有位于左上的标准窗口控制器 _(“traffic lights”)_。 在 Windows上,当与 _(titleBarOverlay: true)_ 合并时,它将激活窗口控件叠加(详情请参阅 _(titleBarOverlay)_),否则将不会显示窗口控件。
|
||||
` titleBarStyle.hiddenInset` _(mac)_ | 隐藏标题栏,使用窗口边缘稍微小的红绿灯按钮替代。
|
||||
` titleBarStyle.customButtonsOnHover` _(mac)_ | 隐藏的标题栏的全尺寸的内容窗口, 红绿灯按钮在鼠标悬停在窗口左上方时显示。**注意:**此选项目前是实验性的。
|
||||
`titleBarStyle.default` | 分别返回 _mac_ 或者 _win_ 的标准标题栏
|
||||
`titleBarStyle.hidden` | 在一个隐藏的标题栏和一个全尺寸大小的内容窗口中取得结果。 在 macOS 内, 窗口将一直拥有位于左上的标准窗口控制器 _(“traffic lights”)_。 在 Windows上,当与 _(titleBarOverlay: true)_ 合并时,它将激活窗口控件叠加(详情请参阅 _(titleBarOverlay)_),否则将不会显示窗口控件。
|
||||
`titleBarStyle.hiddenInset` _(mac)_ | 隐藏标题栏,使用窗口边缘稍微小的红绿灯按钮替代。
|
||||
`titleBarStyle.customButtonsOnHover` _(mac)_ | 隐藏的标题栏的全尺寸的内容窗口, 红绿灯按钮在鼠标悬停在窗口左上方时显示。**注意:**此选项目前是实验性的。
|
||||
`trafficLightPosition` _Point_ _(mac)_ | 在无边框窗口中设置灯绿灯按钮位置。
|
||||
`roundedCorners` _boolean_ _(mac)_ | 无边框窗口在 macOS 上,是否应该有圆角。 默认值为 _(true)_。 属性设置为 _(false)_ ,将阻止窗口是可全屏的。
|
||||
~~`fullscreenWindowTitle`~~ _boolean_ _(mac)_ ~~_已弃用_~~ | _titleBarStyle_ 设置为 _(hiddenInset)_ 时,在 macOS 全屏模式下标题栏显示标题。默认值为 _(false)_.
|
||||
@@ -433,34 +445,34 @@ BrowserWindow
|
||||
`zoomToPageWidth` _boolean_ _(mac)_ | 在 macOS 上控制,当按住 option 点击工具栏绿色红绿灯按钮或点击窗口 > 放大菜单项的行为。 如果为 _(true)_,窗口为将会缩放到适合宽度,若为 _(false)_ 将会放大到屏幕宽度。 这也会影响,直接调用 _(maximize())_ 的行为。 默认值为 _(false)_.
|
||||
`tabbingIdentifier` _string_ _(mac)_ | 选项卡组名称,允许在原生选择卡中打开窗口,macOS 10.12+ 支持。 Windows 中,有相同选项卡标识的将会组合在一起。 这会添加一个原生新增选项卡按钮到你窗口的选项卡栏,同时 _(app)_ 和窗口允许接收 _(new-window-for-tab)_ 事件。
|
||||
`webPreferences` _Object_ | 网页功能设置。
|
||||
` webPreferences.devTools` _boolean_ | 是否开启 DevTools. 如果设置为 _(false)_, 则无法使用 _(BrowserWindow.webContents.openDevTools ())_ 打开 DevTools。 默认值为 _(true)_。
|
||||
` webPreferences.nodeIntegration` _boolean_ | 是否启用Node integration. 默认值为 _(false)_.
|
||||
` webPreferences.nodeIntegrationInWorker` _boolean_ | 是否在Web工作器中启用了Node集成. 默认值为 _(false)_. 更多内容参见 [多线程](https://www.electronjs.org/docs/latest/tutorial/multithreading)
|
||||
` webPreferences.nodeIntegrationInSubFrames` _boolean_ **_实验性_**| 是否允许在子页面(iframe)或子窗口(child window)中集成Node.js; 预先加载的脚本会被注入到每一个iframe,你可以用 _(process.isMainFrame)_ 来判断当前是否处于主框架(main frame)中。
|
||||
` webPreferences.preload` _string_ | 在页面运行其他脚本之前预先加载指定的脚本 无论页面是否集成Node, 此脚本都可以访问所有Node API 脚本路径为文件的绝对路径。 当 node integration 关闭时, 预加载的脚本将从全局范围重新引入node的全局引用标志[参考示例](https://www.electronjs.org/docs/latest/api/context-bridge#exposing-node-global-symbols)
|
||||
` webPreferences.sandbox` _boolean_ | 如果设置该参数, 沙箱的渲染器将与窗口关联, 使它与Chromium OS-level 的沙箱兼容, 并禁用 Node. js 引擎。 它与 _(nodeIntegration)_ 的选项不同,且预加载脚本的 API 也有限制。[更多详情](https://www.electronjs.org/docs/latest/tutorial/sandbox)
|
||||
` webPreferences.session` | [Session](https://www.electronjs.org/docs/latest/api/session#class-session) 设置页面的 session 而不是直接忽略 Session 对象, 也可用 _(partition)_ 选项来代替,它接受一个 partition 字符串. 同时设置了_(session)_ 和 _(partition)_时, _(session)_ 的优先级更高. 默认使用默认的 session.
|
||||
` webPreferences.partition` | string (optional) - 通过 session 的 partition 字符串来设置界面session. 如果 _(partition)_ 以 _(persist:)_开头, 该页面将使用持续的 session,并在所有页面生效,且使用同一个_(partition)_. 如果没有 _(persist:)_ 前缀, 页面将使用 in-memory session. 通过分配相同的 _(partition)_, 多个页可以共享同一会话。 默认使用默认的 session.
|
||||
` webPreferences.zoomFactor` _number_ | 页面的默认缩放系数, _(3.0)_ 表示 _(300%)_。 默认值为 _(1.0)_.
|
||||
` webPreferences.javascript` _boolean_ | 是否启用 JavaScript 支持。 默认值为 _(true)_。
|
||||
` webPreferences.webSecurity` _boolean_ | 当设置为 _(false)_, 它将禁用同源策略 (通常用来测试网站), 如果此选项不是由开发者设置的,还会把 _(allowRunningInsecureContent)_设置为 _(true)_. 默认值为 _(true)_
|
||||
` webPreferences.allowRunningInsecureContent` _boolean_ | 允许一个 https 页面运行来自http url的JavaScript, CSS 或 plugins。 默认值为 _(false)_
|
||||
` webPreferences.images` _boolean_ | 允许加载图片。 默认值为 _(true)_
|
||||
` webPreferences.imageAnimationPolicy` _string_ | 指定如何运行图像动画 (比如: GIF等). 可以是 _(animate)_, _(animateOnce)_ 或 _(noAnimation)_。默认值为 _(animate)_
|
||||
` webPreferences.textAreasAreResizable` _boolean_ | 允许调整 TextArea 元素大小。 默认值为 _(true)_
|
||||
` webPreferences.webgl` _boolean_ | 启用 WebGL 支持。 默认值为 _(true)_
|
||||
` webPreferences.plugins` _boolean_ | 是否应该启用插件。 默认值为 _(false)_
|
||||
` webPreferences.experimentalFeatures` _boolean_ | 启用 Chromium 的实验功能。 默认值为 _(false)_
|
||||
` webPreferences.scrollBounce` _boolean_ _(mac)_ | 启用滚动回弹(橡皮筋)效果。 默认值为 _(false)_
|
||||
` webPreferences.enableBlinkFeatures`_string_ | 以 _(逗号)_ 分隔的需要启用的特性列表,譬如 _(CSSVariables,KeyboardEventKey)_ 在 [RuntimeEnabledFeatures.json5](https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70) 文件中查看被支持的所有特性
|
||||
` webPreferences.disableBlinkFeatures` _string_ | 以 _(,)_ 分隔的禁用特性列表, 如 _(CSSVariables,KeyboardEventKey)_ 在 [RuntimeEnabledFeatures.json5](https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70) 文件中查看被支持的所有特性
|
||||
`webPreferences.devTools` _boolean_ | 是否开启 DevTools. 如果设置为 _(false)_, 则无法使用 _(BrowserWindow.webContents.openDevTools ())_ 打开 DevTools。 默认值为 _(true)_。
|
||||
`webPreferences.nodeIntegration` _boolean_ | 是否启用Node integration. 默认值为 _(false)_.
|
||||
`webPreferences.nodeIntegrationInWorker` _boolean_ | 是否在Web工作器中启用了Node集成. 默认值为 _(false)_. 更多内容参见 [多线程](https://www.electronjs.org/docs/latest/tutorial/multithreading)
|
||||
`webPreferences.nodeIntegrationInSubFrames` _boolean_ **_实验性_**| 是否允许在子页面(iframe)或子窗口(child window)中集成Node.js; 预先加载的脚本会被注入到每一个iframe,你可以用 _(process.isMainFrame)_ 来判断当前是否处于主框架(main frame)中。
|
||||
`webPreferences.preload` _string_ | 在页面运行其他脚本之前预先加载指定的脚本 无论页面是否集成Node, 此脚本都可以访问所有Node API 脚本路径为文件的绝对路径。 当 node integration 关闭时, 预加载的脚本将从全局范围重新引入node的全局引用标志[参考示例](https://www.electronjs.org/docs/latest/api/context-bridge#exposing-node-global-symbols)
|
||||
`webPreferences.sandbox` _boolean_ | 如果设置该参数, 沙箱的渲染器将与窗口关联, 使它与Chromium OS-level 的沙箱兼容, 并禁用 Node. js 引擎。 它与 _(nodeIntegration)_ 的选项不同,且预加载脚本的 API 也有限制。[更多详情](https://www.electronjs.org/docs/latest/tutorial/sandbox)
|
||||
`webPreferences.session` | [Session](https://www.electronjs.org/docs/latest/api/session#class-session) 设置页面的 session 而不是直接忽略 Session 对象, 也可用 _(partition)_ 选项来代替,它接受一个 partition 字符串. 同时设置了_(session)_ 和 _(partition)_时, _(session)_ 的优先级更高. 默认使用默认的 session.
|
||||
`webPreferences.partition` | string (optional) - 通过 session 的 partition 字符串来设置界面session. 如果 _(partition)_ 以 _(persist:)_开头, 该页面将使用持续的 session,并在所有页面生效,且使用同一个_(partition)_. 如果没有 _(persist:)_ 前缀, 页面将使用 in-memory session. 通过分配相同的 _(partition)_, 多个页可以共享同一会话。 默认使用默认的 session.
|
||||
`webPreferences.zoomFactor` _number_ | 页面的默认缩放系数, _(3.0)_ 表示 _(300%)_。 默认值为 _(1.0)_.
|
||||
`webPreferences.javascript` _boolean_ | 是否启用 JavaScript 支持。 默认值为 _(true)_。
|
||||
`webPreferences.webSecurity` _boolean_ | 当设置为 _(false)_, 它将禁用同源策略 (通常用来测试网站), 如果此选项不是由开发者设置的,还会把 _(allowRunningInsecureContent)_设置为 _(true)_. 默认值为 _(true)_
|
||||
`webPreferences.allowRunningInsecureContent` _boolean_ | 允许一个 https 页面运行来自http url的JavaScript, CSS 或 plugins。 默认值为 _(false)_
|
||||
`webPreferences.images` _boolean_ | 允许加载图片。 默认值为 _(true)_
|
||||
`webPreferences.imageAnimationPolicy` _string_ | 指定如何运行图像动画 (比如: GIF等). 可以是 _(animate)_, _(animateOnce)_ 或 _(noAnimation)_。默认值为 _(animate)_
|
||||
`webPreferences.textAreasAreResizable` _boolean_ | 允许调整 TextArea 元素大小。 默认值为 _(true)_
|
||||
`webPreferences.webgl` _boolean_ | 启用 WebGL 支持。 默认值为 _(true)_
|
||||
`webPreferences.plugins` _boolean_ | 是否应该启用插件。 默认值为 _(false)_
|
||||
`webPreferences.experimentalFeatures` _boolean_ | 启用 Chromium 的实验功能。 默认值为 _(false)_
|
||||
`webPreferences.scrollBounce` _boolean_ _(mac)_ | 启用滚动回弹(橡皮筋)效果。 默认值为 _(false)_
|
||||
`webPreferences.enableBlinkFeatures`_string_ | 以 _(逗号)_ 分隔的需要启用的特性列表,譬如 _(CSSVariables,KeyboardEventKey)_ 在 [RuntimeEnabledFeatures.json5](https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70) 文件中查看被支持的所有特性
|
||||
`webPreferences.disableBlinkFeatures` _string_ | 以 _(,)_ 分隔的禁用特性列表, 如 _(CSSVariables,KeyboardEventKey)_ 在 [RuntimeEnabledFeatures.json5](https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70) 文件中查看被支持的所有特性
|
||||
`defaultFontFamily` _Object_ | 为 font-family 设置默认字体
|
||||
` defaultFontFamily.standard` _string_ |默认值为 _(Times New Roman)_
|
||||
` defaultFontFamily.serif` _string_ | 默认值为 _(Times New Roman)_
|
||||
` defaultFontFamily.sansSerif` _string_ | 默认值为 _(Arial)_
|
||||
` defaultFontFamily.monospace` _string_ | 默认值为 _(Courier New)_
|
||||
` defaultFontFamily.cursive` _string_ | 默认值为 _(Script)_
|
||||
` defaultFontFamily.fantasy` _string_ | 默认值为 _(Impact)_
|
||||
`defaultFontFamily.standard` _string_ |默认值为 _(Times New Roman)_
|
||||
`defaultFontFamily.serif` _string_ | 默认值为 _(Times New Roman)_
|
||||
`defaultFontFamily.sansSerif` _string_ | 默认值为 _(Arial)_
|
||||
`defaultFontFamily.monospace` _string_ | 默认值为 _(Courier New)_
|
||||
`defaultFontFamily.cursive` _string_ | 默认值为 _(Script)_
|
||||
`defaultFontFamily.fantasy` _string_ | 默认值为 _(Impact)_
|
||||
`defaultFontSize` _Integer_ | 默认值为 _(16)_
|
||||
`defaultMonospaceFontSize` _Integer_ | 默认值为 _(13)_
|
||||
`minimumFontSize` _Integer_ | 默认值为 _(0)_
|
||||
@@ -480,10 +492,10 @@ BrowserWindow
|
||||
`spellcheck` _boolean_ | 是否启用内置拼写检查器。 默认值为 _(true)_
|
||||
`enableWebSQL` _boolean_ | 是否启用 [WebSQL api](https://www.w3.org/TR/webdatabase/)。 默认值为 _(true)_
|
||||
`v8CacheOptions` _string_ | 强制 blink 使用 v8 代码缓存策略。 可接受的值为:
|
||||
` v8CacheOptions.none` | 禁用代码缓存
|
||||
` v8CacheOptions.code` | 基于启发式代码缓存
|
||||
` v8CacheOptions.bypassHeatCheck` | 绕过启发式代码缓存,但使用懒编译。
|
||||
` v8CacheOptions.bypassHeatCheckAndEagerCompile` | 与上面相同,除了编译是及时的。 默认策略是 _(code)_
|
||||
`v8CacheOptions.none` | 禁用代码缓存
|
||||
`v8CacheOptions.code` | 基于启发式代码缓存
|
||||
`v8CacheOptions.bypassHeatCheck` | 绕过启发式代码缓存,但使用懒编译。
|
||||
`v8CacheOptions.bypassHeatCheckAndEagerCompile` | 与上面相同,除了编译是及时的。 默认策略是 _(code)_
|
||||
`enablePreferredSizeMode` _boolean_ | 是否启用首选大小模式。 首选大小是包含文档布局所需的最小大小--无需滚动。 启用该属性将导致在首选大小发生变化时,在 _(WebContents)_ 上触发 _(preferred-size-changed)_ 事件。默认值为 _(false)_
|
||||
`titleBarOverlay` _Object/Boolean_ | 当在 macOS 使用无框窗口结合 _(win.setWindowButtonVisibility(true))_ 或使用 _(titleBarStyle)_ 以便标准窗口控制 (在 macOS为 "traffic lights") 可见,此属性将启用 Window Controls Overlay [JavaScript APIs](https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#javascript-apis) 和 [CSS Environment Variables](https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#css-environment-variables)。指定 _(true)_ 将导致覆盖默认系统颜色。 默认值为 _(false)_
|
||||
`color` _String_ _(win)_ | 启用窗口控制时覆盖面的 CSS 颜色 默认是系统颜色
|
||||
@@ -684,7 +696,6 @@ child.once('ready-to-show', () => {
|
||||
`win.setTitleBarOverlay(options)` _(win)_ | 在已开启 Window Controls Overlay 的窗口上,此方法将更新标题栏叠加层的样式 [#](https://www.electronjs.org/zh/docs/latest/api/browser-window#winsettitlebaroverlayoptions-windows)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
|
||||
### 静态方法
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
|
@@ -522,5 +522,3 @@ With prefix argument LINE, put point on LINE."
|
||||
0
|
||||
(prefix-numeric-value line))))
|
||||
```
|
||||
|
||||
|
||||
|
@@ -3,7 +3,6 @@ Emmet 备忘清单
|
||||
|
||||
[Emmet](https://emmet.io/) 是一个用于提升 [HTML](./html.md) 和 CSS 代码编写的 Web 开发人员工具包,它允许您使用著名的 CSS 选择器以光速编写大型 HTML 代码块。
|
||||
|
||||
|
||||
Emmet 语法
|
||||
---------------
|
||||
|
||||
@@ -16,7 +15,6 @@ Emmet 语法
|
||||
- [Emmet for Coda](https://emmet.io/download/coda/) _(emmet.io)_
|
||||
- [Emmet for Atom](https://github.com/emmetio/emmet-atom#readme) _(github.com)_
|
||||
|
||||
|
||||
### 乘法:*
|
||||
|
||||
`ul>li*5`
|
||||
@@ -74,14 +72,14 @@ a{Click me}
|
||||
|
||||
p>{Click }+a{here}+{ 继续}
|
||||
|
||||
```html {.wrap}
|
||||
```html
|
||||
<p>Click <a href="">here</a> 继续</p>
|
||||
```
|
||||
|
||||
### ID 和 CLASS 属性
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#header
|
||||
\# header
|
||||
|
||||
```html
|
||||
<div id="header"></div>
|
||||
@@ -199,7 +197,6 @@ ul>li.item$@2*3
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
### 上一层: ^
|
||||
|
||||
div+div>p>span+em^bq
|
||||
@@ -793,7 +790,6 @@ select
|
||||
|
||||
select:disabled, select:d 别名 select[disabled.]
|
||||
|
||||
|
||||
```html
|
||||
<select name="" id="" disabled="disabled"></select>
|
||||
```
|
||||
@@ -1162,7 +1158,7 @@ html:4s 别名 !!!4s+doc4[lang=${lang}]
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
html:xt 别名 !!!xt+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]
|
||||
html:xt 别名 !!!xt+doc4[xmlns=<http://www.w3.org/1999/xhtml> xml:lang=${lang}]
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
```html
|
||||
@@ -1179,7 +1175,7 @@ html:xt 别名 !!!xt+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
html:xs 别名 !!!xs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]
|
||||
html:xs 别名 !!!xs+doc4[xmlns=<http://www.w3.org/1999/xhtml> xml:lang=${lang}]
|
||||
|
||||
```html
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
@@ -1195,7 +1191,7 @@ html:xs 别名 !!!xs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
html:xxs 别名 !!!xxs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]
|
||||
html:xxs 别名 !!!xxs+doc4[xmlns=<http://www.w3.org/1999/xhtml> xml:lang=${lang}]
|
||||
|
||||
```html
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
@@ -1968,6 +1964,7 @@ CSS
|
||||
font-weight: normal;
|
||||
}
|
||||
```
|
||||
|
||||
#### @i, @import
|
||||
|
||||
```css
|
||||
@@ -2057,7 +2054,7 @@ CSS
|
||||
`bfv:h` | backface-visibility:hidden;
|
||||
`bfv:v` | backface-visibility:visible;
|
||||
`bg:ie` | filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='x.png',sizingMethod='crop');
|
||||
`cm` | /* ${child} */
|
||||
`cm` | /\* ${child} */
|
||||
`colm` | columns:;
|
||||
`colmc` | column-count:;
|
||||
`colmf` | column-fill:;
|
||||
@@ -2068,7 +2065,7 @@ CSS
|
||||
`colmrw` | column-rule-width:;
|
||||
`colms` | column-span:;
|
||||
`colmw` | column-width:;
|
||||
`d:ib+` | display: inline-block;<br /> *display: inline;<br /> *zoom: 1;
|
||||
`d:ib+` | display: inline-block;<br /> *display: inline;<br />*zoom: 1;
|
||||
`jc` | justify-content:;
|
||||
`jc:c` | justify-content:center;
|
||||
`jc:fe` | justify-content:flex-end;
|
||||
@@ -2384,7 +2381,7 @@ choose+ A别名 xsl:choose>xsl:when+xsl:otherwise
|
||||
</xsl:choose>
|
||||
```
|
||||
|
||||
xsl 别名 !!!+xsl:stylesheet[version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform]>{ | }
|
||||
xsl 别名 !!!+xsl:stylesheet[version=1.0 xmlns:xsl=<http://www.w3.org/1999/XSL/Transform>]>{ | }
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -2401,4 +2398,4 @@ xsl 别名 !!!+xsl:stylesheet[version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/T
|
||||
另见
|
||||
--------
|
||||
|
||||
* [Emmet Cheat sheet](https://docs.emmet.io/cheat-sheet/) _(docs.emmet.io)_
|
||||
- [Emmet Cheat sheet](https://docs.emmet.io/cheat-sheet/) _(docs.emmet.io)_
|
||||
|
37
docs/es6.md
@@ -149,7 +149,6 @@ class Circle extends Shape {
|
||||
原型的语法糖。
|
||||
请参阅: [类](https://babeljs.io/learn-es2015/#classes)
|
||||
|
||||
|
||||
Promises
|
||||
--------
|
||||
|
||||
@@ -237,7 +236,9 @@ let {title, author} = {
|
||||
const scores = [22, 33]
|
||||
const [math = 50, sci = 50, arts = 50] = scores
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
// Result:
|
||||
// math === 22, sci === 33, arts === 50
|
||||
@@ -252,7 +253,9 @@ function greet({ name, greeting }) {
|
||||
console.log(`${greeting}, ${name}!`)
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
greet({ name: 'Larry', greeting: 'Ahoy' })
|
||||
```
|
||||
@@ -266,7 +269,9 @@ function greet({ name = 'Rauno' } = {}) {
|
||||
console.log(`Hi ${name}!`);
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
greet() // Hi Rauno!
|
||||
greet({ name: 'Larry' }) // Hi Larry!
|
||||
@@ -279,7 +284,9 @@ function printCoordinates({ left: x, top: y }) {
|
||||
console.log(`x: ${x}, y: ${y}`)
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
printCoordinates({ left: 25, top: 90 })
|
||||
```
|
||||
@@ -456,7 +463,9 @@ Objects
|
||||
```js
|
||||
module.exports = { hello, bye }
|
||||
```
|
||||
|
||||
同下:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
hello: hello, bye: bye
|
||||
@@ -524,22 +533,30 @@ Modules 模块
|
||||
import 'helpers'
|
||||
// 又名: require('···')
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
import Express from 'express'
|
||||
// 又名: const Express = require('···').default || require('···')
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
import { indent } from 'helpers'
|
||||
// 又名: const indent = require('···').indent
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
import * as Helpers from 'helpers'
|
||||
// 又名: const Helpers = require('···')
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
import { indentSpaces as indent } from 'helpers'
|
||||
// 又名: const indent = require('···').indentSpaces
|
||||
@@ -554,12 +571,16 @@ import { indentSpaces as indent } from 'helpers'
|
||||
export default function () { ··· }
|
||||
// 又名: module.exports.default = ···
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
export function mymethod () { ··· }
|
||||
// 又名: module.exports.mymethod = ···
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
export const pi = 3.14159
|
||||
// 又名: module.exports.pi = ···
|
||||
@@ -643,7 +664,6 @@ new URL('data.txt', import.meta.url)
|
||||
|
||||
Node.js 环境中,`import.meta.url`返回的总是本地路径,即 `file:URL` 协议的字符串,比如 `file:///home/user/foo.js`
|
||||
|
||||
|
||||
Generators
|
||||
----------
|
||||
|
||||
@@ -655,7 +675,9 @@ function* idMaker () {
|
||||
while (true) { yield id++ }
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```js
|
||||
let gen = idMaker()
|
||||
gen.next().value // → 0
|
||||
@@ -707,7 +729,6 @@ gen[Symbol.iterator] = function* () {
|
||||
|
||||
`Generator` 函数赋值给 `Symbol.iterator` 属性,从而使得 `gen` 对象具有了 `Iterator` 接口,可以被 `...` 运算符遍历了
|
||||
|
||||
|
||||
### Symbol.iterator 属性
|
||||
|
||||
```js
|
||||
|
@@ -10,16 +10,21 @@ Express 备忘清单
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
- 创建项目,添加 `package.json` 配置
|
||||
|
||||
```bash
|
||||
$ mkdir myapp # 创建目录
|
||||
$ cd myapp # 进入目录
|
||||
$ npm init -y # 初始化一个配置
|
||||
```
|
||||
|
||||
- 安装依赖
|
||||
|
||||
```bash
|
||||
$ npm install express # 安装依赖
|
||||
```
|
||||
|
||||
- 入口文件 `index.js` 添加代码:
|
||||
|
||||
```js
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
@@ -31,7 +36,9 @@ Express 备忘清单
|
||||
console.log(`监听端口${port}示例应用`)
|
||||
})
|
||||
```
|
||||
|
||||
- 使用以下命令运行应用程序
|
||||
|
||||
```bash
|
||||
$ node index.js
|
||||
```
|
||||
@@ -189,7 +196,7 @@ app.get('/', function (req, res) {
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`res.app ` | [#](http://expressjs.com/en/4x/api.html#res.app)
|
||||
`res.app` | [#](http://expressjs.com/en/4x/api.html#res.app)
|
||||
`res.headersSent` | [#](http://expressjs.com/en/4x/api.html#res.headersSent)
|
||||
`res.locals` | [#](http://expressjs.com/en/4x/api.html#res.locals)
|
||||
|
||||
|
397
docs/ffmpeg.md
@@ -7,6 +7,7 @@ FFmpeg 参考
|
||||
---
|
||||
|
||||
### 安装
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
Linux
|
||||
|
||||
@@ -22,6 +23,7 @@ $ brew install ffmpeg
|
||||
```
|
||||
|
||||
### 示例
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
mp4 转 avi:
|
||||
|
||||
@@ -35,40 +37,85 @@ webm 转 mp4:
|
||||
$ ffmpeg -i movie.webm movie.mp4
|
||||
```
|
||||
|
||||
### 常用开关
|
||||
### 全局选项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-y` | 覆盖输出文件
|
||||
`-n` | 不要覆盖输出文件
|
||||
|
||||
### 主要选项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-f fmt` | 强制输入或输出文件格式
|
||||
`-i fName` | 输入文件名,未指定显示内容流的摘要
|
||||
`-c codecName` | 指定编解码器 [输入或输出]
|
||||
`-fs Nbytes` | 以 Nbytes 指定最大输出文件大小
|
||||
|
||||
### 基础参数
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-codecs` | 列出可用编码
|
||||
`-formats` | 列出支持的格式
|
||||
`-protocols` | 列出支持的协议
|
||||
`-i input.mp4` | 指定输入文件
|
||||
`-c:v libx264` | 指定视频编码
|
||||
`-c:a aac` | 指定音频编码
|
||||
`-vcodec libx264` | 旧写法
|
||||
`-acodec aac` | 旧写法
|
||||
`-fs SIZE` | 指定文件大小
|
||||
|
||||
### 视频参数
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-b bRate` | 设置视频比特率(单位 kbit/s)
|
||||
`-fixaspect` | 固定纵横比
|
||||
`-bt tolerance` | 设置视频比特率容差(单位 kbit/s)
|
||||
`-maxrate bRate` | 设置最大视频比特率容差(单位 kbit/s)
|
||||
`-minrate bRate` | 设置最小视频比特率容差(单位 kbit/s)
|
||||
`-bufsize size` | 设置速率控制缓冲区大小(以 kByte 为单位)
|
||||
`-sameq` | 使用与源相同的视频质量(意味着 VBR)
|
||||
`-newvideo` | 将新的视频流添加到当前输出流
|
||||
`-aspect RATIO` | 纵横比(4:3、16:9 或 1.25)
|
||||
`-r RATE` | 每秒帧率
|
||||
`-s WIDTHxHEIGHT` | 帧大小
|
||||
`-vn` | 没有视频
|
||||
|
||||
### 码率设置
|
||||
|
||||
```bash
|
||||
-codecs # 列出编解码器
|
||||
-c:v # 视频编解码器(-vcodec)-'copy'复制流
|
||||
-c:a # 音频编解码器(-acodec)
|
||||
-fs SIZE # 限制文件大小(字节)
|
||||
-b:v 1M # 视频比特率(1M = 1Mbit/s)
|
||||
-b:a 1M # 音频比特率(1M = 1Mbit/s)
|
||||
```
|
||||
|
||||
### 音频
|
||||
### 尺寸规格
|
||||
|
||||
```bash
|
||||
-aq QUALITY # 音频质量(特定于编解码器)
|
||||
-ar 44100 # 音频采样率 (Hz)
|
||||
-ac 1 # 音频通道(1=单声道,2=立体声)
|
||||
-an # 没有音频
|
||||
-vol N # 音量(256=正常)
|
||||
```
|
||||
:- | - | - | -
|
||||
:- | - | - | -
|
||||
`K` 或 `k` | 103 | 1000 字节 | 千字节 Kilobytes
|
||||
`M` | 106 | 1000000 字节 | 兆字节 Megabytes
|
||||
`G` | 109 | 1000000000 | 千兆字节 Gigabytes
|
||||
`Ki` | 210 | 1024 | 千字节 Kibibyte
|
||||
`Mi` | 220 | 1048576 | 兆字节 Mebibyte
|
||||
`Gi` | 230 | 1073741824 | Gibibyte
|
||||
|
||||
### 比特率
|
||||
### 音频参数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
-b:v 1M # 视频比特率(1M = 1Mbit/s)
|
||||
-b:a 1M # 音频比特率
|
||||
```
|
||||
|
||||
#### 视频
|
||||
|
||||
```bash
|
||||
-aspect RATIO # 纵横比(4:3、16:9 或 1.25)
|
||||
-r RATE # 每秒帧率
|
||||
-s WIDTHxHEIGHT # 帧大小
|
||||
-vn # 没有视频
|
||||
```
|
||||
:- | -
|
||||
:- | -
|
||||
`-ab bRate` | 设置音频比特率(单位 kbit/s)
|
||||
`-aframes N` | 设置要录制的音频帧数 [-frames:a 的别名]
|
||||
`-aq q` | 设置音频质量(特定于编解码器,VBR) [-q:a 的别名]
|
||||
`-an` | 禁用录音
|
||||
`-acodec codec` | 设置音频编解码器。[-codec:a 的别名] 使用 'copy' 复制流。
|
||||
`-vol` | 以 256 的倍数更改音频音量,其中 256 = 100%(正常)音量。例如 512 = 200%
|
||||
`-newaudio` | 将新的音频流添加到当前输出流
|
||||
`-alang code` | 设置当前音频流的 ISO 639 语言代码(3 个字母)
|
||||
|
||||
视频编辑
|
||||
---
|
||||
@@ -116,13 +163,16 @@ $ ffmpeg -i input.avi -r 24 output.avi
|
||||
$ ffmpeg -r 1 -i input.m2v -r 24 output.avi
|
||||
```
|
||||
|
||||
将输入文件的帧速率(仅对原始格式有效)强制为 1 fps,将输出文件的帧速率强制为 24 fps
|
||||
将输入文件的帧速率(仅对原始格式有效)强制为 1 fps,将输出文件的帧速率强制为 24 fps
|
||||
|
||||
### 剪切视频部分
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
# 从1分45秒开始剪切2分35秒
|
||||
$ ffmpeg -i <input> -ss 00:01:45 -t 00:02:35 -vcodec copy -acodec copy <output>
|
||||
# 从1分45秒开始剪切到第4分20秒,与上一行等效
|
||||
$ ffmpeg -i <input> -ss 00:01:45 -to 00:04:20 -codec copy <output>
|
||||
$ ffmpeg -ss 00:00:30 -i orginalfile.mpg -t 00:00:05 -vcodec copy -acodec copy newfile.mpg
|
||||
# 从 4.5 秒开始的 5 秒长的视频
|
||||
$ ffmpeg -i in.mp4 -ss 4.5 -t 5 out.mp4
|
||||
@@ -184,11 +234,11 @@ $ ffmpeg -i in.mp4 -filter:v scale="538:trunc(ow/a/2)*2" -c:a copy out.mp4
|
||||
### 提取音频流
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mp4 -vn -acodec copy output.aac
|
||||
$ ffmpeg -i file.mp4 -vn -c copy output.aac
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
将`-vn`(无视频)与 `-acodec copy` 结合起来。请注意,输出文件扩展名必须与输入文件中的音频编解码器匹配,`-acodec copy` 才能工作。
|
||||
`-vn` (过滤视频),使用 `-c copy`,不会重新解码和编码,加快速度。
|
||||
|
||||
### 创建缩略图
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
@@ -207,6 +257,12 @@ $ ffmpeg -i <input file> -vf fps=1/60 thumbnails/thumb%03d.png
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 提取视频流
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mp4 -an -c copy output.mp4
|
||||
```
|
||||
|
||||
### 处理 id3 标签
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -233,8 +289,44 @@ $ ffmpeg -i file.aac -acodec mp3 -ar 44100 -ab 128000 output.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### -map 命令
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
`-map` 命令用于指定索引文件,以及索引文件中流类型和它的索引
|
||||
|
||||
----
|
||||
|
||||
```bash
|
||||
-map index:stram_type:stream_index
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`input_file_index` | 输入的文件索引(从 0 开始)
|
||||
`stream_type` | 指定文件流的类型(a -> 音频,v -> 视频,s -> 字幕)
|
||||
`stream_index` | 指定流类型的索引(从 0 开始)
|
||||
|
||||
将第一个输入文件的第二个音频拷贝到 out.mp3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mp4 -map 0:a:1 -c copy out.mp3
|
||||
```
|
||||
|
||||
将第一个输入文件的视频流和第二个输入文件的音频流拷贝到 out.mp4
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i i1.mp4 -i i2.mp4 -map 0:v -map 0:a -c copy out.mp4
|
||||
```
|
||||
|
||||
#### 反向 -map 命令
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
反向的 map 命令(在 map 命令的参数前加负号)。例如,`-map -0:a:0`,忽略第一个文件中的第一个音频流。
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 切换容器(转换类型)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
将容器从 `MKV` 更改为 `MP4`
|
||||
|
||||
@@ -259,31 +351,63 @@ $ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 0:v -map 1:a -codec:a copy
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
将视频延迟 3 秒(即将音频提前 3 秒)
|
||||
将视频延迟 3 秒(即将音频提前 3 秒)
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 1:v -map 0:a -codec:a copy -codec:v copy output.mov
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
|
||||
### 图片中的视频
|
||||
|
||||
如果您有多个编号的图像 image1.jpg、image2.jpg... 像这样从它们创建一个视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f image2 -i image%d.jpg video.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
多个编号的图像 image1.jpg、image2.jpg... 像这样从它们创建一个视频
|
||||
|
||||
### 将视频拆分为图像
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i video.mp4 image%d.jpg
|
||||
```
|
||||
|
||||
### 录屏
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
#### 查找所有可用设备
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f avfoundation -list_devices true -i ""
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
<span style="color:red">一定要选择好设备,根据设备进行配置。</sapn>
|
||||
|
||||
#### windows 下录屏
|
||||
|
||||
```bash
|
||||
$ ffmpeg -hide_banner -loglevel error -stats -f gdigrab -framerate 60 \
|
||||
-offset_x 0 -offset_y 0 -video_size 1920x1080 -draw_mouse 1 -i deskop \
|
||||
-c:v libx264 -r 60 -preset ultrafast -pix_fmt yuv420p -y screen_record.mp4
|
||||
```
|
||||
|
||||
#### mac 下录屏
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f avfoundation -i 1:0 -preset ultrafast out.mkv
|
||||
```
|
||||
|
||||
### 将输入文件转码为 DVD PAL 格式
|
||||
|
||||
```bash
|
||||
$ ffmpeg -y -threads 8 -i inFile -target pal-dvd -ac 2 -aspect 16:9 -acodec mp2 -ab 224000 -vf pad=0:0:0:0 outFile
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 转换为 Gif
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```bash
|
||||
$ ffmpeg -ss 2 -t 28 -i input.mp4 -vf "fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
|
||||
@@ -301,15 +425,27 @@ $ ffmpeg -i input.gif output.mov
|
||||
$ ffmpeg -i input.mov -codec:v copy -codec:a copy output.mp4
|
||||
```
|
||||
|
||||
### 移除音频
|
||||
### 转换为灰度
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mov -codec:v copy -an output.mov
|
||||
$ ffmpeg -y -i inFile -flags gray outFile
|
||||
```
|
||||
|
||||
### 字幕格式转换
|
||||
|
||||
```bash
|
||||
# srt -> ass
|
||||
$ ffmpeg -i subtitle.srt subtitle.ass
|
||||
# ass -> vtt
|
||||
$ ffmpeg -i subtitle.ass subtitle.vtt
|
||||
```
|
||||
|
||||
srt、ass、vtt 等格式之间可以相互转换
|
||||
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 字幕
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
将字幕写入视频
|
||||
|
||||
@@ -322,9 +458,24 @@ $ ffmpeg -i input.mov -filter:v 'subtitles=subtitles.srt' -codec:a copy output.m
|
||||
```bash
|
||||
$ ffmpeg -i input.mov -filter:v "subtitles=subtitles.srt:force_style='FontName=Menlo Bold,Fontsize=18'" -codec:a copy output.mov
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 制造 1 分钟的音频噪音
|
||||
|
||||
```bash
|
||||
$ ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -i /dev/urandom -ab 64K -f mp2 -acodec mp2 -y noise.mp2
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 从视频中提取图像
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i foo.avi -r 1 -s WxH -f image2 outFile%03d.png
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 音量
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
将音量减半
|
||||
|
||||
@@ -338,6 +489,171 @@ $ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=0.5' output.mov
|
||||
$ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=2' output.mov
|
||||
```
|
||||
|
||||
### 将图像文件转换为其他格式
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i foo0122.png foo.tiff
|
||||
```
|
||||
|
||||
pgm, ppm, pam, pgmyuv, jpeg, gif, png, tiff, sgi
|
||||
|
||||
### 将图像转换为 AVI 文件
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将 WAV 文件转换为 MP3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_song.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 从视频中提取音频,将其转码为 MP3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将 .avi 转换为 .flv
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output.flv
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将图片附加到 mp3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将视频与声音文件混合
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i song.wav -i source_video.avi outvideo.mpg
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 编写带有 ID3v2.3 页眉和 ID3v1 页脚的 mp3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i inFile -id3v2_version 3 -write_id3v1 1 outFile.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 连接输入文件
|
||||
|
||||
```bash
|
||||
$ cat inFile1 inFile2 | ffmpeg -f mpeg -i - -vcodec copy -acodec copy outFile.mpg
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 使用比特率和 mp3 音频的编解码器对剪辑进行编码
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i clip.avi -vcodec libxvid -b 800000 -acodec libmp3lame -ab 128 new-clip.avi
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将音频流与来自不同文件的视频流合并
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i audioS.mp4 -i videoS.mp4 -c copy -map 0:a -map 1:v outFile.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 合并视频
|
||||
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
合并相同规格(解码/分辨率/帧率)视频
|
||||
|
||||
```bash
|
||||
# mylist.txt >>>
|
||||
file '1.mp4'
|
||||
file '2.mp4'
|
||||
file '3.mp4'
|
||||
|
||||
# 这些文件是相对路径,如使用绝对路径需要添加 `-safe 0` 参数
|
||||
$ ffmpeg -f concat -i mylist.txt -c copy output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并当前目录下所有视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并不同规格视频,保证视频不变形
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i 1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp1.ts
|
||||
$ ffmpeg -i 2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp2.ts
|
||||
$ ffmpeg -i 3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp3.ts
|
||||
|
||||
$ ffmpeg -threads 2 -i "concat:tmp1.ts|tmp2.ts|tmp3.ts" -vf "scale=720:1080:force_original_aspect_ratio=decrease,pad=720:1080:(ow-iw)/2:(oh-ih)/2" -pix_fmt yuvj420p -shortest -y output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并不同解码视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input1.mp4 -i input2.webm -i input3.mov \
|
||||
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \
|
||||
-map "[outv]" -map "[outa]" output.mkv
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并视频并重新编码音频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f concat -i mylist.txt -c:v copy -c:a flac -strict -2 output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 合并音频与图片
|
||||
|
||||
合并多个音频,自定义背景图片,生成视频音乐
|
||||
|
||||
```bash
|
||||
# mylist.txt >>>
|
||||
file '1.mp3'
|
||||
file '2.mp3'
|
||||
file '3.mp3'
|
||||
|
||||
# OBS: 46500 = 25:50 minutes * 60 * 30fps
|
||||
# echo "00:25:50" | awk -F: '{ print (($1 * 3600) + ($2 * 60) + $3) * 30 }'
|
||||
$ ffmpeg -y -loop 1 -i cover.jpg -f concat -i mylist.txt -c:v libx264 -r 30 -pix_fmt yuv420p -vframes 46500 -c:a aac -b:a 192k -strict experimental -shortest output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 添加水印
|
||||
|
||||
在视频左上方 20,20 的位置插入 logo.png 图片
|
||||
|
||||
```bash
|
||||
# -b:v 548k 可选参数,设置视频比特率,默认 200k 最好设置与原视频一致
|
||||
ffmpeg -i 1.mp4 -acodec copy -b:v 548k -vf "movie=logo.png[watermark];[in][watermark]overlay=20:20" output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 去除水印
|
||||
|
||||
设置一个矩形覆盖区域 x=10:y=10:w=120:h=45
|
||||
|
||||
```bash
|
||||
# show=1 为可选参数,设置显示边框,方便调试用的
|
||||
ffmpeg -i 1.mp4 -b:v 548k -vf delogo=x=10:y=10:w=120:h=45:show=1 output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
@@ -345,3 +661,4 @@ $ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=2' output.mov
|
||||
- [FFmpeg Cheat Sheet](https://lzone.de/cheat-sheet/ffmpeg) _(lzone.de)_
|
||||
- [FFmpeg Cheat Sheet](https://devhints.io/ffmpeg) _(devhints.io)_
|
||||
- [FFmpeg Cheat Sheet](https://github.com/yuanqing/ffmpeg-cheatsheet) _(github.com)_
|
||||
- [FFmpeg Cheat Sheet](https://cheatography.com/thetartankilt/cheat-sheets/ffmpeg/) _(cheatography.com)_
|
||||
|
@@ -39,7 +39,6 @@ $ find . -name "json_*"
|
||||
| `-mindepth` | find / -mindepth 3 -maxdepth 5 -name pass | 在子目录级别 2 和 4 之间 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 类型
|
||||
|
||||
| | |
|
||||
@@ -224,7 +223,6 @@ $ find . -type d -empty
|
||||
$ find . -type f -empty -delete
|
||||
```
|
||||
|
||||
|
||||
查找日期和时间
|
||||
-------------
|
||||
|
||||
|
@@ -374,15 +374,20 @@ Git 技巧
|
||||
### 重命名分支
|
||||
|
||||
- **重命名**为`new`
|
||||
|
||||
```shell
|
||||
$ git branch -m <new>
|
||||
$ git branch -m <old> <new> #重命名分支
|
||||
```
|
||||
|
||||
- **推送**并重置
|
||||
|
||||
```shell
|
||||
$ git push origin -u <new>
|
||||
```
|
||||
|
||||
- **删除**远程分支
|
||||
|
||||
```shell
|
||||
$ git push origin --delete <old> #方法1
|
||||
$ git push origin :oldBranchName #方法2
|
||||
@@ -827,7 +832,6 @@ $ git config --global --unset http.https://github.com.proxy
|
||||
$ git config --global --unset https.https://github.com.proxy
|
||||
```
|
||||
|
||||
|
||||
### clone 最新一次提交
|
||||
|
||||
```bash
|
||||
|
@@ -212,6 +212,7 @@ jobs:
|
||||
```shell
|
||||
jobs.<job_id>.environment
|
||||
```
|
||||
|
||||
使用单一环境名称的示例
|
||||
|
||||
```yml
|
||||
@@ -251,7 +252,6 @@ steps:
|
||||
|
||||
设置环境变量的示例
|
||||
|
||||
|
||||
```yml
|
||||
env:
|
||||
MY_ENV_VAR: ${{ <expression> }}
|
||||
|
128
docs/gmail.md
Normal file
@@ -0,0 +1,128 @@
|
||||
Gmail 备忘清单
|
||||
===
|
||||
|
||||
本备忘单总结了常用的 [Gmail](https://gmail.com/) 快捷键,以供快速参考。
|
||||
|
||||
Gmail 快捷键
|
||||
---
|
||||
|
||||
### Gmail 导航
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`u` | 返回话题列表(或刷新话题列表)
|
||||
`k` / `j` | 较新/较旧的对话
|
||||
`o` or `Enter` | 打开对话; 折叠/展开
|
||||
`p` / `n` | 阅读上一条/下一条消息
|
||||
<code>\`</code> | 转到下一个收件箱部分
|
||||
`~` | 转到上一个收件箱部分
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 应用程序
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`c` | 撰写
|
||||
`d` | 添加 cc 撰写
|
||||
`b` | 添加 cc 和 bcc 撰写
|
||||
`/` | 搜索
|
||||
`q` | 焦点聊天联系人搜索
|
||||
`?` | 打开快捷方式帮助
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 操作
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`,` | 将焦点移至工具栏
|
||||
`x` | 选择对话
|
||||
`s` | 旋转超级巨星
|
||||
`y` | 删除标签
|
||||
`e` | 档案
|
||||
`m` | 忽略对话
|
||||
`!` | 报告为垃圾邮件
|
||||
`v` | 打开移动到菜单
|
||||
`#` | 移到废纸篓
|
||||
`r` | 回复
|
||||
`Shift+r` | 在新窗口中回复
|
||||
`a` | 全部回复
|
||||
`Shift+a` | 在新窗口中回复所有
|
||||
`f` | 向前
|
||||
`Shift+f` | 在新窗口中转发
|
||||
`Shift+n` | 更新对话
|
||||
`Tab` 然后 `Enter` | 发邮件
|
||||
`Esc` | 焦点最后聊天痣
|
||||
`]` / `[` | 删除并转到上一个/下一个
|
||||
`}` / `{` | 存档并转到上一个/下一个
|
||||
`z` | 撤消上一个操作
|
||||
`.` | 打开更多操作菜单
|
||||
`l` | 打开标签菜单
|
||||
`Shift+i` | 标记为已读
|
||||
`Shift+u` | 标记为未读
|
||||
`_` | 将所选邮件标记为未读
|
||||
`Ctrl+s` | 保存草稿
|
||||
`+` 或 `=` | 标记为重要
|
||||
`-` | 标记为不重要
|
||||
`Shift+l` | 喜欢/不喜欢嗡嗡声
|
||||
`h` | 抢先看
|
||||
`g` 然后 `p` | 打个电话
|
||||
`&` | 启动老蛇
|
||||
`Shift+t` | 将对话添加到任务
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 跳转
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`g` 然后 `i` | 打开收件箱
|
||||
`g` 然后 `s` | 打开已加星标的对话
|
||||
`g` 然后 `t` | 打开已发送消息
|
||||
`g` 然后 `d` | 打开草稿
|
||||
`g` 然后 `a` | 打开所有消息
|
||||
`g` 然后 `c` | 打开联系人
|
||||
`g` 然后 `b` | 去嗡嗡声
|
||||
`g` 然后 `l` | 转到标签
|
||||
`g` 然后 `k` | 前往任务
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 主题列表选择
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`*` 然后 `a` | 选择所有对话
|
||||
`*` 然后 `n` | 取消选择所有对话
|
||||
`*` 然后 `r` | 选择阅读对话
|
||||
`*` 然后 `u` | 选择未读对话
|
||||
`*` 然后 `s` | 选择加星标的对话
|
||||
`*` 然后 `t` | 选择未加星标的对话
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 搜索语法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`from:[arg]` | 从
|
||||
`to:[arg]` | 至
|
||||
`label:[arg]` | 标签
|
||||
`subject:[arg]` | 主题
|
||||
`-[arg]` | 不包含
|
||||
`has:attachment` | 有附件
|
||||
`filename:[filename]` | 附件文件名
|
||||
`before:2011/11/20` | 之前(日期)
|
||||
`after:2011/11/20` | 之后(日期)
|
||||
`from:annie` 或 `from:david` | 或运算符
|
||||
`list:[arg]` | 邮件列表
|
||||
`subject:(word1 word2)` | 组词
|
||||
`in:anywhere` | 在所有框中搜索(垃圾邮件和垃圾邮件除外)
|
||||
`in:trash in:inbox in:spam` | 在特定框中搜索
|
||||
`is:starred is:read is:unread` | 搜索特定消息
|
||||
`is:chat` | 在聊天中搜索
|
||||
`cc:[arg] bcc:[arg]` | 搜索副本收件人
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 提示和技巧
|
||||
|
||||
- 按 `u` 刷新话题列表
|
||||
- 对于多选,选择一个对话,然后 `shift+单击`另一个对话以选择其间的所有对话
|
||||
- 在主题中添加 `EOM`(消息结尾)以避免 `no-text-in-body` 警告
|
144
docs/golang.md
@@ -89,7 +89,7 @@ Golang 基本类型
|
||||
s1 := "Hello" + "World"
|
||||
s2 := `A "raw" string literal
|
||||
can include line breaks.`
|
||||
// 输出:11
|
||||
// 输出:10
|
||||
fmt.Println(len(s1))
|
||||
// 输出:Hello
|
||||
fmt.Println(string(s1[0:5]))
|
||||
@@ -247,7 +247,6 @@ s := strconv.Itoa(i)
|
||||
fmt.Println(s) // Outputs: 90
|
||||
```
|
||||
|
||||
|
||||
Golang 字符串
|
||||
--------
|
||||
|
||||
@@ -256,18 +255,18 @@ Golang 字符串
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
s "strings"
|
||||
"fmt"
|
||||
s "strings"
|
||||
)
|
||||
func main() {
|
||||
/* 需要将字符串导入为 s */
|
||||
fmt.Println(s.Contains("test", "e"))
|
||||
fmt.Println(s.Contains("test", "e"))
|
||||
/* 内置 */
|
||||
fmt.Println(len("hello")) // => 5
|
||||
// 输出: 101
|
||||
fmt.Println("hello"[1])
|
||||
fmt.Println("hello"[1])
|
||||
// 输出: e
|
||||
fmt.Println(string("hello"[1]))
|
||||
fmt.Println(string("hello"[1]))
|
||||
}
|
||||
```
|
||||
|
||||
@@ -277,38 +276,38 @@ func main() {
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
type point struct {
|
||||
x, y int
|
||||
x, y int
|
||||
}
|
||||
func main() {
|
||||
p := point{1, 2}
|
||||
fmt.Printf("%v\n", p) // => {1 2}
|
||||
fmt.Printf("%+v\n", p) // => {x:1 y:2}
|
||||
fmt.Printf("%#v\n", p) // => main.point{x:1, y:2}
|
||||
fmt.Printf("%T\n", p) // => main.point
|
||||
fmt.Printf("%t\n", true) // => TRUE
|
||||
fmt.Printf("%d\n", 123) // => 123
|
||||
fmt.Printf("%b\n", 14) // => 1110
|
||||
fmt.Printf("%c\n", 33) // => !
|
||||
fmt.Printf("%x\n", 456) // => 1c8
|
||||
fmt.Printf("%f\n", 78.9) // => 78.9
|
||||
fmt.Printf("%e\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%E\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%s\n", "\"string\"") // => "string"
|
||||
fmt.Printf("%q\n", "\"string\"") // => "\"string\""
|
||||
fmt.Printf("%x\n", "hex this") // => 6.86578E+15
|
||||
fmt.Printf("%p\n", &p) // => 0xc00002c040
|
||||
fmt.Printf("|%6d|%6d|\n", 12, 345) // => | 12| 345|
|
||||
fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) // => | 1.20| 3.45|
|
||||
fmt.Printf("|%-6.2f|%-6.2f|\n", 1.2, 3.45) // => |1.20 |3.45 |
|
||||
fmt.Printf("|%6s|%6s|\n", "foo", "b") // => | foo| b|
|
||||
fmt.Printf("|%-6s|%-6s|\n", "foo", "b") // => |foo |b |
|
||||
s := fmt.Sprintf("a %s", "string")
|
||||
fmt.Println(s)
|
||||
fmt.Fprintf(os.Stderr, "an %s\n", "error")
|
||||
p := point{1, 2}
|
||||
fmt.Printf("%v\n", p) // => {1 2}
|
||||
fmt.Printf("%+v\n", p) // => {x:1 y:2}
|
||||
fmt.Printf("%#v\n", p) // => main.point{x:1, y:2}
|
||||
fmt.Printf("%T\n", p) // => main.point
|
||||
fmt.Printf("%t\n", true) // => TRUE
|
||||
fmt.Printf("%d\n", 123) // => 123
|
||||
fmt.Printf("%b\n", 14) // => 1110
|
||||
fmt.Printf("%c\n", 33) // => !
|
||||
fmt.Printf("%x\n", 456) // => 1c8
|
||||
fmt.Printf("%f\n", 78.9) // => 78.9
|
||||
fmt.Printf("%e\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%E\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%s\n", "\"string\"") // => "string"
|
||||
fmt.Printf("%q\n", "\"string\"") // => "\"string\""
|
||||
fmt.Printf("%x\n", "hex this") // => 6.86578E+15
|
||||
fmt.Printf("%p\n", &p) // => 0xc00002c040
|
||||
fmt.Printf("|%6d|%6d|\n", 12, 345) // => | 12| 345|
|
||||
fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) // => | 1.20| 3.45|
|
||||
fmt.Printf("|%-6.2f|%-6.2f|\n", 1.2, 3.45) // => |1.20 |3.45 |
|
||||
fmt.Printf("|%6s|%6s|\n", "foo", "b") // => | foo| b|
|
||||
fmt.Printf("|%-6s|%-6s|\n", "foo", "b") // => |foo |b |
|
||||
s := fmt.Sprintf("a %s", "string")
|
||||
fmt.Println(s)
|
||||
fmt.Fprintf(os.Stderr, "an %s\n", "error")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -316,8 +315,8 @@ func main() {
|
||||
|
||||
### 函数实例
|
||||
|
||||
| 实例 | Result |
|
||||
|-------------------------------|-------------|
|
||||
| 实例 | Result |
|
||||
| ----------------------------- | ----------- |
|
||||
| Contains("test", "es") | true |
|
||||
| Count("test", "t") | 2 |
|
||||
| HasPrefix("test", "te") | true |
|
||||
@@ -441,16 +440,16 @@ Golang 结构和映射
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"fmt"
|
||||
)
|
||||
type Vertex struct {
|
||||
X int
|
||||
Y int
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
func main() {
|
||||
v := Vertex{1, 2}
|
||||
v.X = 4
|
||||
fmt.Println(v.X, v.Y) // => 4 2
|
||||
v := Vertex{1, 2}
|
||||
v.X = 4
|
||||
fmt.Println(v.X, v.Y) // => 4 2
|
||||
}
|
||||
```
|
||||
|
||||
@@ -569,6 +568,7 @@ sum(nums...) // => [1 2 3 4] 10
|
||||
```go
|
||||
import --> const --> var --> init()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
@@ -701,22 +701,22 @@ Golang 并发
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
func f(from string) {
|
||||
for i := 0; i < 3; i++ {
|
||||
fmt.Println(from, ":", i)
|
||||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
fmt.Println(from, ":", i)
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
f("direct")
|
||||
go f("goroutine")
|
||||
go func(msg string) {
|
||||
fmt.Println(msg)
|
||||
}("going")
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println("done")
|
||||
f("direct")
|
||||
go f("goroutine")
|
||||
go func(msg string) {
|
||||
fmt.Println(msg)
|
||||
}("going")
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println("done")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -725,26 +725,26 @@ func main() {
|
||||
### WaitGroup
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```golang
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
func w(id int, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
fmt.Printf("%d starting\n", id)
|
||||
time.Sleep(time.Second)
|
||||
fmt.Printf("%d done\n", id)
|
||||
defer wg.Done()
|
||||
fmt.Printf("%d starting\n", id)
|
||||
time.Sleep(time.Second)
|
||||
fmt.Printf("%d done\n", id)
|
||||
}
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
for i := 1; i <= 5; i++ {
|
||||
wg.Add(1)
|
||||
go w(i, &wg)
|
||||
}
|
||||
wg.Wait()
|
||||
var wg sync.WaitGroup
|
||||
for i := 1; i <= 5; i++ {
|
||||
wg.Add(1)
|
||||
go w(i, &wg)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
```
|
||||
|
||||
@@ -916,6 +916,7 @@ func main() {
|
||||
-------------
|
||||
|
||||
### 关键字(Keywords)
|
||||
|
||||
- break
|
||||
- default
|
||||
- func
|
||||
@@ -945,8 +946,8 @@ func main() {
|
||||
|
||||
### 运算符和标点符号
|
||||
|
||||
| | | | | | | | | |
|
||||
|---|----|-----|-----|------|----|-----|---|---|
|
||||
| | | | | | | | | |
|
||||
| --- | ---- | ----- | ----- | ------ | ---- | ----- | --- | --- |
|
||||
| `+` | `&` | `+=` | `&=` | `&&` | `==` | `!=` | `(` | `)` |
|
||||
| `-` | `\|` | `-=` | `\|=` | `\|\|` | `<` | `<=` | `[` | `]` |
|
||||
| `*` | `^` | `*=` | `^=` | `<-` | `>` | `>=` | `{` | `}` |
|
||||
@@ -956,6 +957,7 @@ func main() {
|
||||
|
||||
另见
|
||||
--------
|
||||
|
||||
- [Devhints](https://devhints.io/go) _(devhints.io)_
|
||||
- [A tour of Go](https://tour.golang.org/welcome/1) _(tour.golang.org)_
|
||||
- [Golang wiki](https://github.com/golang/go/wiki/) _(github.com)_
|
||||
|
653
docs/graphql.md
Normal file
@@ -0,0 +1,653 @@
|
||||
GraphQL 备忘清单
|
||||
===
|
||||
|
||||
这份快速参考备忘单提供了 [GraphQL](https://graphql.org/) 的简要概述
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 概述
|
||||
|
||||
- RESTful API 的另一种方法
|
||||
- GraphQL 是一种 API 查询语言
|
||||
- 使用清晰的共享术语轻松描述 GraphQL API 的形状。
|
||||
- 客户端发出查询/突变以读取和更新数据
|
||||
- GraphQL 语法可以表达复杂的实体关系
|
||||
- 用 [不同语言](https://graphql.org/code/) 实现 GraphQL 的库
|
||||
|
||||
[GraphQL](https://graphql.org/)
|
||||
|
||||
### Schema
|
||||
|
||||
:-|-
|
||||
:-|-
|
||||
`schema` | GraphQL 架构定义
|
||||
`query` | 读取和遍历数据
|
||||
`mutation` | 修改数据或触发动作
|
||||
`subscription` | 发生事件时运行查询
|
||||
|
||||
### 内置标量类型
|
||||
|
||||
:-|-
|
||||
:-|-
|
||||
`Int` | 有符号 32 位整数
|
||||
`Float` | 有符号双精度浮点值
|
||||
`String` | UTF-8 字符序列
|
||||
`Boolean` | 对或错布尔值类型
|
||||
`ID` | 唯一标识符
|
||||
|
||||
### 类型定义
|
||||
|
||||
:-|-
|
||||
:-|-
|
||||
`scalar` | 标量类型
|
||||
`type` | 对象类型
|
||||
`interface` | 接口类型
|
||||
`union` | 联合类型
|
||||
`enum` | 枚举类型
|
||||
`input` | 输入对象类型
|
||||
|
||||
### 类型修饰符
|
||||
|
||||
:-|-
|
||||
:-|-
|
||||
`String` | 可空字符串
|
||||
`String!` | 非空字符串
|
||||
`[String]` | 可空字符串列表
|
||||
`[String]!` | 可空字符串的非空列表
|
||||
`[String!]!` | 非空字符串的非空列表
|
||||
|
||||
### 输入参数
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### 基本输入
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
users(limit: Int): [User]
|
||||
}
|
||||
```
|
||||
|
||||
#### 输入默认值
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
users(limit: Int = 10): [User]
|
||||
}
|
||||
```
|
||||
|
||||
#### 具有多个参数的输入
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
users(limit: Int, sort: String): [User]
|
||||
}
|
||||
```
|
||||
|
||||
#### 具有多个参数和默认值的输入
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
users(limit: Int = 10, sort: String): [User]
|
||||
}
|
||||
type Query {
|
||||
users(limit: Int, sort: String = "asc"): [User]
|
||||
}
|
||||
type Query {
|
||||
users(limit: Int = 10, sort: String = "asc"): [User]
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 输入类型
|
||||
|
||||
```graphql
|
||||
input ListUsersInput {
|
||||
limit: Int
|
||||
since_id: ID
|
||||
}
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
users(params: ListUsersInput): [User]!
|
||||
}
|
||||
```
|
||||
|
||||
### 自定义标量
|
||||
|
||||
```graphql
|
||||
scalar Url
|
||||
type User {
|
||||
name: String
|
||||
homepage: Url
|
||||
}
|
||||
```
|
||||
|
||||
### 接口
|
||||
|
||||
```graphql
|
||||
interface Foo {
|
||||
is_foo: Boolean
|
||||
}
|
||||
interface Goo {
|
||||
is_goo: Boolean
|
||||
}
|
||||
type Bar implements Foo {
|
||||
is_foo: Boolean
|
||||
is_bar: Boolean
|
||||
}
|
||||
type Baz implements Foo, Goo {
|
||||
is_foo: Boolean
|
||||
is_goo: Boolean
|
||||
is_baz: Boolean
|
||||
}
|
||||
```
|
||||
|
||||
实现一个或多个接口的对象
|
||||
|
||||
### 联合
|
||||
|
||||
```graphql
|
||||
type Foo {
|
||||
name: String
|
||||
}
|
||||
type Bar {
|
||||
is_bar: String
|
||||
}
|
||||
union SingleUnion = Foo
|
||||
union MultipleUnion = Foo | Bar
|
||||
type Root {
|
||||
single: SingleUnion
|
||||
multiple: MultipleUnion
|
||||
}
|
||||
```
|
||||
|
||||
一个或多个对象的联合
|
||||
|
||||
### 枚举
|
||||
|
||||
```graphql
|
||||
enum USER_STATE {
|
||||
NOT_FOUND
|
||||
ACTIVE
|
||||
INACTIVE
|
||||
SUSPENDED
|
||||
}
|
||||
type Root {
|
||||
stateForUser(userID: ID!): USER_STATE!
|
||||
users(state: USER_STATE, limit: Int = 10): [User]
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
查询和变更(Mutations)
|
||||
---
|
||||
|
||||
### 字段
|
||||
|
||||
```graphql
|
||||
{
|
||||
hero {
|
||||
name
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"hero": {
|
||||
"name": "R2-D2"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 查询可以有注释
|
||||
|
||||
```graphql
|
||||
{
|
||||
hero {
|
||||
name
|
||||
# 查询可以有注释!
|
||||
friends {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"hero": {
|
||||
"name": "R2-D2",
|
||||
"friends": [
|
||||
{ "name": "Luke Skywalker" },
|
||||
{ "name": "Han Solo" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 参数 Arguments
|
||||
|
||||
```graphql
|
||||
{
|
||||
human(id: "1000") {
|
||||
name
|
||||
height
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"human": {
|
||||
"name": "Luke Skywalker",
|
||||
"height": 1.72
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 不同类型的参数
|
||||
|
||||
```graphql
|
||||
{
|
||||
human(id: "1000") {
|
||||
name
|
||||
height(unit: FOOT)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"human": {
|
||||
"name": "Luke Skywalker",
|
||||
"height": 5.6430448
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 别名(Aliases)
|
||||
|
||||
```graphql
|
||||
{
|
||||
empireHero: hero(episode: EMPIRE) {
|
||||
name
|
||||
}
|
||||
jediHero: hero(episode: JEDI) {
|
||||
name
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"empireHero": {
|
||||
"name": "Luke Skywalker"
|
||||
},
|
||||
"jediHero": {
|
||||
"name": "R2-D2"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 片段(Fragments)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```graphql
|
||||
{
|
||||
leftComparison: hero(episode: EMPIRE) {
|
||||
...comparisonFields
|
||||
}
|
||||
rightComparison: hero(episode: JEDI) {
|
||||
...comparisonFields
|
||||
}
|
||||
}
|
||||
|
||||
fragment comparisonFields on Character {
|
||||
name
|
||||
appearsIn
|
||||
friends {
|
||||
name
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"leftComparison": {
|
||||
"name": "Luke Skywalker",
|
||||
"appearsIn": [
|
||||
"NEWHOPE",
|
||||
"EMPIRE",
|
||||
"JEDI"
|
||||
],
|
||||
"friends": [
|
||||
{ "name": "Han Solo" },
|
||||
{ "name": "Leia Organa" },
|
||||
{ "name": "C-3PO" },
|
||||
{ "name": "R2-D2" }
|
||||
]
|
||||
},
|
||||
"rightComparison": {
|
||||
"name": "R2-D2",
|
||||
"appearsIn": [
|
||||
"NEWHOPE",
|
||||
"EMPIRE",
|
||||
"JEDI"
|
||||
],
|
||||
"friends": [
|
||||
{ "name": "Luke Skywalker" },
|
||||
{ "name": "Han Solo" },
|
||||
{ "name": "Leia Organa" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 在片段内使用变量
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```graphql
|
||||
query HeroComparison($first: Int = 3) {
|
||||
leftComparison: hero(episode: EMPIRE) {
|
||||
...comparisonFields
|
||||
}
|
||||
rightComparison: hero(episode: JEDI) {
|
||||
...comparisonFields
|
||||
}
|
||||
}
|
||||
|
||||
fragment comparisonFields on Character {
|
||||
name
|
||||
friendsConnection(first: $first) {
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"leftComparison": {
|
||||
"name": "Luke Skywalker",
|
||||
"friendsConnection": {
|
||||
"totalCount": 4,
|
||||
"edges": [
|
||||
{
|
||||
"node": {
|
||||
"name": "Han Solo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"name": "Leia Organa"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"rightComparison": {
|
||||
"name": "R2-D2",
|
||||
"friendsConnection": {
|
||||
"totalCount": 3,
|
||||
"edges": [
|
||||
{
|
||||
"node": {
|
||||
"name": "Luke Skywalker"
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"name": "Han Solo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 操作名称(Operation name)
|
||||
|
||||
```graphql
|
||||
query HeroNameAndFriends {
|
||||
hero {
|
||||
name
|
||||
friends {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"hero": {
|
||||
"name": "R2-D2",
|
||||
"friends": [
|
||||
{ "name": "Luke Skywalker" },
|
||||
{ "name": "Han Solo" },
|
||||
{ "name": "Leia Organa" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 变量(Variables)
|
||||
|
||||
```graphql
|
||||
# { "graphiql": true, "variables": { "episode": JEDI } }
|
||||
query HeroNameAndFriends($episode: Episode) {
|
||||
hero(episode: $episode) {
|
||||
name
|
||||
friends {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
变量前缀必须为 `$`,后跟其类型
|
||||
|
||||
### 默认变量(Default variables)
|
||||
|
||||
```graphql
|
||||
query HeroNameAndFriends($episode: Episode = "JEDI") {
|
||||
hero(episode: $episode) {
|
||||
name
|
||||
friends {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 指令(Directives)
|
||||
|
||||
```graphql
|
||||
query Hero($episode: Episode, $withFriends: Boolean!) {
|
||||
hero(episode: $episode) {
|
||||
name
|
||||
friends @include(if: $withFriends) {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
----
|
||||
|
||||
```graphql
|
||||
{ "episode": "JEDI", "withFriends": false }
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": { "hero": { "name": "R2-D2" } }
|
||||
}
|
||||
```
|
||||
|
||||
- `@include(if: Boolean)` 仅在参数为 `true` 时,包含此字段
|
||||
- `@skip(if: Boolean)` 如果参数为 `true`,跳过此字段
|
||||
|
||||
### 变更(Mutations)
|
||||
|
||||
```graphql
|
||||
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
|
||||
createReview(episode: $ep, review: $review) {
|
||||
stars
|
||||
commentary
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
----
|
||||
|
||||
```
|
||||
{
|
||||
"ep": "JEDI",
|
||||
"review": {
|
||||
"stars": 5,
|
||||
"commentary": "This is a great movie!"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"createReview": {
|
||||
"stars": 5,
|
||||
"commentary": "This is a great movie!"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 内联片段(Inline Fragments)
|
||||
|
||||
```graphql
|
||||
query HeroForEpisode($ep: Episode!) {
|
||||
hero(episode: $ep) {
|
||||
name
|
||||
... on Droid {
|
||||
primaryFunction
|
||||
}
|
||||
... on Human {
|
||||
height
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```graphql
|
||||
{ "ep": "JEDI" }
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"hero": {
|
||||
"name": "R2-D2",
|
||||
"primaryFunction": "Astromech"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 元字段(Meta fields)
|
||||
|
||||
```graphql
|
||||
{
|
||||
search(text: "an") {
|
||||
__typename
|
||||
... on Human {
|
||||
name
|
||||
}
|
||||
... on Droid {
|
||||
name
|
||||
}
|
||||
... on Starship {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"search": [
|
||||
{
|
||||
"__typename": "Human",
|
||||
"name": "Han Solo"
|
||||
},
|
||||
{
|
||||
"__typename": "Human",
|
||||
"name": "Leia Organa"
|
||||
},
|
||||
{
|
||||
"__typename": "Starship",
|
||||
"name": "TIE Advanced x1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
另见
|
||||
-------
|
||||
|
||||
- [GraphQL Schema Language Cheat Sheet](https://github.com/sogko/graphql-schema-language-cheat-sheet) _(github.com)_
|
@@ -3,7 +3,6 @@ Grep 备忘清单
|
||||
|
||||
本备忘单旨在快速提醒使用命令行程序 grep 所涉及的主要概念,并假设您已经了解其用法。
|
||||
|
||||
|
||||
入门
|
||||
------
|
||||
<!--rehype:body-class=cols-5-->
|
||||
@@ -31,7 +30,6 @@ $ grep 'mellon' myfile.txt
|
||||
|
||||
文件名中接受通配符。
|
||||
|
||||
|
||||
### 选项示例
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -51,7 +49,6 @@ $ grep 'mellon' myfile.txt
|
||||
| `-o` | grep -o search_string filename | 只显示字符串的匹配部分
|
||||
| `-n` | grep -n "go" demo.txt | 显示匹配的行号
|
||||
|
||||
|
||||
Grep 正则表达式
|
||||
-------
|
||||
|
||||
@@ -97,13 +94,12 @@ Grep 正则表达式
|
||||
`[0-9]` | 任何数字
|
||||
`[0-9A-Za-z]` | 任何大小写字母或数字
|
||||
|
||||
|
||||
### 位置
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`^ ` | 行的开头
|
||||
`$ ` | 行结束
|
||||
`^` | 行的开头
|
||||
`$` | 行结束
|
||||
`^$` | 空行
|
||||
`\<` | 词的开头
|
||||
`\>` | 词尾
|
||||
|
@@ -3,7 +3,6 @@ HTML 字符实体备忘清单
|
||||
|
||||
此备忘清单是 HTML 实体及其编号和名称的完整列表。还包括可以用 HTML 表示的 ASCII 字符的完整列表。
|
||||
|
||||
|
||||
HTML 字符实体引用
|
||||
------
|
||||
<!--rehype:body-class=cols-1-->
|
||||
|
30
docs/html.md
@@ -43,6 +43,7 @@ HTML 备忘清单
|
||||
<p>我来自快速参考</p>
|
||||
<p>分享快速参考备忘单。</p>
|
||||
```
|
||||
|
||||
请参阅:[段落元素](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/p)
|
||||
|
||||
### HTML 链接
|
||||
@@ -68,8 +69,6 @@ HTML 备忘清单
|
||||
|
||||
请参阅:[\<a> 属性](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/a#attributes)
|
||||
|
||||
|
||||
|
||||
### Image 标签
|
||||
|
||||
```html
|
||||
@@ -163,10 +162,8 @@ HTML 备忘清单
|
||||
src="https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik">
|
||||
</iframe>
|
||||
|
||||
|
||||
请参阅:[内联框架元素](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/iframe)
|
||||
|
||||
|
||||
### HTML 中的 JavaScript
|
||||
|
||||
```html
|
||||
@@ -176,7 +173,6 @@ HTML 备忘清单
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
#### 外部 JavaScript
|
||||
|
||||
```html
|
||||
@@ -186,7 +182,6 @@ HTML 备忘清单
|
||||
</body>
|
||||
```
|
||||
|
||||
|
||||
### HTML 中的 CSS
|
||||
|
||||
```html
|
||||
@@ -206,8 +201,6 @@ HTML 备忘清单
|
||||
</head>
|
||||
```
|
||||
|
||||
|
||||
|
||||
HTML5 标签
|
||||
-------------
|
||||
|
||||
@@ -227,7 +220,6 @@ HTML5 标签
|
||||
</body>
|
||||
```
|
||||
|
||||
|
||||
### 标题导航
|
||||
|
||||
```html
|
||||
@@ -242,7 +234,6 @@ HTML5 标签
|
||||
</header>
|
||||
```
|
||||
|
||||
|
||||
### HTML5 Tags
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
@@ -281,7 +272,6 @@ HTML5 标签
|
||||
[video](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/video) | 嵌入视频
|
||||
[wbr](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/wbr) | 换行机会
|
||||
|
||||
|
||||
### HTML5 Video
|
||||
|
||||
```html
|
||||
@@ -339,7 +329,6 @@ HTML5 标签
|
||||
音 <rp>(</rp><rt>yīn</rt><rp>)</rp>
|
||||
</ruby>
|
||||
|
||||
|
||||
### HTML5 kdi
|
||||
|
||||
```html
|
||||
@@ -358,7 +347,6 @@ HTML5 标签
|
||||
<li>User <bdi>إيان</bdi>: 90 points</li>
|
||||
</ul>
|
||||
|
||||
|
||||
### HTML5 progress
|
||||
|
||||
```html
|
||||
@@ -375,7 +363,6 @@ HTML5 标签
|
||||
|
||||
<p>我爱<mark>备忘清单</mark></p>
|
||||
|
||||
|
||||
HTML 表格
|
||||
--------------
|
||||
|
||||
@@ -517,7 +504,6 @@ HTML 表单
|
||||
<label for="ck">记住我</label>
|
||||
</form>
|
||||
|
||||
|
||||
HTML `<form>` 元素用于收集信息并将其发送到外部源。
|
||||
|
||||
### Form 属性
|
||||
@@ -602,13 +588,16 @@ Textarea 是一个多行文本输入控件
|
||||
单选按钮用于让用户只选择一个
|
||||
|
||||
### Checkboxes
|
||||
|
||||
```html
|
||||
<input type="checkbox" name="s" id="soc">
|
||||
<label for="soc">Soccer</label>
|
||||
<input type="checkbox" name="s" id="bas">
|
||||
<label for="bas">Baseball</label>
|
||||
```
|
||||
|
||||
#### ↓ 预览
|
||||
|
||||
<form style="padding: 20px;">
|
||||
<input type="checkbox" name="sports" id="soccer">
|
||||
<label for="soccer">Soccer</label>
|
||||
@@ -718,7 +707,6 @@ Textarea 是一个多行文本输入控件
|
||||
|
||||
`将数据提交到服务器` 重置为默认值
|
||||
|
||||
|
||||
HTML input 标签
|
||||
-----------
|
||||
<!--rehype:body-class=cols-2-->
|
||||
@@ -729,10 +717,10 @@ HTML input 标签
|
||||
输入标记是一个空元素,用于标识要从用户处获取的特定类型的字段信息。
|
||||
|
||||
```html
|
||||
<input type="text" name="?" value="?" minlength="6" required />
|
||||
<input type="text" name="?" value="?" minlength="6" required />
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
@@ -794,7 +782,6 @@ HTML input 标签
|
||||
| `type="search"` | <input type="search"> |
|
||||
| `type="range"` | <input type="range"> |
|
||||
|
||||
|
||||
### Input CSS 选择器
|
||||
|
||||
| | |
|
||||
@@ -820,6 +807,7 @@ meta 标记描述 HTML 文档中的元数据。它解释了关于 HTML 的其他
|
||||
<meta property="og:title" content="···">
|
||||
<meta name="twitter:title" content="···">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```html
|
||||
@@ -828,6 +816,7 @@ meta 标记描述 HTML 文档中的元数据。它解释了关于 HTML 的其他
|
||||
<meta property="og:url" content="https://···">
|
||||
<meta name="twitter:url" content="https://···">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```html
|
||||
@@ -836,6 +825,7 @@ meta 标记描述 HTML 文档中的元数据。它解释了关于 HTML 的其他
|
||||
<meta property="og:description" content="···">
|
||||
<meta name="twitter:description" content="···">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```html
|
||||
@@ -843,12 +833,14 @@ meta 标记描述 HTML 文档中的元数据。它解释了关于 HTML 的其他
|
||||
<meta property="og:image" content="https://···">
|
||||
<meta name="twitter:image" content="https://···">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- ua -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```html
|
||||
|
@@ -17,63 +17,63 @@ HTTP 状态码
|
||||
### 2xx. 成功的
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
* [200: OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) _请求没问题_<!--rehype:tooltips-->
|
||||
* [201: Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) _请求完成,并创建了一个新资源_<!--rehype:tooltips-->
|
||||
* [202: Accepted](https://tools.ietf.org/html/rfc7231#section-6.3.3) _接受请求进行处理,但处理未完成_<!--rehype:tooltips-->
|
||||
* [203: Non-Authoritative Information](https://tools.ietf.org/html/rfc7231#section-6.3.4) _实体标头中的信息来自本地或第三方副本,而不是来自原始服务器_<!--rehype:tooltips-->
|
||||
* [204: No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) _响应中给出了状态码和标头,但响应中没有实体主体_<!--rehype:tooltips-->
|
||||
* [205: Reset Content](https://tools.ietf.org/html/rfc7231#section-6.3.6) _浏览器应清除用于此事务的表单以获取其他输入_<!--rehype:tooltips-->
|
||||
* [206: Partial Content](https://tools.ietf.org/html/rfc7233#section-4.1) _服务器正在返回请求大小的部分数据。 用于响应指定 Range 标头的请求。 服务器必须使用 Content-Range 标头指定响应中包含的范围_<!--rehype:tooltips-->
|
||||
- [200: OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) _请求没问题_<!--rehype:tooltips-->
|
||||
- [201: Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) _请求完成,并创建了一个新资源_<!--rehype:tooltips-->
|
||||
- [202: Accepted](https://tools.ietf.org/html/rfc7231#section-6.3.3) _接受请求进行处理,但处理未完成_<!--rehype:tooltips-->
|
||||
- [203: Non-Authoritative Information](https://tools.ietf.org/html/rfc7231#section-6.3.4) _实体标头中的信息来自本地或第三方副本,而不是来自原始服务器_<!--rehype:tooltips-->
|
||||
- [204: No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) _响应中给出了状态码和标头,但响应中没有实体主体_<!--rehype:tooltips-->
|
||||
- [205: Reset Content](https://tools.ietf.org/html/rfc7231#section-6.3.6) _浏览器应清除用于此事务的表单以获取其他输入_<!--rehype:tooltips-->
|
||||
- [206: Partial Content](https://tools.ietf.org/html/rfc7233#section-4.1) _服务器正在返回请求大小的部分数据。 用于响应指定 Range 标头的请求。 服务器必须使用 Content-Range 标头指定响应中包含的范围_<!--rehype:tooltips-->
|
||||
|
||||
### 4xx. 客户端错误
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
* [400: Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1) _服务器不理解该请求_<!--rehype:tooltips-->
|
||||
* [401: Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1) _请求的页面需要用户名和密码_<!--rehype:tooltips-->
|
||||
* [402: Payment Required](https://tools.ietf.org/html/rfc7231#section-6.5.2) _您还不能使用此代码_<!--rehype:tooltips-->
|
||||
* [403: Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3) _禁止访问请求的页面_<!--rehype:tooltips-->
|
||||
* [404: Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4) _服务器找不到请求的页面_<!--rehype:tooltips-->
|
||||
* [405: Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5) _请求中指定的方法是不允许的_<!--rehype:tooltips-->
|
||||
* [406: Not Acceptable](https://tools.ietf.org/html/rfc7231#section-6.5.6) _服务器只能生成客户端不接受的响应_<!--rehype:tooltips-->
|
||||
* [407: Proxy Authentication Required](https://tools.ietf.org/html/rfc7235#section-3.2) _您必须先通过代理服务器进行身份验证,然后才能提供此请求_<!--rehype:tooltips-->
|
||||
* [408: Request Timeout](https://tools.ietf.org/html/rfc7231#section-6.5.7) _请求花费的时间比服务器准备等待的时间长_<!--rehype:tooltips-->
|
||||
* [409: Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8) _由于冲突,请求无法完成_<!--rehype:tooltips-->
|
||||
* [410: Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9) _请求的页面不再可用_<!--rehype:tooltips-->
|
||||
* [411: Length Required](https://tools.ietf.org/html/rfc7231#section-6.5.10) _“Content-Length”未定义。 没有它,服务器将不会接受请求_<!--rehype:tooltips-->
|
||||
* [412: Precondition Failed](https://tools.ietf.org/html/rfc7232#section-4.2) _请求中给出的前提条件被服务器评估为 false_<!--rehype:tooltips-->
|
||||
* [413: Payload Too Large](https://tools.ietf.org/html/rfc7231#section-6.5.11) _服务器不会接受请求,因为请求实体太大_<!--rehype:tooltips-->
|
||||
* [414: URI Too Long](https://tools.ietf.org/html/rfc7231#section-6.5.12) _服务器不会接受请求,因为 url 太长。 当您将“发布”请求转换为具有长查询信息的“获取”请求时发生_<!--rehype:tooltips-->
|
||||
* [415: Unsupported Media Type](https://tools.ietf.org/html/rfc7231#section-6.5.13) _服务器不会接受请求,因为不支持媒体类型_<!--rehype:tooltips-->
|
||||
* [416: Range Not Satisfiable](https://tools.ietf.org/html/rfc7233#section-4.4) _请求的字节范围不可用且超出范围_<!--rehype:tooltips-->
|
||||
* [417: Expectation Failed](https://tools.ietf.org/html/rfc7231#section-6.5.14) _此服务器无法满足在 Expect 请求标头字段中给出的期望_<!--rehype:tooltips-->
|
||||
* [426: Upgrade Required](https://tools.ietf.org/html/rfc7231#section-6.5.15) _服务器拒绝使用当前协议执行请求,但在客户端升级到不同协议后可能愿意这样做_<!--rehype:tooltips-->
|
||||
* [451: Unavailable For Legal Reasons](https://datatracker.ietf.org/doc/html/rfc7725#section-3) _此状态代码表示服务器拒绝访问资源作为法律要求的结果_<!--rehype:tooltips-->
|
||||
- [400: Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1) _服务器不理解该请求_<!--rehype:tooltips-->
|
||||
- [401: Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1) _请求的页面需要用户名和密码_<!--rehype:tooltips-->
|
||||
- [402: Payment Required](https://tools.ietf.org/html/rfc7231#section-6.5.2) _您还不能使用此代码_<!--rehype:tooltips-->
|
||||
- [403: Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3) _禁止访问请求的页面_<!--rehype:tooltips-->
|
||||
- [404: Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4) _服务器找不到请求的页面_<!--rehype:tooltips-->
|
||||
- [405: Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5) _请求中指定的方法是不允许的_<!--rehype:tooltips-->
|
||||
- [406: Not Acceptable](https://tools.ietf.org/html/rfc7231#section-6.5.6) _服务器只能生成客户端不接受的响应_<!--rehype:tooltips-->
|
||||
- [407: Proxy Authentication Required](https://tools.ietf.org/html/rfc7235#section-3.2) _您必须先通过代理服务器进行身份验证,然后才能提供此请求_<!--rehype:tooltips-->
|
||||
- [408: Request Timeout](https://tools.ietf.org/html/rfc7231#section-6.5.7) _请求花费的时间比服务器准备等待的时间长_<!--rehype:tooltips-->
|
||||
- [409: Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8) _由于冲突,请求无法完成_<!--rehype:tooltips-->
|
||||
- [410: Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9) _请求的页面不再可用_<!--rehype:tooltips-->
|
||||
- [411: Length Required](https://tools.ietf.org/html/rfc7231#section-6.5.10) _“Content-Length”未定义。 没有它,服务器将不会接受请求_<!--rehype:tooltips-->
|
||||
- [412: Precondition Failed](https://tools.ietf.org/html/rfc7232#section-4.2) _请求中给出的前提条件被服务器评估为 false_<!--rehype:tooltips-->
|
||||
- [413: Payload Too Large](https://tools.ietf.org/html/rfc7231#section-6.5.11) _服务器不会接受请求,因为请求实体太大_<!--rehype:tooltips-->
|
||||
- [414: URI Too Long](https://tools.ietf.org/html/rfc7231#section-6.5.12) _服务器不会接受请求,因为 url 太长。 当您将“发布”请求转换为具有长查询信息的“获取”请求时发生_<!--rehype:tooltips-->
|
||||
- [415: Unsupported Media Type](https://tools.ietf.org/html/rfc7231#section-6.5.13) _服务器不会接受请求,因为不支持媒体类型_<!--rehype:tooltips-->
|
||||
- [416: Range Not Satisfiable](https://tools.ietf.org/html/rfc7233#section-4.4) _请求的字节范围不可用且超出范围_<!--rehype:tooltips-->
|
||||
- [417: Expectation Failed](https://tools.ietf.org/html/rfc7231#section-6.5.14) _此服务器无法满足在 Expect 请求标头字段中给出的期望_<!--rehype:tooltips-->
|
||||
- [426: Upgrade Required](https://tools.ietf.org/html/rfc7231#section-6.5.15) _服务器拒绝使用当前协议执行请求,但在客户端升级到不同协议后可能愿意这样做_<!--rehype:tooltips-->
|
||||
- [451: Unavailable For Legal Reasons](https://datatracker.ietf.org/doc/html/rfc7725#section-3) _此状态代码表示服务器拒绝访问资源作为法律要求的结果_<!--rehype:tooltips-->
|
||||
|
||||
### 1xx. 信息
|
||||
|
||||
* [100: Continue](https://tools.ietf.org/html/rfc7231#section-6.2.1) _服务器只收到了请求的一部分,但只要没有被拒绝,客户端就应该继续请求_<!--rehype:tooltips-->
|
||||
* [101: Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2) _服务器切换协议_<!--rehype:tooltips-->
|
||||
* [102: Processing](https://tools.ietf.org/html/rfc2518#section-10.1) _用于通知客户端服务器已接受完整请求但尚未完成的临时响应_<!--rehype:tooltips-->
|
||||
- [100: Continue](https://tools.ietf.org/html/rfc7231#section-6.2.1) _服务器只收到了请求的一部分,但只要没有被拒绝,客户端就应该继续请求_<!--rehype:tooltips-->
|
||||
- [101: Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2) _服务器切换协议_<!--rehype:tooltips-->
|
||||
- [102: Processing](https://tools.ietf.org/html/rfc2518#section-10.1) _用于通知客户端服务器已接受完整请求但尚未完成的临时响应_<!--rehype:tooltips-->
|
||||
|
||||
### 3xx. 重定向
|
||||
|
||||
* [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1) _一个链接列表。 用户可以选择一个链接并转到该位置。 最多五个地址_<!--rehype:tooltips-->
|
||||
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2) _请求的页面已移至新的 url_<!--rehype:tooltips-->
|
||||
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3) _请求的页面已临时移动到新的 url_<!--rehype:tooltips-->
|
||||
* [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4) _请求的页面可以在不同的 url 下找到_<!--rehype:tooltips-->
|
||||
* [304: Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1) _这是对 If-Modified-Since 或 If-None-Match 标头的响应代码,其中 URL 自指定日期以来未修改_<!--rehype:tooltips-->
|
||||
* [305: Use Proxy](https://tools.ietf.org/html/rfc7231#section-6.4.5) _请求的 URL 必须通过 Location 标头中提到的代理访问_<!--rehype:tooltips-->
|
||||
* [306: Unused](https://tools.ietf.org/html/rfc7231#section-6.4.6) _此代码在以前的版本中使用过。 它不再使用,但代码被保留_<!--rehype:tooltips-->
|
||||
* [307: Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) _请求的页面已临时移动到新的 url_<!--rehype:tooltips-->
|
||||
- [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1) _一个链接列表。 用户可以选择一个链接并转到该位置。 最多五个地址_<!--rehype:tooltips-->
|
||||
- [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2) _请求的页面已移至新的 url_<!--rehype:tooltips-->
|
||||
- [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3) _请求的页面已临时移动到新的 url_<!--rehype:tooltips-->
|
||||
- [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4) _请求的页面可以在不同的 url 下找到_<!--rehype:tooltips-->
|
||||
- [304: Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1) _这是对 If-Modified-Since 或 If-None-Match 标头的响应代码,其中 URL 自指定日期以来未修改_<!--rehype:tooltips-->
|
||||
- [305: Use Proxy](https://tools.ietf.org/html/rfc7231#section-6.4.5) _请求的 URL 必须通过 Location 标头中提到的代理访问_<!--rehype:tooltips-->
|
||||
- [306: Unused](https://tools.ietf.org/html/rfc7231#section-6.4.6) _此代码在以前的版本中使用过。 它不再使用,但代码被保留_<!--rehype:tooltips-->
|
||||
- [307: Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) _请求的页面已临时移动到新的 url_<!--rehype:tooltips-->
|
||||
|
||||
### 5xx. 服务器错误
|
||||
|
||||
* [500: Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) _请求未完成。服务器遇到了意外情况_<!--rehype:tooltips-->
|
||||
* [501: Not Implemented](https://tools.ietf.org/html/rfc7231#section-6.6.2) _请求未完成。服务器不支持所需的功能_<!--rehype:tooltips-->
|
||||
* [502: Bad Gateway](https://tools.ietf.org/html/rfc7231#section-6.6.3) _请求未完成。服务器收到来自上游服务器的无效响应_<!--rehype:tooltips-->
|
||||
* [503: Service Unavailable](https://tools.ietf.org/html/rfc7231#section-6.6.4) _请求未完成。服务器暂时超载或停机_<!--rehype:tooltips-->
|
||||
* [504: Gateway Timeout](https://tools.ietf.org/html/rfc7231#section-6.6.5) _网关已超时_<!--rehype:tooltips-->
|
||||
* [505: HTTP Version Not Supported](https://tools.ietf.org/html/rfc7231#section-6.6.6) _服务器不支持“http 协议”版本_<!--rehype:tooltips-->
|
||||
- [500: Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) _请求未完成。服务器遇到了意外情况_<!--rehype:tooltips-->
|
||||
- [501: Not Implemented](https://tools.ietf.org/html/rfc7231#section-6.6.2) _请求未完成。服务器不支持所需的功能_<!--rehype:tooltips-->
|
||||
- [502: Bad Gateway](https://tools.ietf.org/html/rfc7231#section-6.6.3) _请求未完成。服务器收到来自上游服务器的无效响应_<!--rehype:tooltips-->
|
||||
- [503: Service Unavailable](https://tools.ietf.org/html/rfc7231#section-6.6.4) _请求未完成。服务器暂时超载或停机_<!--rehype:tooltips-->
|
||||
- [504: Gateway Timeout](https://tools.ietf.org/html/rfc7231#section-6.6.5) _网关已超时_<!--rehype:tooltips-->
|
||||
- [505: HTTP Version Not Supported](https://tools.ietf.org/html/rfc7231#section-6.6.6) _服务器不支持“http 协议”版本_<!--rehype:tooltips-->
|
||||
|
||||
### RESTful API
|
||||
|
||||
|
@@ -3,7 +3,6 @@ ISO 639-1 Language Code 备忘清单
|
||||
|
||||
这是一个符合 ISO 639-1 标准的 ISO 语言代码列表,它为多语言网站提供参考。
|
||||
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
|
27
docs/java.md
@@ -73,6 +73,7 @@ for (char c: word.toCharArray()) {
|
||||
}
|
||||
// 输出: Q-u-i-c-k-R-e-f-
|
||||
```
|
||||
|
||||
查看: [Loops](#java-循环)
|
||||
|
||||
### 数组 Arrays
|
||||
@@ -85,6 +86,7 @@ String[] letters = {"A", "B", "C"};
|
||||
int[] mylist = {100, 200};
|
||||
boolean[] answers = {true, false};
|
||||
```
|
||||
|
||||
查看: [Arrays](#java-数组)
|
||||
|
||||
### Swap
|
||||
@@ -127,9 +129,10 @@ if (j == 10) {
|
||||
}
|
||||
```
|
||||
|
||||
查看: [Conditionals](#java-conditionals)
|
||||
查看: [Conditionals](#条件语句 Conditionals)
|
||||
|
||||
### 用户输入
|
||||
|
||||
```java
|
||||
Scanner in = new Scanner(System.in);
|
||||
String str = in.nextLine();
|
||||
@@ -175,48 +178,60 @@ StringBuilder sb = new StringBuilder(10);
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
sb.append("Reference");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| R | e | f | e | r | e | n | c | e |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
sb.delete(3, 9);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| R | e | f | | | | | | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
sb.insert(0, "My ");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| M | y | | R | e | f | | | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
sb.append("!");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| M | y | | R | e | f | ! | | |
|
||||
@@ -370,7 +385,7 @@ Java 条件语句
|
||||
- `!` _(逻辑补码运算符;反转布尔值)_
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
- `==` _(等于)_
|
||||
- `!=` _(不等于)_
|
||||
@@ -380,19 +395,19 @@ Java 条件语句
|
||||
- `<=` _(小于或等于)_
|
||||
<!--rehype:className=cols-2 style-round-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
- `&&` _条件与_
|
||||
- `||` _条件或_
|
||||
- [?:](#三元运算符) _三元(if-then-else 语句的简写)_
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
- `instanceof` _(将对象与指定类型进行比较)_
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
- `~` _(一元按位补码)_
|
||||
- `<<` _(签名左移)_
|
||||
@@ -462,7 +477,7 @@ for (int i = 0; i < 10; i++) {
|
||||
// 输出: 0123456789
|
||||
```
|
||||
|
||||
------
|
||||
---
|
||||
|
||||
```java
|
||||
for (int i = 0,j = 0; i < 3; i++,j--) {
|
||||
|
@@ -54,7 +54,6 @@ count = 10;
|
||||
console.log(count); // => 10
|
||||
```
|
||||
|
||||
|
||||
### const 关键字
|
||||
|
||||
```javascript
|
||||
@@ -238,11 +237,9 @@ parseFloat();
|
||||
parseInt();
|
||||
```
|
||||
|
||||
|
||||
JavaScript 条件
|
||||
----
|
||||
|
||||
|
||||
### 操作符
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
@@ -273,7 +270,7 @@ true && false; // false
|
||||
1 === '1' // false
|
||||
```
|
||||
|
||||
#### 逻辑运算符 !
|
||||
#### 逻辑运算符
|
||||
|
||||
```javascript
|
||||
let lateToWork = true;
|
||||
@@ -727,7 +724,6 @@ numbers.concat(newFirstNumber)
|
||||
|
||||
如果你想避免改变你的原始数组,你可以使用 concat。
|
||||
|
||||
|
||||
### 方法 .splice()
|
||||
|
||||
```javascript
|
||||
@@ -1295,7 +1291,6 @@ class Song {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
JavaScript Modules
|
||||
----
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
@@ -546,7 +546,6 @@ test('async test', () => {
|
||||
|
||||
从你的测试中 _返回_ 一个 `Promise`
|
||||
|
||||
|
||||
## 模拟
|
||||
|
||||
### 模拟函数
|
||||
@@ -800,7 +799,6 @@ const fs = require('fs')
|
||||
const fs = require.requireActual('fs')
|
||||
```
|
||||
|
||||
|
||||
数据驱动测试(Jest 23+)
|
||||
----
|
||||
|
||||
@@ -886,7 +884,6 @@ test('第二个文本', () => {
|
||||
|
||||
`Node.js` 和 `Jest` 会缓存你需要的模块。 要测试具有副作用的模块,您需要在测试之间重置模块注册表
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
236
docs/jq.md
Normal file
@@ -0,0 +1,236 @@
|
||||
jq 备忘清单
|
||||
===
|
||||
|
||||
这个快速参考备忘单提供了使用 [jq](https://stedolan.github.io/jq/) 命令的各种方法。
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
### 介绍
|
||||
|
||||
jq 就像用于 JSON 数据的 [sed](./sed.md) - 您可以使用它来切片、过滤、映射和转换结构化数据
|
||||
|
||||
- [jq 官网](https://stedolan.github.io/jq/) _(stedolan.github.io)_
|
||||
- [jq 命令使用](https://jaywcjlove.github.io/linux-command/c/jq.html) _(jaywcjlove.github.io)_
|
||||
|
||||
安装
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install jq # Debian& Ubuntu
|
||||
$ sudo dnf install jq # Fedora
|
||||
$ sudo zypper install jq # openSUSE
|
||||
$ sudo pacman -S jq # Arch
|
||||
$ brew install jq # macOS & Homebrew
|
||||
$ port install jq # macOS & MacPorts
|
||||
```
|
||||
|
||||
语法
|
||||
|
||||
```bash
|
||||
$ jq [options] <jq filter> [file...]
|
||||
$ jq [options] --args <jq filter> [strings...]
|
||||
$ jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 选项
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-c` | 紧凑而不是漂亮的输出
|
||||
`-n` | 使用`null`作为单个输入值
|
||||
`-e` | 根据输出设置退出状态代码
|
||||
`-s` | 将所有输入读取(吸取)到数组中;应用过滤器
|
||||
`-r` | 输出原始字符串,而不是JSON文本
|
||||
`-R` | 读取原始字符串,而不是JSON文本
|
||||
`-C` | 为 JSON 着色
|
||||
`-M` | 单色(不要为JSON着色)
|
||||
`-S` | 在输出上排序对象的键
|
||||
`--tab` | 使用制表符进行缩进
|
||||
`--arg a v` | 将变量 `$a` 设置为 value `<v>`
|
||||
`--argjson a v` | 将变量 `$a` 设置为 JSON value `<v>`
|
||||
`--slurpfile a f` | 将变量 `$a` 设置为从`<f>`读取的JSON文本数组
|
||||
`--rawfile a f` | 将变量 `$a` 设置为包含`<f>`内容的字符串
|
||||
`--args` | 其余参数是字符串参数,而不是文件
|
||||
`--jsonargs` | 其余的参数是JSON参数,而不是文件
|
||||
`--` | 终止参数处理
|
||||
|
||||
学习示例
|
||||
---
|
||||
|
||||
### 获取一个键的值
|
||||
|
||||
```bash
|
||||
$ echo '{"foo": 42, "bar": "less interesting data"}' | jq '.foo'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
42
|
||||
```
|
||||
|
||||
### 数组运算
|
||||
|
||||
```bash
|
||||
$ echo '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' | jq '.[1]'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
{
|
||||
"name": "XML",
|
||||
"good": false
|
||||
}
|
||||
```
|
||||
|
||||
### 构造一个数组/对象
|
||||
|
||||
```bash
|
||||
$ echo '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}' | jq '{user, title: .titles[]}'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
{
|
||||
"user": "stedolan",
|
||||
"title": "JQ Primer"
|
||||
}
|
||||
{
|
||||
"user": "stedolan",
|
||||
"title": "More JQ"
|
||||
}
|
||||
```
|
||||
|
||||
### 计算一个值的长度
|
||||
|
||||
```bash
|
||||
$ echo '[[1,2], "string", {"a":2}, null]' | jq '.[] | length'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
2
|
||||
6
|
||||
1
|
||||
0
|
||||
```
|
||||
|
||||
### 取出数组中的键
|
||||
|
||||
```bash
|
||||
$ echo '{"abc": 1, "abcd": 2, "Foo": 3}' | jq 'keys'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
"Foo",
|
||||
"abc",
|
||||
"abcd"
|
||||
]
|
||||
```
|
||||
|
||||
### 使用多个过滤器
|
||||
|
||||
```bash
|
||||
$ echo '{ "foo": 42, "bar": "something else", "baz": true}' | jq '.foo, .bar'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
42
|
||||
"something else"
|
||||
```
|
||||
|
||||
### 管道传递给下一个过滤器
|
||||
|
||||
```bash
|
||||
$ echo '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' | jq '.[] | .name'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"JSON"
|
||||
"XML"
|
||||
```
|
||||
|
||||
### 条件语句判断
|
||||
|
||||
```bash
|
||||
$ echo '[1,5,3,0,7]' | jq 'map(select(. >= 2))'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
5,
|
||||
3,
|
||||
7
|
||||
]
|
||||
```
|
||||
|
||||
### 每个输入调用过滤器
|
||||
|
||||
```bash
|
||||
$ echo '[1,2,3]' | jq 'map(.+1)'
|
||||
```
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
2,
|
||||
3,
|
||||
4
|
||||
]
|
||||
```
|
||||
|
||||
### 条件判断
|
||||
|
||||
```bash
|
||||
$ echo '2' | jq 'if . == 0 then "zero" elif . == 1 then "one" else "many" end'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"many"
|
||||
```
|
||||
|
||||
### 字符串插入值并进行运算
|
||||
|
||||
```bash
|
||||
$ echo '42' | jq '"The input was \(.), which is one less than \(.+1)"'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"The input was 42, which is one less than 43"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [jq 官网](https://stedolan.github.io/jq/) _(stedolan.github.io)_
|
||||
- [jq 命令使用](https://jaywcjlove.github.io/linux-command/c/jq.html) _(jaywcjlove.github.io)_
|
@@ -75,8 +75,8 @@ JSON 备忘清单
|
||||
```json
|
||||
{ "foo": 'bar' }
|
||||
```
|
||||
Have to be delimited by double quotes
|
||||
|
||||
Have to be delimited by double quotes
|
||||
|
||||
### 数字
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
@@ -297,6 +297,7 @@ let myArray = [
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
| | |
|
||||
@@ -320,7 +321,7 @@ let myArray = [
|
||||
];
|
||||
```
|
||||
|
||||
-----
|
||||
----
|
||||
|
||||
| | |
|
||||
|--------------|-----------|
|
||||
@@ -328,7 +329,6 @@ let myArray = [
|
||||
| `myArray[5]` | true |
|
||||
| `myArray[6]` | undefined |
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
@@ -3,7 +3,6 @@ Koajs 备忘清单
|
||||
|
||||
基于 Node.js 平台的下一代 web 开发框架,包含 [Koa](https://koajs.com/) 的 API 参考列表和一些示例。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
@@ -13,6 +12,7 @@ Koajs 备忘清单
|
||||
[Koa](https://koajs.com/) 需要 [node v7.6.0](https://nodejs.org) 或更高版本来支持ES2015、异步方法,你可以安装自己支持的 `node` 版本
|
||||
|
||||
- 安装依赖
|
||||
|
||||
```bash
|
||||
$ mkdir myapp # 创建目录
|
||||
$ cd myapp # 进入目录
|
||||
@@ -20,7 +20,9 @@ Koajs 备忘清单
|
||||
$ npm init -y # 初始化一个配置
|
||||
$ npm install koa # 安装依赖
|
||||
```
|
||||
|
||||
- 入口文件 `index.js` 添加代码:
|
||||
|
||||
```js
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
@@ -31,7 +33,9 @@ Koajs 备忘清单
|
||||
|
||||
app.listen(3000);
|
||||
```
|
||||
|
||||
- 使用以下命令运行应用程序
|
||||
|
||||
```bash
|
||||
$ node index.js
|
||||
```
|
||||
|
@@ -199,7 +199,7 @@ $ lerna publish --canary preminor
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
@@ -239,7 +239,7 @@ $ lerna version -m "chore(doc): publish %v"
|
||||
- `prerelease` 预发行
|
||||
<!--rehype:className=cols-2-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
@@ -311,7 +311,6 @@ $ lerna bootstrap --hoist
|
||||
`--force-local` [#](https://github.com/lerna/lerna/tree/main/commands/bootstrap#--force-local) | 此标志会导致引导命令始终对本地依赖项进行符号链接,而不管匹配的版本范围如何
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
|
||||
### info 本地环境信息
|
||||
|
||||
```bash
|
||||
@@ -424,13 +423,13 @@ lerna la
|
||||
- 如果不存在 `.gitignore`,则生成一个忽略文件
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```shell
|
||||
$ lerna init --independent
|
||||
```
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
@@ -527,7 +526,6 @@ $ lerna diff package-name # 区分一个特定的包
|
||||
|
||||
类似于 `lerna changed`,此命令运行 `git diff`
|
||||
|
||||
|
||||
### clean
|
||||
|
||||
从所有包中删除 `node_modules` 目录
|
||||
|
@@ -72,7 +72,6 @@ $ lessc styles.less styles.css
|
||||
|
||||
另见: [混合(Mixin)的更多信息](https://lesscss.org/features/#mixins-feature)
|
||||
|
||||
|
||||
### 嵌套(Nesting)
|
||||
|
||||
```css
|
||||
|
@@ -78,7 +78,6 @@ $ kill -9 `lsof -t -u apache`
|
||||
$ kill -9 $(lsof -t -i :8080)
|
||||
```
|
||||
|
||||
|
||||
### 参数
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -109,13 +108,12 @@ lsof -p $pid
|
||||
lsof -i:9981 -P -t -sTCP:LISTEN
|
||||
```
|
||||
|
||||
### 列出打开文件的进程:
|
||||
### 列出打开文件的进程
|
||||
|
||||
```bash
|
||||
lsof $filename
|
||||
```
|
||||
|
||||
|
||||
示例
|
||||
---
|
||||
|
||||
@@ -219,7 +217,6 @@ migration 2 root txt unknown /proc/2/exe
|
||||
`NAME` | 打开文件的确切名称
|
||||
`REG` | 常规文件
|
||||
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
@@ -3,7 +3,6 @@ Markdown 备忘清单
|
||||
|
||||
这是 Markdown 语法的快速参考备忘单。
|
||||
|
||||
|
||||
Markdown 快速参考
|
||||
----
|
||||
|
||||
@@ -30,7 +29,6 @@ Header 2
|
||||
--------
|
||||
```
|
||||
|
||||
|
||||
### 块引用
|
||||
|
||||
```markdown
|
||||
@@ -64,6 +62,7 @@ Header 2
|
||||
+ Item 1
|
||||
+ Item 2
|
||||
```
|
||||
|
||||
或者**任务**列表
|
||||
|
||||
```markdown
|
||||
@@ -132,11 +131,13 @@ ___
|
||||
|
||||
### 代码
|
||||
|
||||
~~~markdown
|
||||
```markdown
|
||||
|
||||
```javascript
|
||||
console.log("This is a block code")
|
||||
```
|
||||
~~~
|
||||
|
||||
```
|
||||
|
||||
```markdown
|
||||
~~~css
|
||||
@@ -144,12 +145,10 @@ console.log("This is a block code")
|
||||
~~~
|
||||
```
|
||||
|
||||
|
||||
```markdown
|
||||
4 空格缩进做一个代码块
|
||||
```
|
||||
|
||||
|
||||
#### 内联代码
|
||||
|
||||
```markdown
|
||||
|
1417
docs/matlab.md
Normal file
@@ -3,7 +3,6 @@ MIME 类型 备忘清单
|
||||
|
||||
此备忘单列出了一些常见的 Web MIME 类型。 您可以查看包含所有已注册 MIME 类型的 [IANA/MIME 媒体类型注册表](https://www.iana.org/assignments/media-types/media-types.xhtml)。
|
||||
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
@@ -17,7 +16,6 @@ MIME 类型 备忘清单
|
||||
- 对于 Internet 上的文件格式或格式内容
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
|
||||
MIME 类型列表
|
||||
--------
|
||||
|
||||
|
@@ -3,7 +3,6 @@ MySQL 备忘清单
|
||||
|
||||
本备忘单旨在快速理解 [MySQL](https://mysql.com) 所涉及的主要概念,提供了最常用的SQL语句,供您参考。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
@@ -65,9 +64,9 @@ mysql -h <host> -u <user> -p [db_name]
|
||||
`SHOW TABLES;` | 列出当前数据库的表
|
||||
`SHOW FIELDS FROM` t`;` | 表的列表字段
|
||||
`DESC` t`;` | 显示表格结构
|
||||
`SHOW CREATE TABLE `t`;` | 显示创建表sql
|
||||
`TRUNCATE TABLE `t`;` | 删除表中的所有数据
|
||||
`DROP TABLE `t`;` | 删除表格
|
||||
`SHOW CREATE TABLE`t`;` | 显示创建表sql
|
||||
`TRUNCATE TABLE`t`;` | 删除表中的所有数据
|
||||
`DROP TABLE`t`;` | 删除表格
|
||||
|
||||
#### Proccess
|
||||
|
||||
@@ -388,6 +387,7 @@ CREATE TABLE t(
|
||||
CHECK(c1> 0 AND c1 >= c2)
|
||||
);
|
||||
```
|
||||
|
||||
c2列中的设置值不为NULL
|
||||
|
||||
```sql
|
||||
@@ -556,7 +556,6 @@ DROP INDEX idx_name;
|
||||
MySQL 数据类型
|
||||
---------
|
||||
|
||||
|
||||
### Strings
|
||||
|
||||
| - | - |
|
||||
@@ -573,16 +572,15 @@ MySQL 数据类型
|
||||
| `ENUM` | One of preset options |
|
||||
| `SET` | Selection of preset options |
|
||||
|
||||
|
||||
### Date & time
|
||||
|
||||
| Data Type | Format |
|
||||
|-------------|---------------------|
|
||||
| `DATE ` | yyyy-MM-dd |
|
||||
| `TIME ` | hh:mm:ss |
|
||||
| `DATETIME ` | yyyy-MM-dd hh:mm:ss |
|
||||
| `DATE` | yyyy-MM-dd |
|
||||
| `TIME` | hh:mm:ss |
|
||||
| `DATETIME` | yyyy-MM-dd hh:mm:ss |
|
||||
| `TIMESTAMP` | yyyy-MM-dd hh:mm:ss |
|
||||
| `YEAR ` | yyyy |
|
||||
|
||||
| `YEAR` | yyyy |
|
||||
|
||||
### Numeric
|
||||
|
||||
|
@@ -25,7 +25,6 @@ $ nc -lp port [host] [port]
|
||||
### 选项示例
|
||||
<!--rehype:wrap-class=col-span-3 row-span-2-->
|
||||
|
||||
|
||||
选项 | 示例 | 说明
|
||||
:- | :- | :-
|
||||
`-h` | nc -h | 帮助
|
||||
@@ -40,7 +39,6 @@ $ nc -lp port [host] [port]
|
||||
`-4` | nc -4 -l 8000 | 仅限 `IPv4`
|
||||
`-6` | nc -6 -l 8000 | 仅限 `IPv6`
|
||||
|
||||
|
||||
### 聊天客户端-服务器
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -192,7 +190,7 @@ $ cat video.avi | nc -l 8000
|
||||
|
||||
客户端 Client
|
||||
|
||||
```shell {.wrap}
|
||||
```shell
|
||||
$ nc 192.168.1.9 8000 | mplayer -vo x11 -cache 3000 -
|
||||
```
|
||||
|
||||
|
@@ -42,7 +42,6 @@ $ netstat -h
|
||||
`netstat -au` | 所有 UDP 连接
|
||||
`netstat -ant` | 显示没有反向 DNS 查找的 IP 地址
|
||||
|
||||
|
||||
选项 | 说明
|
||||
:- | :-
|
||||
`netstat` | 活动连接
|
||||
@@ -53,7 +52,6 @@ $ netstat -h
|
||||
`netstat -tnl` | 监听 TCP 端口
|
||||
`netstat -unl` | 监听 UDP 端口
|
||||
|
||||
|
||||
### 网络
|
||||
|
||||
选项 | 说明
|
||||
@@ -65,7 +63,6 @@ $ netstat -h
|
||||
|
||||
### 路由
|
||||
|
||||
|
||||
选项 | 说明
|
||||
:- | :-
|
||||
`netstat -r` | 显示路由表
|
||||
|
@@ -1,7 +1,7 @@
|
||||
NGINX 备忘清单
|
||||
===
|
||||
|
||||
这个 nginx 快速参考备忘单显示了它的常用命和配置使用清单。
|
||||
这个 [nginx](https://nginx.org/en/) 快速参考备忘单显示了它的常用命和配置使用清单。
|
||||
|
||||
入门
|
||||
----
|
||||
@@ -313,7 +313,6 @@ server {
|
||||
|
||||
您可以使用 Let's Encrypt 轻松保护您的网站/应用程序。去 [lets-encrypt](https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx.html) 获取更多信息
|
||||
|
||||
|
||||
### 重定向(301永久)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
|
192
docs/npm.md
@@ -1,7 +1,7 @@
|
||||
npm 备忘清单
|
||||
===
|
||||
|
||||
这个 npm 快速参考备忘单显示了它的常用命令使用清单。
|
||||
这个 [npm](https://www.npmjs.com/) 快速参考备忘单显示了它的常用命令使用清单
|
||||
|
||||
常用命令
|
||||
----
|
||||
@@ -67,112 +67,92 @@ npm 备忘清单
|
||||
### 缓存 cache
|
||||
|
||||
```bash
|
||||
npm cache add <package-spec> # 将指定的包添加到本地缓存
|
||||
npm cache clean [<key>] # 删除缓存文件夹中的所有数据
|
||||
npm cache ls [<name>@<version>]
|
||||
npm cache verify # 验证缓存文件夹的内容,垃圾收集任何不需要的数据,
|
||||
$ npm cache add <package-spec> # 将指定的包添加到本地缓存
|
||||
$ npm cache clean [<key>] # 删除缓存文件夹中的所有数据
|
||||
$ npm cache ls [<name>@<version>]
|
||||
$ npm cache verify # 验证缓存文件夹的内容,垃圾收集任何不需要的数据,
|
||||
# 并验证缓存索引和所有缓存数据的完整性
|
||||
```
|
||||
|
||||
用于添加、列出或清理 npm 缓存文件夹
|
||||
用于添加、列出或清理 [npm](https://www.npmjs.com/) 缓存文件夹
|
||||
|
||||
### 更新
|
||||
|
||||
| 命令 | 描述 |
|
||||
| --- | --- |
|
||||
| `npm version <version>` | 要更改 `package.json` 中的版本号 |
|
||||
| `npm update` | 更新生产包 |
|
||||
| `npm update --dev` | 更新开发包 |
|
||||
| `npm update -g` | 更新全局包 |
|
||||
| `npm update lodash` | 更新 `lodash` 包 |
|
||||
|
||||
命令 | 描述
|
||||
:- | -
|
||||
`npm version <version>` | 要更改 `package.json` 中的版本号
|
||||
`npm update` | 更新生产包
|
||||
`npm update --dev` | 更新开发包
|
||||
`npm update -g` | 更新全局包
|
||||
`npm update lodash` | 更新 `lodash` 包
|
||||
|
||||
### 杂项功能
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
将某人添加为所有者
|
||||
|
||||
```bash
|
||||
npm owner add USERNAME PACKAGENAME
|
||||
```
|
||||
|
||||
列出包
|
||||
|
||||
```bash
|
||||
npm ls
|
||||
```
|
||||
|
||||
向安装旧版本软件包的用户添加警告(弃用)
|
||||
|
||||
```bash
|
||||
npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
|
||||
```
|
||||
|
||||
更新所有包或选定的包
|
||||
|
||||
```bash
|
||||
npm update [-g] PACKAGE
|
||||
```
|
||||
|
||||
检查过时的包
|
||||
|
||||
```bash
|
||||
npm outdated [PACKAGE]
|
||||
```
|
||||
|
||||
### 更改包裹可见性
|
||||
|
||||
将公共包设为私有
|
||||
|
||||
```bash
|
||||
npm access restricted <package-name>
|
||||
```
|
||||
|
||||
公开私有包
|
||||
|
||||
```bash
|
||||
npm access public <package-name>
|
||||
```
|
||||
|
||||
授予私有包访问权限
|
||||
|
||||
```bash
|
||||
npm owner add <user> <your-package-name>
|
||||
```
|
||||
|
||||
### 要将包转移到 npm 用户帐户
|
||||
|
||||
```bash
|
||||
npm owner add <their-username> <package-name>
|
||||
# 新维护者接受邀请
|
||||
npm owner rm <your-username> <package-name>
|
||||
```
|
||||
|
||||
写入启用了双因素身份验证
|
||||
|
||||
```bash
|
||||
npm owner add <their-username> <package-name> --otp=123456
|
||||
# 将某人添加为所有者
|
||||
$ npm owner add USERNAME PACKAGENAME
|
||||
# 列出包
|
||||
$ npm ls
|
||||
# 向安装旧版本软件包的用户添加警告(弃用)
|
||||
$ npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
|
||||
# 更新所有包或选定的包
|
||||
$ npm update [-g] PACKAGE
|
||||
# 检查过时的包
|
||||
$ npm outdated [PACKAGE]
|
||||
```
|
||||
|
||||
### 取消发布包
|
||||
|
||||
```bash
|
||||
npm unpublish <package-name> -f
|
||||
$ npm unpublish <package-name> -f
|
||||
# 取消指定版本
|
||||
npm unpublish <package-name>@<version>
|
||||
$ npm unpublish <package-name>@<version>
|
||||
```
|
||||
|
||||
注意:如果您取消发布整个包,则必须在 24 小时后才能发布该包的任何新版本。
|
||||
注意:如果您取消发布整个包,则必须在 24 小时后才能发布该包的任何新版本
|
||||
|
||||
### 更改包裹可见性
|
||||
|
||||
```bash
|
||||
# 将公共包设为私有
|
||||
$ npm access restricted <package-name>
|
||||
# 公开私有包
|
||||
$ npm access public <package-name>
|
||||
# 授予私有包访问权限
|
||||
$ npm owner add <user> <your-package-name>
|
||||
```
|
||||
|
||||
### 要将包转移到 npm 用户帐户
|
||||
|
||||
```bash
|
||||
# 新维护者接受邀请
|
||||
$ npm owner add <their-username> <package-name>
|
||||
# 删除维护者
|
||||
$ npm owner rm <your-username> <package-name>
|
||||
# 写入启用了双因素身份验证
|
||||
$ npm owner add <their-username> <package-name> --otp=123456
|
||||
```
|
||||
|
||||
### 发布包 npmjs.org
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
$ npm publish
|
||||
# 第一次需要指定公开参数
|
||||
npm publish --access public
|
||||
$ npm publish --access public
|
||||
```
|
||||
|
||||
发布公开包,到 npmjs.org
|
||||
发布公开包,到 [npmjs.org](https://docs.npmjs.com)
|
||||
|
||||
### 使用 nrm 切换 registry
|
||||
|
||||
```bash
|
||||
$ npm install -g nrm # 安装 nrm 包
|
||||
# 查看 registry 列表
|
||||
$ nrm ls
|
||||
# 将注册表切换到 cnpm
|
||||
$ nrm use cnpm
|
||||
```
|
||||
|
||||
配置
|
||||
---
|
||||
@@ -186,17 +166,27 @@ npm publish --access public
|
||||
`$PREFIX/etc/npmrc` | 全局配置文件
|
||||
`/path/to/npm/npmrc` | npm 内置配置文件
|
||||
|
||||
|
||||
### 配置内容
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```ini
|
||||
# last modified: 01 Jan 2016
|
||||
; Set a new registry for a scoped package
|
||||
@myscope:registry=https://registry.npmmirror.com
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
注释使用 `#`, `;` 放置到一行的开头。`.npmrc` 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
|
||||
注释使用 `#`, `;` 放置到一行的开头, [`.npmrc`](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc) 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
|
||||
|
||||
### registry
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`npm` | <https://registry.npmjs.org/>
|
||||
`yarn` | <https://registry.yarnpkg.com/>
|
||||
`tencent` | <https://mirrors.cloud.tencent.com/npm/>
|
||||
`cnpm` | <https://r.cnpmjs.org/>
|
||||
`taobao` | <https://registry.npmmirror.com/>
|
||||
`npmMirror` | <https://skimdb.npmjs.com/registry/>
|
||||
|
||||
### `.npmignore`
|
||||
|
||||
@@ -223,7 +213,7 @@ npm publish --access public
|
||||
$ npm install -g <package-name> --registry=https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
将配置放置在 `.npmrc` 全局配置文件中,或者在项目的根目录中。
|
||||
将配置放置在 [`.npmrc`](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc) 全局配置文件中,或者在项目的根目录中。
|
||||
|
||||
```ini
|
||||
; registry=https://registry.npmjs.org/
|
||||
@@ -241,7 +231,7 @@ registry=https://registry.npmmirror.com
|
||||
替换 npm 仓库地址为 npmmirror(淘宝) 镜像地址
|
||||
|
||||
```bash
|
||||
npm config set registry https://registry.npmmirror.com
|
||||
$ npm config set registry https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
请参阅:[npmmirror 中国镜像站](https://npmmirror.com/)
|
||||
@@ -267,6 +257,36 @@ ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-
|
||||
//somewhere.com/another/:_authToken=MYTOKEN2
|
||||
```
|
||||
|
||||
纯 ESM 包
|
||||
----
|
||||
|
||||
### CommonJS 项目移动到 ESM
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
- 将 `"type": "module"` 添加到您的 [package.json](./package.json.md)
|
||||
- 将 [package.json](./package.json.md) 中的 `"main": "index.js"` 替换为 `"exports": "./index.js"`。
|
||||
- 将 [package.json](./package.json.md) 中的 `"engines"` 字段更新为 Node.js 14: `"node": ">=14.16"`。(不包括 <red>~~Node.js 12~~</red>,因为它不再受支持)
|
||||
- 删除 `"use strict"`;来自所有 JavaScript 文件
|
||||
- 将所有 `require()` / `module.export` 替换为 `import` / `export`
|
||||
- 仅使用完整的相对文件路径进行导入:`import x from '.';` → `import x from './index.js';`
|
||||
- 如果您有 `TypeScript` 类型定义(例如 `index.d.ts`),请将其更新为使用 ESM 导入/导出
|
||||
- 可选但推荐使用 `node:` 导入[协议](https://nodejs.org/api/esm.html#esm_node_imports)
|
||||
|
||||
### TypeScript 项目输出 ESM
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
- 确保您使用的是 TypeScript 4.7 或更高版本
|
||||
- 将 `"type": "module"` 添加到您的 [package.json](./package.json.md)
|
||||
- 将 [package.json](./package.json.md) 中的 `"main": "index.js"` 替换为 `"exports": "./index.js"`
|
||||
- 将 [package.json](./package.json.md) 中的 `"engines"` 字段更新为 Node.js 14: `"node": ">=14.16"`。 (不包括 <red>~~Node.js 12~~</red>,因为它不再受支持)
|
||||
- 将 `"module": "node16"`, `"moduleResolution": "node16"` 添加到您的 [tsconfig.json](./typescript.md) ([列子](https://github.com/sindresorhus/tsconfig/blob/main/tsconfig.json))
|
||||
- 仅使用完整的相对文件路径进行导入:`import x from '.';` → `import x from './index.js';`
|
||||
- 删除 `namespace` 使用并改用 `export`
|
||||
- 可选但推荐使用 `node:` 导入[协议](https://nodejs.org/api/esm.html#esm_node_imports)
|
||||
- **即使您正在导入 `.ts` 文件,也必须在相对导入中使用 `.js` 扩展名**
|
||||
|
||||
阅读[官方 ESM 指南](https://www.typescriptlang.org/docs/handbook/esm-node.html)
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
@@ -12,6 +12,8 @@ package.json 备忘清单
|
||||
|
||||
- [npm 文档](https://docs.npmjs.com/files/package.json) _(npmjs.com)_
|
||||
- [yarnpkg 文档](https://classic.yarnpkg.com/en/docs/package-json) _(yarnpkg.com)_
|
||||
- [packages 文档](https://nodejs.org/api/packages.html) _(nodejs.org)_
|
||||
- [npm 备忘清单(速查表)](./npm.md) _(jaywcjlove.github.io)_
|
||||
|
||||
### `name`
|
||||
|
||||
@@ -21,7 +23,7 @@ package.json 备忘清单
|
||||
}
|
||||
```
|
||||
|
||||
**规则**
|
||||
#### 规则
|
||||
|
||||
- 必须小于或等于214个字符(包括 `@scope/` 范围包)
|
||||
- 不能以点(`.`)或下划线(`_`)开头
|
||||
@@ -328,12 +330,100 @@ https://registry.npmjs.org/[包名]/-/[包名]-[version].tgz
|
||||
|
||||
字段由模块作者提供,作为 `JavaScript` 包或组件工具的提示,用于打包模块以供客户端使用。 提案就[在这里](https://github.com/defunctzombie/package-browser-field-spec)。
|
||||
|
||||
### `exports`
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "mod",
|
||||
"exports":{
|
||||
".": "./lib/index.js",
|
||||
"./lib/*": "./lib/*.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
使用最新的 `exports` 字段导出,可规避 `main` 字段局限性 [具体参考](https://nodejs.org/api/packages.html)
|
||||
|
||||
### exports 导出子路径中的模块
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "mod",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./sub": "./src/sub.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
导入
|
||||
|
||||
```js
|
||||
import sub from "mod/sub"
|
||||
```
|
||||
|
||||
### exports 简写 (`.` 唯一的导出)
|
||||
|
||||
```json
|
||||
{
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
简写
|
||||
|
||||
```json
|
||||
{
|
||||
"exports": "./dist/index.js"
|
||||
}
|
||||
```
|
||||
|
||||
### 条件导出(exports)
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`export` | 通过 `import` 或 `import()` 或 `es` 模块加载的任何顶层导入或解析操作加载时,匹配。
|
||||
`require` | 当包通过 `require()` 加载时匹配。预期的格式包括 CommonJS、JSON 和本地插件。
|
||||
`node` | 匹配任何 `Node.js` 环境。可以是 `cjs` 或 `es` 模块文件。必须在 `import` 或 `require` 之后。
|
||||
`default` | 默认的降级条件。可以是一个 `cjs` 或 `es` 模块文件。这个条件应该总是排在最后。
|
||||
|
||||
```js
|
||||
{
|
||||
"exports": {
|
||||
".": {
|
||||
"import":"./dist/index.mjs",
|
||||
"require":"./dist/index.cjs", // 当包通过 `require()` 加载时匹配
|
||||
"node": "./dist/ployfill.js", // 匹配任何 `Node.js` 环境
|
||||
"default": "./dist/default.js" // 默认的降级条件
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<red>注意:</red>由于 `require` 和 `import` 互斥,所以 `require` 不能加载 `es` 的模块,`export` 不能加载 `cjs` 模块
|
||||
|
||||
### `main` Vs `exports`
|
||||
|
||||
```json
|
||||
{
|
||||
"main": "./index.js",
|
||||
"exports": "./index.js"
|
||||
}
|
||||
```
|
||||
|
||||
如果同时出现 <red>~~`main`~~</red> 和 `exports` 字段,只会读取 `exports` 字段
|
||||
|
||||
## 任务类字段
|
||||
|
||||
包里还可以包含一些可执行脚本或者其他配置信息。
|
||||
|
||||
### `scripts`
|
||||
|
||||
脚本是定义自动化开发相关任务的好方法,比如使用一些简单的构建过程或开发工具。 在 `scripts` 字段里定义的脚本,可以通过 `yarn run <script>` 命令来执行。 例如,下面 `build-project` 脚本可以通过 `yarn run build-project` 调用,并执行 `node build-project.js`。
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
@@ -342,12 +432,14 @@ https://registry.npmjs.org/[包名]/-/[包名]-[version].tgz
|
||||
}
|
||||
```
|
||||
|
||||
脚本是定义自动化开发相关任务的好方法,比如使用一些简单的构建过程或开发工具。 在 `scripts` 字段里定义的脚本,可以通过 `yarn run <script>` 命令来执行。 例如,上述 `build-project` 脚本可以通过 `yarn run build-project` 调用,并执行 `node build-project.js`。
|
||||
|
||||
有一些特殊的脚本名称。 如果定义了 `preinstall` 脚本,它会在包安装前被调用。 出于兼容性考虑,`install`、`postinstall` 和 `prepublish` 脚本会在包完成安装后被调用。
|
||||
|
||||
----
|
||||
|
||||
`start` 脚本的默认值为 `node server.js`。
|
||||
|
||||
----
|
||||
|
||||
参考文档:[npm docs](https://docs.npmjs.com/files/package.json#default-values)
|
||||
|
||||
### 特定的 `scripts`
|
||||
@@ -355,24 +447,24 @@ https://registry.npmjs.org/[包名]/-/[包名]-[version].tgz
|
||||
|
||||
对于以下脚本,`npm` 支持 `package.json` 文件的 `scripts` 默认命令字段:
|
||||
|
||||
- `prepublish`: 在打包并发布包之前运行,以及在没有任何参数的本地 `npm` 安装之前运行。 (见下文)
|
||||
- `prepare`: 在打包和发布包之前运行,在没有任何参数的本地 `npm install` 上运行,以及安装 git 依赖项时(见下文)。 这是在 `preublish` 之后运行,但是在 `preublishOnly` 之前运行。
|
||||
- `prepublishOnly`: 在包准备和打包之前运行,仅限于npm发布。 (见下文。)
|
||||
- `prepublish`: 在打包并发布包之前运行,以及在没有任何参数的本地 `npm` 安装之前运行
|
||||
- `prepare`: 在打包和发布包之前运行,在没有任何参数的本地 `npm install` 上运行,以及安装 git 依赖项时。 这是在 `preublish` 之后运行,但是在 `preublishOnly` 之前运行
|
||||
- `prepublishOnly`: 在包准备和打包之前运行,仅限于npm发布
|
||||
- `prepack`: 在打包 `tarball` 之前运行(在 `npm pack`,`npm publish`,以及安装 git 依赖项时)
|
||||
- `postpack`: 在生成 `tarball` 之后运行并移动到其最终目标。
|
||||
- `publish`, `postpublish`: 在包发布后运行。
|
||||
- `preinstall`: 在安装软件包之前运行。
|
||||
- `install`, `postinstall`: 安装包后运行。
|
||||
- `preuninstall`, `uninstall`: 在卸载软件包之前运行。
|
||||
- `postuninstall`: 在卸载软件包之后运行。
|
||||
- `preversion`: 在改变包版本之前运行。
|
||||
- `version`: 改变包版本后运行,但提交之前。
|
||||
- `postversion`: 改变包版本后运行,然后提交。
|
||||
- `pretest`, `test`, `posttest`: 由 `npm test` 命令运行。
|
||||
- `prestop`, `stop`, `poststop`: 由 `npm stop` 命令运行。
|
||||
- `prestart`, `start`, `poststart`: 由 `npm start` 命令运行。
|
||||
- `prerestart`, `restart`, `postrestart`: 由 `npm restart` 命令运行。 注意:如果没有提供重启脚本,`npm restart` 将运行 `stop` 和`start` 脚本。
|
||||
- `preshrinkwrap`, `shrinkwrap`, `postshrinkwrap`: 由 `npm shrinkwrap` 命令运行。
|
||||
- `postpack`: 在生成 `tarball` 之后运行并移动到其最终目标
|
||||
- `publish`, `postpublish`: 在包发布后运行
|
||||
- `preinstall`: 在安装软件包之前运行
|
||||
- `install`, `postinstall`: 安装包后运行
|
||||
- `preuninstall`, `uninstall`: 在卸载软件包之前运行
|
||||
- `postuninstall`: 在卸载软件包之后运行
|
||||
- `preversion`: 在改变包版本之前运行
|
||||
- `version`: 改变包版本后运行,但提交之前
|
||||
- `postversion`: 改变包版本后运行,然后提交
|
||||
- `pretest`, `test`, `posttest`: 由 `npm test` 命令运行
|
||||
- `prestop`, `stop`, `poststop`: 由 `npm stop` 命令运行
|
||||
- `prestart`, `start`, `poststart`: 由 `npm start` 命令运行
|
||||
- `prerestart`, `restart`, `postrestart`: 由 `npm restart` 命令运行。 注意:如果没有提供重启脚本,`npm restart` 将运行 `stop` 和`start` 脚本
|
||||
- `preshrinkwrap`, `shrinkwrap`, `postshrinkwrap`: 由 `npm shrinkwrap` 命令运行
|
||||
|
||||
参考文档:[npm docs](https://docs.npmjs.com/misc/scripts).
|
||||
|
||||
@@ -577,7 +669,6 @@ https://registry.npmjs.org/[包名]/-/[包名]-[version].tgz
|
||||
|
||||
此选项指定你的包的操作系统兼容性,它会检查 `process.platform`。
|
||||
|
||||
|
||||
### `cpu`
|
||||
|
||||
```json
|
||||
@@ -624,6 +715,8 @@ Yarn
|
||||
|
||||
### `flat`
|
||||
|
||||
<!-- markdownlint-disable MD042 -->
|
||||
|
||||
如果你的包只允许给定依赖的一个版本,你想强制和命令行上 [yarn install --flat](#) 相同的行为,把这个值设为 `true`。
|
||||
|
||||
```json
|
||||
@@ -651,8 +744,11 @@ Yarn
|
||||
|
||||
注意,`yarn install --flat` 命令将会自动在 `package.json` 文件里加入 `resolutions` 字段。
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [PACKAGE.JSON 中文说明](https://jaywcjlove.github.io/package.json) _(github.io)_
|
||||
- [npm 文档](https://docs.npmjs.com/files/package.json) _(npmjs.com)_
|
||||
- [yarnpkg 文档](https://classic.yarnpkg.com/en/docs/package-json) _(yarnpkg.com)_
|
||||
- [packages 文档](https://nodejs.org/api/packages.html) _(nodejs.org)_
|
||||
- [npm 备忘清单(速查表)](./npm.md) _(jaywcjlove.github.io)_
|
||||
|
629
docs/postgres.md
Normal file
@@ -0,0 +1,629 @@
|
||||
PostgreSQL 备忘清单
|
||||
===
|
||||
|
||||
[PostgreSQL](https://www.postgresql.org/docs/current/) 备忘清单为您提供了常用的 PostgreSQL 命令和语句。
|
||||
|
||||
入门
|
||||
---------------
|
||||
|
||||
### 入门
|
||||
|
||||
切换和连接
|
||||
|
||||
```shell
|
||||
$ sudo -u postgres psql
|
||||
```
|
||||
|
||||
列出所有数据库
|
||||
|
||||
```shell
|
||||
postgres=# \l
|
||||
```
|
||||
|
||||
连接到名为 postgres 的数据库
|
||||
|
||||
```shell
|
||||
postgres=# \c postgres
|
||||
```
|
||||
|
||||
断开
|
||||
|
||||
```shell
|
||||
postgres=# \q
|
||||
postgres=# \!
|
||||
```
|
||||
|
||||
### psql 命令
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
参数 | 示例 | 说明
|
||||
:- |- | -
|
||||
`[-d] <database>` | psql -d mydb | 连接到数据库
|
||||
`-U` | psql -U john mydb | 以特定用户身份连接
|
||||
`-h` `-p` | psql -h localhost -p 5432 mydb | 连接到主机/端口
|
||||
`-U` `-h` `-p` `-d` | psql -U admin -h 192.168.1.5 -p 2506 -d mydb | 连接远程 PostgreSQL
|
||||
`-W` | psql -W mydb | 强制密码
|
||||
`-c` | psql -c '\c postgres' -c '\dt' | 执行 SQL 查询或命令
|
||||
`-H` | psql -c "\l+" -H postgres > database.html | 生成 HTML 报告
|
||||
`-l` | psql -l | 列出所有数据库
|
||||
`-f` | psql mydb -f file.sql | 从文件执行命令
|
||||
`-V` | psql -V | 打印 psql 版本
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 获得帮助
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\h` | SQL 命令语法帮助
|
||||
`\h` DELETE | DELETE SQL 语句语法
|
||||
`\?` | PostgreSQL 命令列表
|
||||
|
||||
在 PostgreSQL 控制台中运行
|
||||
|
||||
PostgreSQL 工作
|
||||
-------
|
||||
|
||||
### Recon 观察
|
||||
|
||||
显示版本
|
||||
|
||||
```sql
|
||||
SHOW SERVER_VERSION;
|
||||
```
|
||||
|
||||
显示系统状态
|
||||
|
||||
```sql
|
||||
\conninfo
|
||||
```
|
||||
|
||||
显示环境变量
|
||||
|
||||
```sql
|
||||
SHOW ALL;
|
||||
```
|
||||
|
||||
列出用户
|
||||
|
||||
```sql
|
||||
SELECT rolname FROM pg_roles;
|
||||
```
|
||||
|
||||
显示当前用户
|
||||
|
||||
```sql
|
||||
SELECT current_user;
|
||||
```
|
||||
|
||||
显示当前用户的权限
|
||||
|
||||
```sql
|
||||
\du
|
||||
```
|
||||
|
||||
显示当前数据库
|
||||
|
||||
```sql
|
||||
SELECT current_database();
|
||||
```
|
||||
|
||||
显示数据库中的所有表
|
||||
|
||||
```sql
|
||||
\dt
|
||||
```
|
||||
|
||||
列出函数
|
||||
|
||||
```sql
|
||||
\df <schema>
|
||||
```
|
||||
|
||||
### Databases 数据库
|
||||
|
||||
列出数据库
|
||||
|
||||
```sql
|
||||
\l
|
||||
```
|
||||
|
||||
连接到数据库
|
||||
|
||||
```sql
|
||||
\c <database_name>
|
||||
```
|
||||
|
||||
显示当前数据库
|
||||
|
||||
```sql
|
||||
SELECT current_database();
|
||||
```
|
||||
|
||||
[创建数据库](http://www.postgresql.org/docs/current/static/sql-createdatabase.html)
|
||||
|
||||
```sql
|
||||
CREATE DATABASE <database_name> WITH OWNER <username>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[删除数据库](http://www.postgresql.org/docs/current/static/sql-dropdatabase.html)
|
||||
|
||||
```sql
|
||||
DROP DATABASE IF EXISTS <database_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[重命名数据库](http://www.postgresql.org/docs/current/static/sql-alterdatabase.html)
|
||||
|
||||
```sql
|
||||
ALTER DATABASE <old_name> RENAME TO <new_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Tables 表
|
||||
|
||||
列出当前数据库中的表
|
||||
|
||||
```sql
|
||||
\dt
|
||||
SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
全局列表
|
||||
|
||||
```sql
|
||||
\dt *.*.
|
||||
SELECT * FROM pg_catalog.pg_tables
|
||||
```
|
||||
|
||||
列表表架构
|
||||
|
||||
```sql
|
||||
\d <table_name>
|
||||
\d+ <table_name>
|
||||
SELECT column_name, data_type, character_maximum_length
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '<table_name>';
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[创建表](http://www.postgresql.org/docs/current/static/sql-createtable.html)
|
||||
|
||||
```sql
|
||||
CREATE TABLE <table_name>(
|
||||
<column_name> <column_type>,
|
||||
<column_name> <column_type>
|
||||
);
|
||||
```
|
||||
|
||||
创建表,主键自增
|
||||
|
||||
```sql
|
||||
CREATE TABLE <table_name> (
|
||||
<column_name> SERIAL PRIMARY KEY
|
||||
);
|
||||
```
|
||||
|
||||
[删除表](http://www.postgresql.org/docs/current/static/sql-droptable.html)
|
||||
|
||||
```sql
|
||||
DROP TABLE IF EXISTS <table_name> CASCADE;
|
||||
```
|
||||
|
||||
### Permissions 权限
|
||||
|
||||
成为 postgres 用户,如果您有权限错误
|
||||
|
||||
```shell
|
||||
sudo su - postgres
|
||||
psql
|
||||
```
|
||||
|
||||
[授予](http://www.postgresql.org/docs/current/static/sql-grant.html) 对数据库的所有权限
|
||||
|
||||
```sql
|
||||
GRANT ALL PRIVILEGES ON DATABASE <db_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予数据库连接权限
|
||||
|
||||
```sql
|
||||
GRANT CONNECT ON DATABASE <db_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予架构权限
|
||||
|
||||
```sql
|
||||
GRANT USAGE ON SCHEMA public TO <user_name>;
|
||||
```
|
||||
|
||||
授予函数权限
|
||||
|
||||
```sql
|
||||
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予在所有表上选择、更新、插入、删除的权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
在表上授予权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT, UPDATE, INSERT ON <table_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予对表的选择权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Columns 列
|
||||
|
||||
[添加栏目](http://www.postgresql.org/docs/current/static/sql-altertable.html)
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
ADD <column_name> <data_type> [<constraints>];
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
更新栏
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
ALTER <column_name> TYPE <data_type> [<constraints>];
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
删除列
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
DROP <column_name>;
|
||||
```
|
||||
|
||||
将列更新为自增主键
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name>
|
||||
ADD COLUMN <column_name> SERIAL PRIMARY KEY;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
使用自动递增的主键插入表中
|
||||
|
||||
```sql
|
||||
INSERT INTO <table_name>
|
||||
VALUES (DEFAULT, <value1>);
|
||||
INSERT INTO <table_name> (<column1_name>,<column2_name>)
|
||||
VALUES ( <value1>,<value2> );
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Data 数据
|
||||
|
||||
[选择](http://www.postgresql.org/docs/current/static/sql-select.html) 所有数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name>;
|
||||
```
|
||||
|
||||
读取一行数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name> LIMIT 1;
|
||||
```
|
||||
|
||||
搜索数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name> WHERE <column_name> = <value>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[插入](http://www.postgresql.org/docs/current/static/sql-insert.html) 数据
|
||||
|
||||
```sql
|
||||
INSERT INTO <table_name> VALUES( <value_1>, <value_2> );
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[更新](http://www.postgresql.org/docs/current/static/sql-update.html) 数据
|
||||
|
||||
```sql
|
||||
UPDATE <table_name>
|
||||
SET <column_1> = <value_1>, <column_2> = <value_2>
|
||||
WHERE <column_1> = <value>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[删除](http://www.postgresql.org/docs/current/static/sql-delete.html) 所有数据
|
||||
|
||||
```sql
|
||||
DELETE FROM <table_name>;
|
||||
```
|
||||
|
||||
删除特定数据
|
||||
|
||||
```sql
|
||||
DELETE FROM <table_name>
|
||||
WHERE <column_name> = <value>;
|
||||
```
|
||||
|
||||
### Users 用户
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
列出角色
|
||||
|
||||
```sql
|
||||
SELECT rolname FROM pg_roles;
|
||||
```
|
||||
|
||||
[创建用户](http://www.postgresql.org/docs/current/static/sql-createuser.html)
|
||||
|
||||
```sql
|
||||
CREATE USER <user_name> WITH PASSWORD '<password>';
|
||||
```
|
||||
|
||||
[删除用户](http://www.postgresql.org/docs/current/static/sql-dropuser.html)
|
||||
|
||||
```sql
|
||||
DROP USER IF EXISTS <user_name>;
|
||||
```
|
||||
|
||||
[更改](http://www.postgresql.org/docs/current/static/sql-alterrole.html) 用户密码
|
||||
|
||||
```sql
|
||||
ALTER ROLE <user_name> WITH PASSWORD '<password>';
|
||||
```
|
||||
|
||||
### Schema
|
||||
|
||||
列出 Schemas
|
||||
|
||||
```sql
|
||||
\dn
|
||||
SELECT schema_name FROM information_schema.schemata;
|
||||
SELECT nspname FROM pg_catalog.pg_namespace;
|
||||
```
|
||||
|
||||
[创建架构](http://www.postgresql.org/docs/current/static/sql-createschema.html)
|
||||
|
||||
```sql
|
||||
CREATE SCHEMA IF NOT EXISTS <schema_name>;
|
||||
```
|
||||
|
||||
[删除模式](http://www.postgresql.org/docs/current/static/sql-dropschema.html)
|
||||
|
||||
```sql
|
||||
DROP SCHEMA IF EXISTS <schema_name> CASCADE;
|
||||
```
|
||||
|
||||
PostgreSQL 命令
|
||||
-----------
|
||||
|
||||
### 表
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\d <table>` | 描述表
|
||||
`\d+ <table>` | 详细描述表格
|
||||
`\dt` | 列出当前模式中的表
|
||||
`\dt *.*` | 列出所有模式中的表
|
||||
`\dt <schema>.*` | 列出架构的表
|
||||
`\dp` | 列出表访问权限
|
||||
`\det[+]` | 列出外部表
|
||||
|
||||
### 查询缓冲区
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\e [FILE]` | 编辑查询缓冲区(或文件)
|
||||
`\ef [FUNC]` | 编辑函数定义
|
||||
`\p` | 显示内容
|
||||
`\r` | 重置(清除)查询缓冲区
|
||||
`\s [FILE]` | 显示历史记录或保存到文件
|
||||
`\w FILE` | 将查询缓冲区写入文件
|
||||
|
||||
### 信息
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\l[+]` | 列出所有数据库
|
||||
`\dn[S+]` | 列出架构
|
||||
`\di[S+]` | 列出索引
|
||||
`\du[+]` | 列出角色
|
||||
`\ds[S+]` | 列出序列
|
||||
`\df[antw][S+]` | 列出函数
|
||||
`\deu[+]` | 列出用户映射
|
||||
`\dv[S+]` | 列表视图
|
||||
`\dl` | 列出大对象
|
||||
`\dT[S+]` | 列出数据类型
|
||||
`\da[S]` | 列出聚合
|
||||
`\db[+]` | 列出表空间
|
||||
`\dc[S+]` | 列出转化
|
||||
`\dC[+]` | 列出演员表
|
||||
`\ddp` | 列出默认权限
|
||||
`\dd[S]` | 显示对象描述
|
||||
`\dD[S+]` | 列出域
|
||||
`\des[+]` | 列出国外服务器
|
||||
`\dew[+]` | 列出外部数据包装器
|
||||
`\dF[+]` | 列出文本搜索配置
|
||||
`\dFd[+]` | 列出文本搜索词典
|
||||
`\dFp[+]` | 列出文本搜索解析器
|
||||
`\dFt[+]` | 列出文本搜索模板
|
||||
`\dL[S+]` | 列出程序语言
|
||||
`\do[S]` | 列出运算符
|
||||
`\dO[S+]` | 列出排序规则
|
||||
`\drds` | 列出每个数据库的角色设置
|
||||
`\dx[+]` | 列出扩展
|
||||
|
||||
`S`:显示系统对象,`+`:附加细节
|
||||
|
||||
### 连接
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\c [DBNAME]` | 连接到新数据库
|
||||
`\encoding [ENCODING]` | 显示或设置客户端编码
|
||||
`\password [USER]` | 更改密码
|
||||
`\conninfo` | 显示信息
|
||||
|
||||
### 格式化
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\a` | 在未对齐和对齐之间切换
|
||||
`\C [STRING]` | 设置表格标题,如果没有则取消设置
|
||||
`\f [STRING]` | 显示或设置未对齐的字段分隔符
|
||||
`\H` | 切换 HTML 输出模式
|
||||
`\t [on\|off]` | 仅显示行
|
||||
`\T [STRING]` | 设置或取消设置 HTML \<table\> 标签属性
|
||||
`\x [on\|off]` | 切换扩展输出
|
||||
|
||||
### 输入输出
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\copy ...` | 导入/导出表 _另见:_ [复制](#导入导出-csv)
|
||||
`\echo [STRING]` | 打印字符串
|
||||
`\i FILE` | 执行文件
|
||||
`\o [FILE]` | 将所有结果导出到文件
|
||||
`\qecho [STRING]` | 输出流的字符串
|
||||
|
||||
### 变量
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\prompt [TEXT] NAME` | 设置变量
|
||||
`\set [NAME [VALUE]]` | 设置变量 _(如果没有参数,则列出所有变量)_
|
||||
`\unset NAME` | 删除变量
|
||||
|
||||
### 杂项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\cd [DIR]` | 更改目录
|
||||
`\timing [on\|off]` | 切换时间
|
||||
`\! [COMMAND]` | 在shell中执行
|
||||
`\! ls -l` | 在shell中列出所有
|
||||
|
||||
### 大对象
|
||||
|
||||
- `\lo_export LOBOID FILE`
|
||||
- `\lo_import FILE [COMMENT]`
|
||||
- `\lo_list`
|
||||
- `\lo_unlink LOBOID`
|
||||
|
||||
各种各样的
|
||||
-------------
|
||||
|
||||
### 备份
|
||||
|
||||
使用 pg_dumpall 备份所有数据库
|
||||
|
||||
```shell
|
||||
$ pg_dumpall -U postgres > all.sql
|
||||
```
|
||||
|
||||
使用 pg_dump 备份数据库
|
||||
|
||||
```shell
|
||||
$ pg_dump -d mydb -f mydb_backup.sql
|
||||
```
|
||||
|
||||
- `-a` 只转储数据,而不是模式(schema)
|
||||
- `-s` 只转储模式,不转储数据
|
||||
- `-c` 在重新创建之前删除数据库
|
||||
- `-C` 还原前创建数据库
|
||||
- `-t` 仅转储命名表
|
||||
- `-F` 格式(`c`:自定义,`d`:目录,`t`:tar)
|
||||
<!--rehype:className=style-none-->
|
||||
|
||||
使用 `pg_dump -?` 获取完整的选项列表
|
||||
|
||||
### 恢复
|
||||
|
||||
使用 psql 恢复数据库
|
||||
|
||||
```shell
|
||||
$ psql -U user mydb < mydb_backup.sql
|
||||
```
|
||||
|
||||
使用 pg_restore 恢复数据库
|
||||
|
||||
```shell
|
||||
$ pg_restore -d mydb mydb_backup.sql -c
|
||||
```
|
||||
|
||||
- `-U` 指定数据库用户
|
||||
- `-c` 在重新创建之前删除数据库
|
||||
- `-C` 还原前创建数据库
|
||||
- `-e` 如果遇到错误退出
|
||||
- `-F` 格式(`c`:自定义,`d`:目录,`t`:tar,`p`:纯文本sql(默认))
|
||||
<!--rehype:className=style-none-->
|
||||
|
||||
使用 `pg_restore -?` 获取完整的选项列表
|
||||
|
||||
### 远程访问
|
||||
|
||||
获取 postgresql.conf 的位置
|
||||
|
||||
```shell
|
||||
$ psql -U postgres -c 'SHOW config_file'
|
||||
```
|
||||
|
||||
附加到 postgresql.conf
|
||||
|
||||
```shell
|
||||
listen_addresses = '*'
|
||||
```
|
||||
|
||||
附加到 pg_hba.conf(与 postgresql.conf 相同的位置)
|
||||
|
||||
```shell
|
||||
host all all 0.0.0.0/0 md5
|
||||
host all all ::/0 md5
|
||||
```
|
||||
|
||||
重启 PostgreSQL 服务器
|
||||
|
||||
```shell
|
||||
$ sudo systemctl restart postgresql
|
||||
```
|
||||
|
||||
### 导入/导出 CSV
|
||||
|
||||
将表格导出为 CSV 文件
|
||||
|
||||
```sql
|
||||
\copy table TO '<path>' CSV
|
||||
\copy table(col1,col1) TO '<path>' CSV
|
||||
\copy (SELECT...) TO '<path>' CSV
|
||||
```
|
||||
|
||||
将 CSV 文件导入表格
|
||||
|
||||
```sql
|
||||
\copy table FROM '<path>' CSV
|
||||
\copy table(col1,col1) FROM '<path>' CSV
|
||||
```
|
||||
|
||||
另见:[复制](https://www.postgresql.org/docs/current/sql-copy.html)
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
- [Posgres-cheatsheet](https://gist.github.com/apolloclark/ea5466d5929e63043dcf#posgres-cheatsheet) _(gist.github.com)_
|
@@ -57,6 +57,7 @@ llo
|
||||
查看: [Strings](#python-字符串)
|
||||
|
||||
### Lists
|
||||
|
||||
```python
|
||||
mylist = []
|
||||
mylist.append(1)
|
||||
@@ -67,7 +68,6 @@ for item in mylist:
|
||||
|
||||
查看: [Lists](#python-lists)
|
||||
|
||||
|
||||
### If Else
|
||||
|
||||
```python
|
||||
@@ -77,6 +77,7 @@ if num > 0:
|
||||
else:
|
||||
print("num is not greater than 0")
|
||||
```
|
||||
|
||||
查看: [流程控制](#python-流程控制)
|
||||
|
||||
### 循环
|
||||
@@ -88,8 +89,8 @@ for item in range(6):
|
||||
else:
|
||||
print("Finally finished!")
|
||||
```
|
||||
查看: [Loops](#python-循环)
|
||||
|
||||
查看: [Loops](#python-循环)
|
||||
|
||||
### 函数
|
||||
|
||||
@@ -101,7 +102,7 @@ else:
|
||||
来自函数的你好
|
||||
```
|
||||
|
||||
查看: [Functions](#python-functions)
|
||||
查看: [Functions](#函数)
|
||||
|
||||
### 文件处理
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
@@ -151,7 +152,7 @@ message += "Part 2."
|
||||
'10 + 10 = 20'
|
||||
```
|
||||
|
||||
查看: [Python F-Strings](#python-f-strings-since-python)
|
||||
查看: [Python F-Strings](#f-字符串(Python 3.6+))
|
||||
|
||||
Python 数据类型
|
||||
---------------
|
||||
@@ -165,6 +166,7 @@ multi_string = """Multiline Strings
|
||||
Lorem ipsum dolor sit amet,
|
||||
consectetur adipiscing elit """
|
||||
```
|
||||
|
||||
查看: [Strings](#python-字符串)
|
||||
|
||||
### 数字
|
||||
@@ -194,8 +196,8 @@ list2 = [True, False, False]
|
||||
list3 = [1, 5, 7, 9, 3]
|
||||
list4 = list((1, 5, 7, 9, 3))
|
||||
```
|
||||
查看: [Lists](#python-lists)
|
||||
|
||||
查看: [Lists](#python-lists)
|
||||
|
||||
### 元组 Tuple
|
||||
|
||||
@@ -361,6 +363,7 @@ o
|
||||
`len()` 函数返回字符串的长度
|
||||
|
||||
### 多份
|
||||
|
||||
```python
|
||||
>>> s = '===+'
|
||||
>>> n = 8
|
||||
@@ -396,7 +399,9 @@ True
|
||||
name = "John"
|
||||
print("Hello, %s!" % name)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
name = "John"
|
||||
age = 23
|
||||
@@ -789,7 +794,7 @@ x = 0
|
||||
for index in range(10):
|
||||
x = index * 10
|
||||
if index == 5:
|
||||
break
|
||||
break
|
||||
print(x)
|
||||
```
|
||||
|
||||
@@ -799,7 +804,7 @@ for index in range(10):
|
||||
for index in range(3, 8):
|
||||
x = index * 10
|
||||
if index == 5:
|
||||
continue
|
||||
continue
|
||||
print(x)
|
||||
```
|
||||
|
||||
@@ -948,6 +953,7 @@ with open("myfile.txt") as file:
|
||||
for line in file:
|
||||
print(line)
|
||||
```
|
||||
|
||||
#### 带行号
|
||||
|
||||
```python
|
||||
@@ -956,7 +962,6 @@ for i, line in enumerate(file, start=1):
|
||||
print("Number %s: %s" % (i, line))
|
||||
```
|
||||
|
||||
|
||||
### 字符串
|
||||
|
||||
#### 写一个字符串
|
||||
@@ -1083,6 +1088,7 @@ class ChildClass(ParentClass):
|
||||
# 调用父级的 print_test()
|
||||
super().print_test()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
@@ -1172,7 +1178,8 @@ Yoki.sound() # => Woof!
|
||||
```python
|
||||
# 这是单行注释
|
||||
```
|
||||
----------
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
""" 可以写多行字符串
|
||||
@@ -1180,7 +1187,9 @@ Yoki.sound() # => Woof!
|
||||
作为文档。
|
||||
"""
|
||||
```
|
||||
----------
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
''' 可以写多行字符串
|
||||
使用三个',并且经常使用
|
||||
|
@@ -29,7 +29,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
|
||||
### 介绍
|
||||
|
||||
在备忘清单采用 `HTML 注释语法`,标识网站布局和一些样式,目的是为了在 `GitHub` 中也是正常毫无瑕疵的预览 `Markdown`。
|
||||
在备忘清单采用 `HTML 注释语法`,标识网站布局和一些样式,目的是为了在 `GitHub` 中也是正常毫无瑕疵的预览 [`Markdown`](./markdown.md)。
|
||||
|
||||
```markdown
|
||||
### 卡片标题
|
||||
@@ -45,7 +45,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
### 注释语法介绍
|
||||
<!--rehype:wrap-class=row-span-3&style=color:black;background-color: #d7a100;-->
|
||||
|
||||
- 在某个 Markdown 语法下方或者后面,添加 HTML注释
|
||||
- 在某个 [`Markdown`](./markdown.md) 语法下方或者后面,添加 HTML注释
|
||||
- 以 `<!--rehype:` 开始,`-->` 结束,包裹参数内容
|
||||
- 内容采用 URL 参数的字符拼接方式
|
||||
|
||||
@@ -78,7 +78,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
---- | ----
|
||||
`body-style` | 包裹所有卡片`外壳`的样式
|
||||
`body-class` | 用于卡片栏布局,添加`类`名
|
||||
`wrap-style` | 卡片栏添加 CSS 样式
|
||||
`wrap-style` | 卡片栏添加 [CSS](./css.md) 样式
|
||||
`wrap-class` | 用于卡片占位,添加`类`名
|
||||
|
||||
### 文字颜色
|
||||
@@ -111,7 +111,6 @@ function () {}
|
||||
|
||||
如果代码块内容太长,使用强制换行类(`wrap-text`)解决
|
||||
|
||||
|
||||
### 展示表格表头
|
||||
|
||||
```markdown
|
||||
@@ -135,7 +134,7 @@ export const Student = (
|
||||
);
|
||||
```
|
||||
|
||||
上面 `{1,4-5}` 行代码高亮,下面是 `Markdown` 代码示例
|
||||
上面 `{1,4-5}` 行代码高亮,下面是 [`Markdown`](./markdown.md) 代码示例
|
||||
|
||||
```markdown
|
||||
```jsx {1,4-5}
|
||||
@@ -209,11 +208,27 @@ const school = <div>学校</div>;
|
||||
:- | -
|
||||
:- | -
|
||||
`<yel>` | <yel>黄色</yel>
|
||||
`<red>` | <yel>红色</yel>
|
||||
`<pur>` | <pur>紫色</pur>
|
||||
`<code>` 或 <code>\`\`</code> | <code>绿</code>`色`
|
||||
`<del>` 或 `~~删除~~` | <del>~~红色~~</del>
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 注释类配置
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
类 | 说明
|
||||
---- | ----
|
||||
`<!--rehype:className=wrap-text-->` | 强制换行
|
||||
`<!--rehype:className=show-header-->` | 展示表格表头
|
||||
`<!--rehype:className=shortcuts-->` | 快捷键样式
|
||||
`<!--rehype:className=auto-wrap-->` | 隐藏表头强制小尺寸自动换行
|
||||
`<!--rehype:className=style-list-arrow-->` | 列表箭头样式展示表格
|
||||
`<!--rehype:className=style-list-->` | 列表样式展示表格
|
||||
`<!--rehype:className=left-align-->` | 表格末尾列左对齐
|
||||
`<!--rehype:className=style-none-->` | \<li> 没有标记
|
||||
`<!--rehype:className=style-timeline-->` | 时间轴样式
|
||||
`<!--rehype:className=style-arrow-->` | 箭头标记
|
||||
|
||||
### 隐藏卡片标题
|
||||
<!--rehype:style=display:none;&wrap-style=padding-top: 0;-->
|
||||
@@ -242,8 +257,24 @@ const school = <div>学校</div>;
|
||||
<b>这里是你的 HTML 代码</b>
|
||||
```
|
||||
|
||||
上面的 `markdown` 代码在 `meta` 位置添加 `preview` 标识,HTML 代码将被执行预览
|
||||
上面的 [`markdown`](./markdown.md) 代码在 `meta` 位置添加 `preview` 标识,[HTML](./html.md) 代码将被执行预览
|
||||
|
||||
### KaTeX 数学渲染
|
||||
|
||||
```KaTeX
|
||||
c = \pm\sqrt{a^2 + b^2}
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
上面示例 [`Markdown`](./markdown.md) 代码源码
|
||||
|
||||
```markdown {1}
|
||||
```KaTeX
|
||||
c = \pm\sqrt{a^2 + b^2}
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
还可以单行展示 `KaTeX:c = \pm\sqrt{a^2 + b^2}`,需要标记 <code>\`KaTeX:数学公式\`</code> 将被显示成数学公式,这是基于 [KaTeX](https://katex.org/) 生成
|
||||
|
||||
布局
|
||||
---
|
||||
@@ -336,7 +367,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### H3 Title 1
|
||||
@@ -361,7 +392,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -409,7 +440,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -433,7 +464,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈┈┈┈┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -457,7 +488,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -481,7 +512,7 @@ H2 部分
|
||||
╰┈┈┈┈┈┈┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -505,7 +536,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
H2 部分
|
||||
@@ -536,7 +567,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@@ -550,7 +581,6 @@ H2 部分
|
||||
|
||||
在 `Title 1` 标题添加 `col-span-2` 和 `row-span-2` 占位类,使用 `空格` 间隔。
|
||||
|
||||
|
||||
表格
|
||||
---
|
||||
|
||||
@@ -667,14 +697,19 @@ H2 部分
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
- **重命名为 new_name**
|
||||
|
||||
```bash
|
||||
$ git branch -m <new_name>
|
||||
```
|
||||
|
||||
- 推送和**重置**
|
||||
|
||||
```bash
|
||||
$ git push origin -u <new_name>
|
||||
```
|
||||
|
||||
- 删除远程分支
|
||||
|
||||
```bash
|
||||
$ git push origin --delete <old>
|
||||
```
|
||||
|
@@ -3,7 +3,6 @@ React 备忘清单
|
||||
|
||||
适合初学者的综合 React 备忘清单。
|
||||
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
@@ -59,7 +58,6 @@ import World, { Hello } from './hello.js';
|
||||
|
||||
使用 `import` 导入 `Hello` 组件,在示例中使用。
|
||||
|
||||
|
||||
### React 组件中的 CSS
|
||||
|
||||
```jsx {2,5}
|
||||
@@ -82,7 +80,6 @@ export const Student = (
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
### 属性
|
||||
|
||||
```jsx
|
||||
@@ -112,7 +109,6 @@ class Student extends React.Component {
|
||||
|
||||
`class` 组件使用 `this.props` 访问传递给组件的属性。
|
||||
|
||||
|
||||
### Children
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -138,7 +134,7 @@ function AlertBox(props) {
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
```jsx
|
||||
{props.children}
|
||||
@@ -158,7 +154,7 @@ class AlertBox extends React.Component {
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
```jsx
|
||||
{this.props.children}
|
||||
@@ -297,7 +293,7 @@ function Student() {
|
||||
|
||||
### Portals
|
||||
|
||||
React 并*没有*创建一个新的 `div`。它只是把子元素渲染到 `domNode` 中。`domNode` 是一个可以在任何位置的有效 DOM 节点。
|
||||
React 并_没有_创建一个新的 `div`。它只是把子元素渲染到 `domNode` 中。`domNode` 是一个可以在任何位置的有效 DOM 节点。
|
||||
|
||||
```jsx
|
||||
render() {
|
||||
@@ -438,7 +434,7 @@ function CustomTextInput(props) {
|
||||
</div>
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
- [识别不安全的生命周期](https://zh-hans.reactjs.org/docs/strict-mode.html#identifying-unsafe-lifecycles)
|
||||
- [关于使用过时字符串 ref API 的警告](https://zh-hans.reactjs.org/docs/strict-mode.html#warning-about-legacy-string-ref-api-usage)
|
||||
@@ -754,7 +750,7 @@ export default function Weather(props) {
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
```js
|
||||
{isShow && <div>内容</div>}
|
||||
@@ -860,7 +856,6 @@ class Welcome extends React.Component {
|
||||
`this.props` | 组件接受参数
|
||||
`this.state` | 组件内状态
|
||||
|
||||
|
||||
### Pure 组件
|
||||
|
||||
```jsx
|
||||
@@ -1003,7 +998,7 @@ Menu.Item = ({ children }) => (
|
||||
);
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
```jsx
|
||||
<Menu>
|
||||
@@ -1330,7 +1325,7 @@ PropTypes 属性类型检查
|
||||
import PropTypes from 'prop-types'
|
||||
```
|
||||
|
||||
----
|
||||
-----
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
@@ -1354,7 +1349,6 @@ import PropTypes from 'prop-types'
|
||||
`oneOf(any)` | 枚举类型
|
||||
`oneOfType([type])` | 几种类型中的任意一个类型
|
||||
|
||||
|
||||
#### _数组 Array_
|
||||
|
||||
:- | -
|
||||
|
106
docs/regex.md
@@ -33,7 +33,6 @@ RegEX 备忘清单
|
||||
`[a-zA-Z]` | 范围内的字符:<br>`a-z` 或 `A-Z`
|
||||
`[a-zA-Z0-9]` | 范围内的字符:<br>`a-z`、`A-Z` 或 `0-9`
|
||||
|
||||
|
||||
### 量词
|
||||
|
||||
范例 | 说明
|
||||
@@ -115,7 +114,6 @@ RegEX 备忘清单
|
||||
`[\b]` | 退格字符
|
||||
`\` | 使任何字符文字
|
||||
|
||||
|
||||
### 锚点
|
||||
|
||||
范例 | 说明
|
||||
@@ -129,7 +127,6 @@ RegEX 备忘清单
|
||||
`\b` | 一个词的边界
|
||||
`\B` | 非单词边界
|
||||
|
||||
|
||||
### 替代
|
||||
|
||||
范例 | 说明
|
||||
@@ -210,8 +207,8 @@ RegEX 备忘清单
|
||||
`(?!...)` | 负先行断言
|
||||
`(?<=...)` | 正后发断言
|
||||
`(?<!...)` | 负后发断言
|
||||
`?= `|正先行断言-存在
|
||||
`?! `|负先行断言-排除
|
||||
`?=`|正先行断言-存在
|
||||
`?!`|负先行断言-排除
|
||||
`?<=`|正后发断言-存在
|
||||
`?<!`|负后发断言-排除
|
||||
|
||||
@@ -276,26 +273,25 @@ RegEX 备忘清单
|
||||
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`ring ` | 匹配 <yel>ring</yel> sp<yel>ring</yel>board 等。
|
||||
`. ` | 匹配 <yel>a</yel>、<yel>9</yel>、<yel>+</yel> 等。
|
||||
`h.o ` | 匹配 <yel>hoo</yel>、<yel>h2o</yel>、<yel>h/o</yel> 等。
|
||||
`ring\? ` | 匹配 <yel>ring?</yel>
|
||||
`\(quiet\) ` | 匹配<yel>(安静)</yel>
|
||||
`c:\\windows ` | 匹配 <yel>c:\windows</yel>
|
||||
`ring` | 匹配 <yel>ring</yel> sp<yel>ring</yel>board 等。
|
||||
`.` | 匹配 <yel>a</yel>、<yel>9</yel>、<yel>+</yel> 等。
|
||||
`h.o` | 匹配 <yel>hoo</yel>、<yel>h2o</yel>、<yel>h/o</yel> 等。
|
||||
`ring\?` | 匹配 <yel>ring?</yel>
|
||||
`\(quiet\)` | 匹配<yel>(安静)</yel>
|
||||
`c:\\windows` | 匹配 <yel>c:\windows</yel>
|
||||
|
||||
使用 `\` 搜索这些特殊字符:<br> `[ \ ^ $ . | ? * + ( ) { }`
|
||||
|
||||
|
||||
### 速记类
|
||||
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`\w ` | “单词”字符 <br> _(字母、数字或下划线)_
|
||||
`\d ` | 数字
|
||||
`\s ` | 空格 <br> _(空格、制表符、vtab、换行符)_
|
||||
`\W, \D, or \S ` | 不是单词、数字或空格
|
||||
`[\D\S] ` | 表示不是数字或空格,两者都匹配
|
||||
`[^\d\s] ` | 禁止数字和空格
|
||||
`\w` | “单词”字符 <br> _(字母、数字或下划线)_
|
||||
`\d` | 数字
|
||||
`\s` | 空格 <br> _(空格、制表符、vtab、换行符)_
|
||||
`\W, \D, or \S` | 不是单词、数字或空格
|
||||
`[\D\S]` | 表示不是数字或空格,两者都匹配
|
||||
`[^\d\s]` | 禁止数字和空格
|
||||
|
||||
### 出现次数
|
||||
|
||||
@@ -311,9 +307,9 @@ RegEX 备忘清单
|
||||
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`cat\|dog ` | 匹配 <yel>cat</yel> 或 <yel>dog</yel>
|
||||
`id\|identity ` | 匹配 <yel>id</yel> 或 <yel>id</yel>entity
|
||||
`identity\|id ` | 匹配 <yel>id</yel> 或 <yel>identity</yel>
|
||||
`cat\|dog` | 匹配 <yel>cat</yel> 或 <yel>dog</yel>
|
||||
`id\|identity` | 匹配 <yel>id</yel> 或 <yel>id</yel>entity
|
||||
`identity\|id` | 匹配 <yel>id</yel> 或 <yel>identity</yel>
|
||||
|
||||
当替代品重叠时,命令从长到短
|
||||
|
||||
@@ -334,7 +330,7 @@ RegEX 备忘清单
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`* + {n,}`<br>_greedy_ | 尽可能匹配
|
||||
`<.+> ` | 在 <yel>\<b>bold\<\/b></yel> 中找到 1 个大匹配项
|
||||
`<.+>` | 在 <yel>\<b>bold\<\/b></yel> 中找到 1 个大匹配项
|
||||
`*? +? {n,}?`<br>_lazy_ | 尽可能少匹配
|
||||
`<.+?>` | 在 \<<yel>b</yel>>bold\<<yel>\/b</yel>> 中找到 2 个匹配项
|
||||
|
||||
@@ -343,18 +339,17 @@ RegEX 备忘清单
|
||||
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`\b ` | “单词”边缘(非“单词”字符旁边)
|
||||
`\bring ` | 单词以“ring”开头,例如 <yel>ringtone</yel>
|
||||
`ring\b ` | 单词以“ring”结尾,例如 <yel>spring</yel>
|
||||
`\b9\b ` | 匹配单个数字 <yel>9</yel>,而不是 19、91、99 等。
|
||||
`\b[a-zA-Z]{6}\b ` | 匹配 6 个字母的单词
|
||||
`\B ` | 不是字边
|
||||
`\Bring\B ` | 匹配 <yel>springs</yel> 和 <yel>wringer</yel>
|
||||
`^\d*$ ` | 整个字符串必须是数字
|
||||
`\b` | “单词”边缘(非“单词”字符旁边)
|
||||
`\bring` | 单词以“ring”开头,例如 <yel>ringtone</yel>
|
||||
`ring\b` | 单词以“ring”结尾,例如 <yel>spring</yel>
|
||||
`\b9\b` | 匹配单个数字 <yel>9</yel>,而不是 19、91、99 等。
|
||||
`\b[a-zA-Z]{6}\b` | 匹配 6 个字母的单词
|
||||
`\B` | 不是字边
|
||||
`\Bring\B` | 匹配 <yel>springs</yel> 和 <yel>wringer</yel>
|
||||
`^\d*$` | 整个字符串必须是数字
|
||||
`^[a-zA-Z]{4,20}$` | 字符串必须有 4-20 个字母
|
||||
`^[A-Z] ` | 字符串必须以大写字母开头
|
||||
`[\.!?"')]$ ` | 字符串必须以终端标点结尾
|
||||
|
||||
`^[A-Z]` | 字符串必须以大写字母开头
|
||||
`[\.!?"')]$` | 字符串必须以终端标点结尾
|
||||
|
||||
### 修饰
|
||||
|
||||
@@ -371,7 +366,7 @@ RegEX 备忘清单
|
||||
|
||||
范例 | 说明
|
||||
:-|-
|
||||
`(in\|out)put ` | 匹配 <yel>input</yel> 或 <yel>output</yel>
|
||||
`(in\|out)put` | 匹配 <yel>input</yel> 或 <yel>output</yel>
|
||||
`\d{5}(-\d{4})?` | 美国邮政编码 _(“+ 4”可选)_
|
||||
|
||||
如果组后匹配失败,解析器会尝试每个替代方案。
|
||||
@@ -417,11 +412,10 @@ RegEX 备忘清单
|
||||
`(?<! )` | 向后看,如果你找不到后面
|
||||
`\b\w+?(?=ing\b)` | 匹配 <yel>warbl</yel>ing, <yel>str</yel>ing, <yel>fish</yel>ing, ...
|
||||
`\b(?!\w+ing\b)\w+\b` | 不以“ing”结尾的单词
|
||||
`(?<=\bpre).*?\b ` | 匹配 pre<yel>tend</yel>、pre<yel>sent</yel>、pre<yel>fix</yel>、...
|
||||
`(?<=\bpre).*?\b` | 匹配 pre<yel>tend</yel>、pre<yel>sent</yel>、pre<yel>fix</yel>、...
|
||||
`\b\w{3}(?<!pre)\w*?\b` | 不以“pre”开头的词
|
||||
`\b\w+(?<!ing)\b` | 匹配不以“ing”结尾的单词
|
||||
|
||||
|
||||
### If-then-else
|
||||
|
||||
匹配 `Mr.` 或 `Ms.` 如果单词 `her` 稍后在字符串中
|
||||
@@ -664,7 +658,6 @@ Python 中的正则表达式
|
||||
import re
|
||||
```
|
||||
|
||||
|
||||
### 实例
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
@@ -736,11 +729,8 @@ False
|
||||
`re.compile` | 编译正则表达式模式供以后使用
|
||||
`re.escape` | 返回所有非字母数字反斜杠的字符串
|
||||
|
||||
|
||||
|
||||
### Flags 标志
|
||||
|
||||
|
||||
:- | - | -
|
||||
:- | - | -
|
||||
`re.I` | `re.IGNORECASE` | 忽略大小写
|
||||
@@ -750,8 +740,6 @@ False
|
||||
`re.U` | `re.UNICODE` | 使 `\w`、`\b`、`\d`、`\s` _unicode 依赖_
|
||||
`re.X` | `re.VERBOSE` | 可读风格
|
||||
|
||||
|
||||
|
||||
JavaScript 中的正则表达式
|
||||
---------------
|
||||
|
||||
@@ -855,7 +843,7 @@ console.log(array[1]);
|
||||
|
||||
### replace()
|
||||
|
||||
```javascript {.wrap}
|
||||
```javascript
|
||||
let text = 'Do you like aPPles?';
|
||||
let regex = /apples/i
|
||||
|
||||
@@ -894,14 +882,12 @@ text.replaceAll(regex, "mangoes");
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
|
||||
PHP中的正则表达式
|
||||
------------
|
||||
|
||||
### 函数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`preg_match()` | 执行正则表达式匹配
|
||||
@@ -911,7 +897,6 @@ PHP中的正则表达式
|
||||
`preg_split()` | 按正则表达式模式拆分字符串
|
||||
`preg_grep()` | 返回与模式匹配的数组条目
|
||||
|
||||
|
||||
### preg_replace
|
||||
|
||||
```php
|
||||
@@ -923,7 +908,6 @@ echo preg_replace($regex, "QuickRef", $str);
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
|
||||
### preg_match
|
||||
|
||||
```php
|
||||
@@ -933,7 +917,6 @@ $regex = "#quickref#i";
|
||||
echo preg_match($regex, $str);
|
||||
```
|
||||
|
||||
|
||||
### preg_matchall
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
@@ -952,7 +935,6 @@ if (preg_match_all($regex, $input_str, $matches_out)) {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### preg_grep
|
||||
|
||||
```php
|
||||
@@ -962,7 +944,6 @@ $regex = "/Jane/";
|
||||
echo preg_grep($regex, $arr);
|
||||
```
|
||||
|
||||
|
||||
### preg_split
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -973,7 +954,6 @@ $regex = "@\s@";
|
||||
print_r(preg_split($regex, $str));
|
||||
```
|
||||
|
||||
|
||||
Java 中的正则表达式
|
||||
-------------
|
||||
|
||||
@@ -1003,10 +983,8 @@ boolean s3 = Pattern.matches(".s", "XXXX");
|
||||
System.out.println(s3); // Outputs: false
|
||||
```
|
||||
|
||||
|
||||
### 模式字段
|
||||
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`CANON_EQ` | 规范等价
|
||||
@@ -1017,7 +995,6 @@ System.out.println(s3); // Outputs: false
|
||||
`UNICODE_CASE` | Unicode 感知大小写折叠
|
||||
`UNIX_LINES` | Unix 行模式
|
||||
|
||||
|
||||
### 方法
|
||||
|
||||
#### Pattern
|
||||
@@ -1043,7 +1020,6 @@ System.out.println(s3); // Outputs: false
|
||||
|
||||
还有更多方法...
|
||||
|
||||
|
||||
### 例子
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -1073,7 +1049,6 @@ while (m.find()) {
|
||||
System.out.println(matches);
|
||||
```
|
||||
|
||||
|
||||
MySQL中的正则表达式
|
||||
-------------
|
||||
<!--rehype:body-class=cols-2-->
|
||||
@@ -1082,16 +1057,15 @@ MySQL中的正则表达式
|
||||
|
||||
函数名称 | 说明
|
||||
:- | -
|
||||
`REGEXP ` | 字符串是否匹配正则表达式
|
||||
`REGEXP_INSTR() ` | 匹配正则表达式的子字符串的起始索引 <br>_(注意:仅限 MySQL 8.0+)_
|
||||
`REGEXP_LIKE() ` | 字符串是否匹配正则表达式 <br>_(注意:仅 MySQL 8.0+)_
|
||||
`REGEXP` | 字符串是否匹配正则表达式
|
||||
`REGEXP_INSTR()` | 匹配正则表达式的子字符串的起始索引 <br>_(注意:仅限 MySQL 8.0+)_
|
||||
`REGEXP_LIKE()` | 字符串是否匹配正则表达式 <br>_(注意:仅 MySQL 8.0+)_
|
||||
`REGEXP_REPLACE()` | 替换匹配正则表达式的子字符串 <br>_(注意:仅限 MySQL 8.0+)_
|
||||
`REGEXP_SUBSTR() ` | 返回匹配正则表达式的子字符串 <br>_(注意:仅 MySQL 8.0+)_
|
||||
|
||||
|
||||
`REGEXP_SUBSTR()` | 返回匹配正则表达式的子字符串 <br>_(注意:仅 MySQL 8.0+)_
|
||||
|
||||
### REGEXP
|
||||
```sql {.wrap}
|
||||
|
||||
```sql
|
||||
expr REGEXP pat
|
||||
```
|
||||
|
||||
@@ -1107,7 +1081,6 @@ mysql> SELECT 'a' REGEXP 'A', 'a' REGEXP BINARY 'A';
|
||||
1 0
|
||||
```
|
||||
|
||||
|
||||
### REGEXP_REPLACE
|
||||
|
||||
```
|
||||
@@ -1123,7 +1096,6 @@ mysql> SELECT REGEXP_REPLACE('abc ghi', '[a-z]+', 'X', 1, 2);
|
||||
abc X
|
||||
```
|
||||
|
||||
|
||||
### REGEXP_SUBSTR
|
||||
|
||||
```
|
||||
@@ -1139,7 +1111,6 @@ mysql> SELECT REGEXP_SUBSTR('abc def ghi', '[a-z]+', 1, 3);
|
||||
ghi
|
||||
```
|
||||
|
||||
|
||||
### REGEXP_LIKE
|
||||
|
||||
```
|
||||
@@ -1161,10 +1132,9 @@ mysql> SELECT regexp_like('a\nb\nc', '^b$', 'm');
|
||||
1
|
||||
```
|
||||
|
||||
|
||||
### REGEXP_INSTR
|
||||
|
||||
``` {.wrap}
|
||||
```
|
||||
REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])
|
||||
```
|
||||
|
||||
|
@@ -133,7 +133,6 @@ Resolutions 备忘清单
|
||||
| Xiaomi Redmi Note 8 Pro (2019) | 6.53 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 395 <sub>ppi</sub> | 144 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 平板
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
@@ -159,7 +158,6 @@ Resolutions 备忘清单
|
||||
| Google Pixel C (2015) | 10.2 <sub>inch</sub> | 2560x1800 <sub>px</sub> | 1280 x 900 <sub>px</sub> | 308 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 6.0.1 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 笔记本电脑
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
|
2452
docs/ruby.md
Normal file
899
docs/rust.md
Normal file
@@ -0,0 +1,899 @@
|
||||
Rust 备忘清单
|
||||
====
|
||||
|
||||
Rust 快速参考备忘单,旨在为编写基本语法和方法提供帮助。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello_World.rs
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, World!");
|
||||
}
|
||||
```
|
||||
|
||||
#### 编译运行
|
||||
|
||||
```shell
|
||||
$ rustc Hello_World.rs
|
||||
$ ./Hello_World
|
||||
Hello, World!
|
||||
```
|
||||
|
||||
### 原始类型
|
||||
|
||||
:-| :-
|
||||
:-| :-
|
||||
`bool` | 布尔值 (`true` _/_ `false`)
|
||||
`char` | 字符
|
||||
`f32`, `f64` | 32 位、64 位浮点数
|
||||
`i64`, `i32`, `i16`, `i8` | 有符号 16- ... 整数
|
||||
`u64`, `u32`, `u16`, `u8` | 无符号 16 位,... 整数
|
||||
`isize` | 指针大小的有符号整数
|
||||
`usize` | 指针大小的无符号整数
|
||||
|
||||
查看: [Rust 类型](#rust-类型)
|
||||
|
||||
### 格式化
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```rust
|
||||
// 单个占位符
|
||||
println!("{}", 1);
|
||||
// 多个占位符
|
||||
println!("{} {}", 1, 3);
|
||||
// 位置参数
|
||||
println!("{0} 是 {1} {2},{0} 也是 {3} 编程语言", "Rust", "cool", "language", "safe");
|
||||
// 命名参数
|
||||
println!("{country} 是一个团结的国家", country = "China");
|
||||
// 占位符特征 :b 表示二进制, :0x 表示十六进制, :o 表示八进制
|
||||
println!("让我们打印 76 是二进制的 {:b} ,十六进制等价物是 {:0x} 八进制等价物是 {:o}", 76, 76, 76);
|
||||
// 调试特征
|
||||
println!("使用调试特征 {:?} 在此处打印我们想要的任何内容", (76, 'A', 90));
|
||||
|
||||
// 1.58 中的新格式字符串
|
||||
let x = "world";
|
||||
println!("Hello {x}!");
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 打印风格
|
||||
|
||||
```rust
|
||||
// 打印输出
|
||||
print!("Hello World\n");
|
||||
// 打印后追加新行
|
||||
println!("追加新行");
|
||||
// 打印为错误
|
||||
eprint!("这是一个错误\n");
|
||||
// 打印为新行错误
|
||||
eprintln!("这是新行的错误");
|
||||
```
|
||||
|
||||
### 变量
|
||||
|
||||
```rust
|
||||
// 初始化和声明变量
|
||||
let some_variable = "This_is_a_variable";
|
||||
// 使变量可变
|
||||
let mut mutable_variable = "Mutable";
|
||||
// 分配多个变量
|
||||
let (name, age) = ("ElementalX", 20);
|
||||
// (全局)常量
|
||||
const SCREAMING_SNAKE_CASE:i64 = 9;
|
||||
```
|
||||
|
||||
### 注释
|
||||
|
||||
```rust
|
||||
// 行注释
|
||||
/*.............块注释 */
|
||||
/// 外部文档注释
|
||||
//! 内部文档评论
|
||||
```
|
||||
|
||||
另见: [注释](https://doc.rust-lang.org/reference/comments.html) _(doc.rust-lang.org)_
|
||||
|
||||
### 函数
|
||||
|
||||
```rust
|
||||
fn test(){
|
||||
println!("这是一个函数!");
|
||||
}
|
||||
fn main(){
|
||||
test();
|
||||
}
|
||||
```
|
||||
|
||||
查看: [Functions](#rust-函数)
|
||||
|
||||
### 声明宏
|
||||
|
||||
```rust
|
||||
macro_rules! foo {
|
||||
($l:tt) => { bar!($l); }
|
||||
}
|
||||
macro_rules! bar {
|
||||
(3) => {}
|
||||
}
|
||||
foo!(3);
|
||||
```
|
||||
|
||||
### 元变量
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`item` | 程序项
|
||||
`block` | 块表达式
|
||||
`stmt` | 语句<br/> _(注意此选择器不匹配句尾的分号)_
|
||||
`pat` | 模式
|
||||
`expr` | 表达式
|
||||
`ty` | 类型
|
||||
`ident` | 标识符或关键字
|
||||
`path` | 类型表达式 形式的路径
|
||||
`tt` | `token` 树<br/> _(单个 `token` 或宏匹配定界符 `()`、`[]` 或 `{}` 中的标记)_
|
||||
`meta` | 属性,属性中的内容
|
||||
`lifetime` | 生存期 `token`
|
||||
`vis` | 可能为空的可见性限定符
|
||||
`literal` | 匹配 `-?` 字面量表达式
|
||||
|
||||
### 结构体
|
||||
|
||||
```rust
|
||||
struct Point { x: i32, y: i32 }
|
||||
let p = Point { x: 10, y: 11 };
|
||||
let px: i32 = p.x;
|
||||
```
|
||||
|
||||
结构体是一个使用关键字 `struct` 定义的标称型(nominal)结构体类型
|
||||
|
||||
### 枚举
|
||||
|
||||
```rust
|
||||
enum Foo {
|
||||
Bar, // 0
|
||||
Baz = 123, // 123
|
||||
Quux, // 124
|
||||
}
|
||||
|
||||
let baz_discriminant = Foo::Baz as u32;
|
||||
assert_eq!(baz_discriminant, 123);
|
||||
```
|
||||
|
||||
Rust 类型
|
||||
--------
|
||||
|
||||
### 类型别名
|
||||
|
||||
```rust
|
||||
type Point = (u8, u8);
|
||||
let p: Point = (41, 68);
|
||||
```
|
||||
|
||||
### 整数
|
||||
|
||||
```rust
|
||||
let mut a: u32 = 8;
|
||||
let b = 877_u64;
|
||||
let c = 8999i64;
|
||||
let d = -90;
|
||||
```
|
||||
|
||||
### 浮点数
|
||||
|
||||
```rust
|
||||
let mut sixty_bit_float: f64 = 89.90;
|
||||
let thirty_two_bit_float: f32 = 7.90;
|
||||
let just_a_float = 69.69;
|
||||
```
|
||||
|
||||
### 布尔值
|
||||
|
||||
```rust
|
||||
let true_val: bool = true;
|
||||
let false_val: bool = false;
|
||||
let just_a_bool = true;
|
||||
let is_true = 8 < 5; // => false
|
||||
```
|
||||
|
||||
### 字符
|
||||
|
||||
```rust
|
||||
let first_letter_of_alphabet = 'a';
|
||||
let explicit_char: char = 'F';
|
||||
let implicit_char = '8';
|
||||
let emoji = "\u{1f600}"; // => 😀
|
||||
```
|
||||
|
||||
### 字符串字面量
|
||||
|
||||
```rust
|
||||
let community_name = "AXIAL";
|
||||
let no_of_members: &str = "ten";
|
||||
println!("社区的名称是 {community_name},它有 {no_of_members} 个成员");
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
查看: [字符串](#rust-字符串)
|
||||
|
||||
### 数组
|
||||
|
||||
```rust
|
||||
┌─────┬─────┬─────┬─────┬─────┬─────┐
|
||||
| 92 | 97 | 98 | 99 | 98 | 94 |
|
||||
└─────┴─────┴─────┴─────┴─────┴─────┘
|
||||
0 1 2 3 4 5
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let array: [i64; 6] = [92,97,98,99,98,94];
|
||||
```
|
||||
|
||||
### 多维数组
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```rust
|
||||
j0 j1 j2 j3 j4 j5
|
||||
┌────┬────┬────┬────┬────┬────┐
|
||||
i0 | 1 | 2 | 3 | 4 | 5 | 6 |
|
||||
├────┼────┼────┼────┼────┼────┤
|
||||
i1 | 6 | 5 | 4 | 3 | 2 | 1 |
|
||||
└────┴────┴────┴────┴────┴────┘
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let array: [[i64; 6] ;2] = [
|
||||
[1,2,3,4,5,6],
|
||||
[6,5,4,3,2,1]];
|
||||
```
|
||||
|
||||
### 可变数组
|
||||
|
||||
```rust
|
||||
let mut array: [i32 ; 3] = [2,6,10];
|
||||
array[1] = 4;
|
||||
array[2] = 6;
|
||||
```
|
||||
|
||||
使用 `mut` 关键字使其可变
|
||||
|
||||
### 切片
|
||||
|
||||
```rust
|
||||
let mut array: [ i64; 4] = [1,2,3,4];
|
||||
// 下限包括在内,上限不包括在内
|
||||
let mut slices: &[i64] = &array[0..3]
|
||||
println!("切片的元素是:{slices:?}");
|
||||
```
|
||||
|
||||
### 向量
|
||||
|
||||
```rust
|
||||
let some_vector = vec![1,2,3,4,5];
|
||||
```
|
||||
|
||||
使用 `vec!` 宏声明向量
|
||||
|
||||
### 元组
|
||||
|
||||
```rust
|
||||
let tuple = (1, 'A' , "Cool", 78, true);
|
||||
```
|
||||
|
||||
Rust 字符串
|
||||
--------------
|
||||
|
||||
### 字符串字面量
|
||||
|
||||
```rust
|
||||
let cs:&str = "备忘清单";
|
||||
// => 为开发者分享备忘单
|
||||
println!("为开发者分享 {cs}");
|
||||
```
|
||||
|
||||
### 字符串对象
|
||||
|
||||
```rust
|
||||
// 创建一个空字符串对象
|
||||
let my_string = String::new;
|
||||
// 转换为字符串对象
|
||||
let S_string = a_string.to_string()
|
||||
// 创建一个初始化的字符串对象
|
||||
let lang = String::from("Rust");
|
||||
println!("First language is {lang}");
|
||||
```
|
||||
|
||||
### .capacity()
|
||||
|
||||
```rust
|
||||
let rand = String::from("Random String");
|
||||
rand.capacity() // => 13
|
||||
```
|
||||
|
||||
以字节为单位计算字符串的容量
|
||||
|
||||
### .contains()
|
||||
|
||||
```rust
|
||||
let name = String::from("ElementalX");
|
||||
name.contains("Element") // => true
|
||||
```
|
||||
|
||||
检查子字符串是否包含在原始字符串中
|
||||
|
||||
### 添加单个字符
|
||||
|
||||
```rust
|
||||
let mut half_text = String::from("Hal");
|
||||
half_text.push('f'); // => Half
|
||||
```
|
||||
|
||||
### 添加整个字符串
|
||||
|
||||
```rust
|
||||
let mut hi = String::from("Hey there...");
|
||||
hi.push_str("How are you doing??");
|
||||
// => Hey there...How are you doing??
|
||||
println!("{hi}");
|
||||
```
|
||||
|
||||
### 原生字符串
|
||||
|
||||
```rust
|
||||
let str1 = r#"\hello"#;
|
||||
println!("{}", str1);
|
||||
// \hello
|
||||
```
|
||||
|
||||
原生字符串,无需增加转义字符(`\`)转义
|
||||
|
||||
### 字节和字节串
|
||||
|
||||
```rust
|
||||
let str2 = b'a';
|
||||
println!("{}", str2);
|
||||
// 97
|
||||
let str3 = b"\\hello";
|
||||
println!("{:?}", str3);
|
||||
// [92, 104, 101, 108, 108, 111]
|
||||
let str4 = br#"\hello"#;
|
||||
println!("{:?}", str4);
|
||||
// [92, 104, 101, 108, 108, 111]
|
||||
```
|
||||
|
||||
Rust 动态数组
|
||||
-----------
|
||||
|
||||
### 创建动态数组
|
||||
|
||||
```rust
|
||||
let v: Vec<i32> = Vec::new();
|
||||
// 使用宏
|
||||
let v1 = vec![1, 2, 3];
|
||||
```
|
||||
|
||||
### 读取元素
|
||||
|
||||
```rust
|
||||
let v = vec![1, 2, 3, 4, 5];
|
||||
|
||||
let element = &v[100];
|
||||
// panic,越界
|
||||
let element2 = v.get(100);
|
||||
println!("{:?}", element2);
|
||||
//None
|
||||
```
|
||||
|
||||
### 遍历数组
|
||||
|
||||
1. 只读取数组中的元素
|
||||
|
||||
```rust
|
||||
let v = vec![1, 2, 3];
|
||||
for i in &v {
|
||||
println!("{}", i);
|
||||
}
|
||||
```
|
||||
|
||||
2. 遍历的同时修改数组中的元素
|
||||
|
||||
```rust
|
||||
let mut v = vec![1, 2, 3];
|
||||
for i in &mut v {
|
||||
*i += 10
|
||||
}
|
||||
```
|
||||
|
||||
### 常用方法
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
-|:-
|
||||
-|:-
|
||||
`len()` | 返回 `vec` 的长度
|
||||
`is_empty()` | `vec` 是否为空
|
||||
`push(value)` | 在 `vec` 尾部插入元素
|
||||
`pop()` | 删除并返回 `vec` 尾部的元素或者返回 `None`
|
||||
`insert(index,element)` | 在指定索引处插入元素
|
||||
`remove(index)` | 删除指定索引处的元素并返回被删除的元素,索引越界将 panic 报错退出
|
||||
`clear()` | 清空 `vec`
|
||||
`append(vec)` | 将另一个 `vec` 中的所有元素追加移入 `vec` 中,移动的 `vec` 变为空
|
||||
`truncate(len)` | 将 `vec` 截断到指定长度,多余的元素被删除
|
||||
`retain(f)` | 根据给定的函数,保留满足条件的元素
|
||||
`drain(range)` | 删除 `vec` 中指定范围的元素,同时返回一个迭代该范围所有元素的迭代器
|
||||
`split_off(index)` | 切分 `vec`,索引左边的元素保留在原 `vec` 中(含索引),索引右边的元素(不含索引)在返回的 `vec` 中
|
||||
|
||||
Rust 运算符
|
||||
-----------
|
||||
|
||||
### 比较运算符
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`e == f` | `e` 等于 `f`
|
||||
`e != f` | `e` 不等于 `f`
|
||||
`e < f` | `e` 小于 `f`
|
||||
`e > f` | `e` 大于 `f`
|
||||
`e <= f` | `e` 小于或等于 `f`
|
||||
`e >= f` | `e` 大于或等于 `f`
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let (e, f) = (1, 100);
|
||||
let greater = f > e; // => true
|
||||
let less = f < e; // => false
|
||||
let greater_equal = f >= e; // => true
|
||||
let less_equal = e <= f; // => true
|
||||
let equal_to = e == f; // => false
|
||||
let not_equal_to = e != f; // => true
|
||||
```
|
||||
|
||||
### 算术运算符
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`a + b` | `a` 被添加到 `b`
|
||||
`a - b` | 从 `a` 中减去`b`
|
||||
`a / b` | `a` 除以 `b`
|
||||
`a % b` | 通过与 `b` 相除得到 `a` 的余数
|
||||
`a * b` | `a` 与 `b` 相乘
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let (a, b) = (4, 5);
|
||||
let sum: i32 = a + b; // => 9
|
||||
let subtractions: i32 = a - b; // => -1
|
||||
let multiplication: i32 = a * b; // => 20
|
||||
let division: i32 = a / b; // => 0
|
||||
let modulus: i32 = a % b; // => 4
|
||||
```
|
||||
|
||||
### 位运算符
|
||||
|
||||
运算符 | 描述
|
||||
:- | :-
|
||||
`g & h` | 二进制与
|
||||
`g \| h` | 二进制或
|
||||
`g ^ h` | 二进制异或
|
||||
`g ~ h` | 二进制补码
|
||||
`g << h` | 二进制左移
|
||||
`g >> h` | 二进制右移
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let (g, h) = (0x1, 0x2);
|
||||
let bitwise_and = g & h; // => 0
|
||||
let bitwise_or = g | h; // => 3
|
||||
let bitwise_xor = g ^ h; // => 3
|
||||
let right_shift = g >> 2; // => 0
|
||||
let left_shift = h << 4; // => 32
|
||||
```
|
||||
|
||||
### 逻辑运算符
|
||||
|
||||
示例 | 意义
|
||||
:- | :-
|
||||
`c && d` | 两者都是真的_(AND)_
|
||||
`c || d` | 要么是真的_(OR)_
|
||||
`!c` | `c` 为假 _(NOT)_
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let (c, d) = (true, false);
|
||||
let and = c && d; // => false
|
||||
let or = c || d; // => true
|
||||
let not = !c; // => false
|
||||
```
|
||||
|
||||
### 复合赋值运算符
|
||||
|
||||
```rust
|
||||
let mut k = 9;
|
||||
let mut l = k;
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
运算符 | 描述
|
||||
:- | :-
|
||||
`k += l` | 添加一个值并赋值,然后 `k=9`
|
||||
`k -= l` | `Substrate` 一个值并赋值,然后 `k=18`
|
||||
`k /= l` | 除以一个值并赋值,然后 `k=9`
|
||||
`k *= l` | 乘一个值并赋值,然后 `k=81`
|
||||
`k \|= l` | 按位或并赋值,则 `k=89`
|
||||
|
||||
Rust 流程控制
|
||||
------------
|
||||
|
||||
### If表达式
|
||||
|
||||
```rust
|
||||
let case1: i32 = 81;
|
||||
let case2: i32 = 82;
|
||||
if case1 < case2 {
|
||||
println!("case1 大于 case2");
|
||||
}
|
||||
```
|
||||
|
||||
### If...Else 表达式
|
||||
|
||||
```rust
|
||||
let case3 = 8;
|
||||
let case4 = 9;
|
||||
if case3 >= case4 {
|
||||
println!("case3 优于 case4");
|
||||
} else {
|
||||
println!("case4 大于 case3");
|
||||
}
|
||||
```
|
||||
|
||||
### If...Else...if...Else 表达式
|
||||
|
||||
```rust
|
||||
let foo = 12;
|
||||
let bar = 13;
|
||||
if foo == bar {
|
||||
println!("foo 等于 bar");
|
||||
} else if foo < bar {
|
||||
println!("foo 小于 bar");
|
||||
} else if foo != bar {
|
||||
println!("foo 不等于 bar");
|
||||
} else {
|
||||
println!("Nothing");
|
||||
}
|
||||
```
|
||||
|
||||
### If...let 表达式
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```rust
|
||||
let mut arr1:[i64 ; 3] = [1,2,3];
|
||||
if let[1,2,_] = arr1{
|
||||
println!("与数组一起使用");
|
||||
}
|
||||
let mut arr2:[&str; 2] = ["one", "two"];
|
||||
if let["Apple", _] = arr2{
|
||||
println!("也适用于 str 数组");
|
||||
}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let tuple_1 = ("India", 7, 90, 90.432);
|
||||
if let(_, 7, 9, 78.99) = tuple_1{
|
||||
println!("也适用于元组");
|
||||
}
|
||||
let tuple_2 = ( 9, 7, 89, 12, "Okay");
|
||||
if let(9, 7,89, 12, blank) = tuple_2 {
|
||||
println!("一切{blank}伴侣?");
|
||||
}
|
||||
let tuple_3 = (89, 90, "Yes");
|
||||
if let(9, 89, "Yes") = tuple_3{
|
||||
println!("模式确实匹配");
|
||||
}
|
||||
else {
|
||||
println!("模式不匹配");
|
||||
}
|
||||
```
|
||||
|
||||
### 匹配表达式
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```rust
|
||||
let day_of_week = 2;
|
||||
match day_of_week {
|
||||
1 => {
|
||||
println!("兄弟们今天是星期一");
|
||||
},
|
||||
2 => {
|
||||
println!("兄弟们今天是星期二");
|
||||
},
|
||||
3 => {
|
||||
println!("兄弟们今天是星期三");
|
||||
},
|
||||
4 => {
|
||||
println!("兄弟们今天是星期四");
|
||||
},
|
||||
5 => {
|
||||
println!("兄弟们今天是星期五");
|
||||
},
|
||||
6 => {
|
||||
println!("兄弟们今天是星期六");
|
||||
},
|
||||
7 => {
|
||||
println!("兄弟们今天是星期天");
|
||||
},
|
||||
_ => {
|
||||
println!("默认!")
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 嵌套...If 表达式
|
||||
|
||||
```rust
|
||||
let nested_conditions = 89;
|
||||
if nested_conditions == 89 {
|
||||
let just_a_value = 98;
|
||||
if just_a_value >= 97 {
|
||||
println!("大于 97");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### For 循环
|
||||
|
||||
```rust
|
||||
for mut i in 0..15 {
|
||||
i-=1;
|
||||
println!("i 的值为:{i}");
|
||||
}
|
||||
```
|
||||
|
||||
### While 循环
|
||||
|
||||
```rust
|
||||
let mut check = 0;
|
||||
while check < 11{
|
||||
println!("check 是:{check}");
|
||||
check+=1;
|
||||
println!("递增后:{check}");
|
||||
if check == 10{
|
||||
break; // 停止 while
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Loop 关键字
|
||||
|
||||
```rust
|
||||
loop {
|
||||
println!("你好,世界永远!");
|
||||
}
|
||||
```
|
||||
|
||||
无限循环表示
|
||||
|
||||
### Break 中断语句
|
||||
|
||||
```rust
|
||||
let mut i = 1;
|
||||
loop {
|
||||
println!("i 是 {i}");
|
||||
if i > 100 {
|
||||
break;
|
||||
}
|
||||
i *= 2;
|
||||
}
|
||||
```
|
||||
|
||||
### Continue 继续声明
|
||||
|
||||
```rust
|
||||
for (v, c) in (0..10+1).enumerate(){
|
||||
println!("{c} 数字循环");
|
||||
if v == 9{
|
||||
println!("我们继续?");
|
||||
continue;
|
||||
}
|
||||
println!{"v 的值为:{v}"};
|
||||
}
|
||||
```
|
||||
|
||||
Rust 函数
|
||||
--------
|
||||
|
||||
### 基本函数
|
||||
|
||||
```rust
|
||||
fn print_message(){
|
||||
println!("Hello, Quick Reference!");
|
||||
}
|
||||
fn main(){
|
||||
// 在 Rust 中调用函数
|
||||
print_message();
|
||||
}
|
||||
```
|
||||
|
||||
### 按值传递
|
||||
|
||||
```rust
|
||||
fn main()
|
||||
{
|
||||
let x:u32 = 10;
|
||||
let y:u32 = 20;
|
||||
|
||||
// => 200
|
||||
println!("计算: {}", cal_rect(x, y));
|
||||
}
|
||||
fn cal_rect(x:u32, y:u32) -> u32
|
||||
{
|
||||
x * y
|
||||
}
|
||||
```
|
||||
|
||||
### 通过引用传递
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut by_ref = 3; // => 3
|
||||
power_of_three(&mut by_ref);
|
||||
println!("{by_ref}"); // => 9
|
||||
}
|
||||
fn power_of_three(by_ref: &mut i32){
|
||||
// 取消引用很重要
|
||||
*by_ref = *by_ref * *by_ref;
|
||||
println!("{by_ref}"); // => 9
|
||||
}
|
||||
```
|
||||
|
||||
### 返回
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let (mut radius, mut pi) = (3.0, 3.14);
|
||||
let(area, _perimeter) = calculate (
|
||||
&mut radius,
|
||||
&mut pi
|
||||
);
|
||||
println!("圆的面积和周长为:{area} & {_perimeter}");
|
||||
}
|
||||
fn calculate(radius : &mut f64, pi: &mut f64) -> (f64, f64){
|
||||
let perimeter = 2.0 * *pi * *radius;
|
||||
let area = *pi * *radius * *radius;
|
||||
return (area, perimeter);
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 数组作为参数
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut array: [i32 ; 5] = [1,2,3,4,6];
|
||||
print_arrays(array);
|
||||
println!("元素:{array:?}");
|
||||
}
|
||||
fn print_arrays(mut array:[i32; 5]) {
|
||||
array[0] = 89;
|
||||
array[1] = 90;
|
||||
array[2] = 91;
|
||||
array[3] = 92;
|
||||
array[4] = 93;
|
||||
println!("元素:{array:?}");
|
||||
}
|
||||
```
|
||||
|
||||
### 返回数组
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut arr:[i32; 5] = [2,4,6,8,10];
|
||||
multiply(arr);
|
||||
println!("数组是:{:?}", multiply(arr));
|
||||
}
|
||||
fn multiply (mut arr: [i32 ; 5]) -> [i32 ; 5]{
|
||||
arr[2] = 90;
|
||||
for mut i in 0..5 {
|
||||
arr[i] = arr[i] * arr[2];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 泛型函数
|
||||
|
||||
```rust
|
||||
use std::fmt::Debug;
|
||||
fn foo<T>(x: &[T]) where T: Debug {
|
||||
// 省略细节
|
||||
}
|
||||
foo(&[1, 2]);
|
||||
```
|
||||
|
||||
杂项
|
||||
-----
|
||||
|
||||
### 类型断言 type-casting
|
||||
|
||||
```rust
|
||||
let a_int = 90; // int
|
||||
// int 到 float
|
||||
let mut type_cast = (a_int as f64);
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let orginal: char = 'I';
|
||||
// char 到 int => 73
|
||||
let type_casted: i64 = orginal as i64;
|
||||
```
|
||||
|
||||
要在 `Rust` 中执行类型转换,必须使用 `as` 关键字
|
||||
|
||||
### 借用
|
||||
|
||||
```rust
|
||||
let mut foo = 4;
|
||||
let mut borrowed_foo = &foo;
|
||||
println!("{borrowed_foo}");
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```rust
|
||||
let mut bar = 3;
|
||||
let mut mutable_borrowed_bar = &mut bar;
|
||||
println!("{mutable_borrowed_bar}");
|
||||
```
|
||||
|
||||
这里借用的值使用 `&` 运算符从值一中借用值
|
||||
|
||||
### 解引用
|
||||
|
||||
```rust
|
||||
let mut borrow = 10;
|
||||
let deref = &mut borrow;
|
||||
println!("{}", *deref);
|
||||
```
|
||||
|
||||
`*` 操作符用于解引用
|
||||
|
||||
### 作用域
|
||||
|
||||
```rust
|
||||
{
|
||||
// 范围仅限于此大括号
|
||||
let a_number = 1;
|
||||
}
|
||||
println!("{a_number}");
|
||||
```
|
||||
|
||||
这将产生错误,因为变量 `a_number` 的生命周期在大括号处结束
|
||||
|
||||
另见
|
||||
--------
|
||||
|
||||
- [Cargo 备忘清单](./cargo.md) _(jaywcjlove.github.io)_
|
||||
- [The Rust Document](https://doc.rust-lang.org/book/ch00-00-introduction.html) _(doc.rust-lang.org)_
|
||||
- [The Rust Reference](https://doc.rust-lang.org/reference/introduction.html) _(doc.rust-lang.org)_
|
||||
- [Rust Cheatsheet](https://phaiax.github.io/rust-cheatsheet/) _(phaiax.github.io)_
|
||||
- [Rust 标准库文档中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/std/std/) _(jaywcjlove.github.io)_
|
||||
- [Rust 程序设计语言 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/book/) _(jaywcjlove.github.io)_
|
||||
- [Rust By Example 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rust-by-example-cn/) _(jaywcjlove.github.io)_
|
||||
- [Rust 参考手册中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/reference/) _(jaywcjlove.github.io)_
|
||||
- [RustDoc 手册中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rustdoc/) _(jaywcjlove.github.io)_
|
||||
- [Rust Cookbook 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rust-cookbook/) _(jaywcjlove.github.io)_
|
@@ -156,7 +156,6 @@ h1 {
|
||||
Sass 混合(Mixins)
|
||||
------
|
||||
|
||||
|
||||
### 参数
|
||||
|
||||
```scss
|
||||
@@ -264,7 +263,7 @@ green($color)
|
||||
blue($color)
|
||||
```
|
||||
|
||||
---
|
||||
----
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
|
@@ -30,7 +30,6 @@ $ screen -ls
|
||||
$ screen -r <name/pid>
|
||||
```
|
||||
|
||||
|
||||
### 选项
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
@@ -45,7 +44,6 @@ $ screen -r <name/pid>
|
||||
`-X` | screen -X -S debug kill | 终止正在运行的会话
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 进入
|
||||
|
||||
Command | Description
|
||||
@@ -108,7 +106,6 @@ Command | Description
|
||||
`Ctrl-A` `H` | 在屏幕会话中启用日志记录
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 分屏
|
||||
|
||||
Command | Description
|
||||
@@ -121,7 +118,6 @@ Command | Description
|
||||
`Ctrl-A` `Q` | 删除除当前区域之外的所有区域
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 滚动
|
||||
|
||||
Command | Description
|
||||
|
33
docs/sed.md
@@ -71,26 +71,26 @@ Sed 命令
|
||||
### 命令
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
| Command | Example | Description |
|
||||
|---------|----------------------------------------|-----------------------------|
|
||||
| `p` | sed -n '1,4 p' input.txt | Print lines 1-4 |
|
||||
| `p` | sed -n -e '1,4 p' -e '6,7 p' input.txt | Print lines 1-4 and 6-7 |
|
||||
| `d` | sed '1,4 d' input.txt | Print lines except 1-4 |
|
||||
| `w` | sed -n '1,4 w output.txt' input.txt | Write pattern space to file |
|
||||
| `a` | sed '2 a new-line' input.txt | Append line after |
|
||||
| `i` | sed '2 i new-line' input.txt | Insert line before |
|
||||
命令 | 示例 | 描述
|
||||
:- | :- |:-
|
||||
`p` | sed -n '1,4 p' input.txt | 打印第 1-4 行
|
||||
`p` | sed -n -e '1,4 p' -e '6,7 p' input.txt | 打印第 1-4 行和第 6-7 行
|
||||
`d` | sed '1,4 d' input.txt | 打印除 1-4 之外的行
|
||||
`w` | sed -n '1,4 w output.txt' input.txt | 将模式空间写入文件
|
||||
`a` | sed '2 a new-line' input.txt | 在后面追加一行
|
||||
`i` | sed '2 i new-line' input.txt | 在前面插入行
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 空间命令
|
||||
|
||||
| Command | Description |
|
||||
|---------|--------------------------------------------------------------|
|
||||
| `n` | 打印模式空间,空模式空间,读取下一行 |
|
||||
| `x` | 用保持空间交换模式空间 |
|
||||
| `h` | 复制模式空间以保持空间 |
|
||||
| `H` | 追加模式空间以保持空间 |
|
||||
| `g` | 将保持空间复制到模式空间 |
|
||||
| `G` | 将保持空间附加到模式空间 |
|
||||
命令 | 描述
|
||||
:- | :-
|
||||
`n` | 打印模式空间,空模式空间,读取下一行
|
||||
`x` | 用保持空间交换模式空间
|
||||
`h` | 复制模式空间以保持空间
|
||||
`H` | 追加模式空间以保持空间
|
||||
`g` | 将保持空间复制到模式空间
|
||||
`G` | 将保持空间附加到模式空间
|
||||
|
||||
### Flags
|
||||
|
||||
@@ -109,7 +109,6 @@ $ sed 's/old/new/[flags]' [input-file]
|
||||
| `I` | 搜索时忽略大小写 |
|
||||
| `e` | 在命令行中替换并执行 |
|
||||
|
||||
|
||||
### 循环命令
|
||||
|
||||
| Command | Description |
|
||||
|
@@ -75,9 +75,9 @@ Semver 备忘清单
|
||||
| `1.2 - 2.3.0` | 是 `1.2.0 - 2.3.0` |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
当右侧为部分(例如,`2.3`)时,假定缺失的部分为`x`(例如,` 2.3.x`)。
|
||||
当右侧为部分(例如,`2.3`)时,假定缺失的部分为`x`(例如,`2.3.x`)。
|
||||
|
||||
如果左边是部分的(例如,`1.2`),则假定缺少的部分为`0`(例如,` 1.2.0`)。
|
||||
如果左边是部分的(例如,`1.2`),则假定缺少的部分为`0`(例如,`1.2.0`)。
|
||||
|
||||
### 有效的语义版本
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
@@ -142,7 +142,6 @@ Semver 备忘清单
|
||||
1.1.2-prerelease+meta
|
||||
```
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
@@ -22,7 +22,6 @@ Sketch 备忘清单
|
||||
| `t` | (Text) 文本 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 类型
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -131,7 +130,6 @@ Sketch 备忘清单
|
||||
| `Fn + ↓` | 选择下面的页面 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
|
@@ -99,7 +99,6 @@ $ scp user@server:/dir/* .
|
||||
`~/.ssh/known_hosts` | 登录主机
|
||||
`~/.ssh/authorized_keys` | 授权登录密钥
|
||||
|
||||
|
||||
### SCP 选项
|
||||
|
||||
选项 | 说明
|
||||
@@ -111,7 +110,6 @@ scp `-P` 8080 | 使用特定端口
|
||||
scp `-B` | 批处理模式_(防止密码)_
|
||||
scp `-p` | 保留时间和模式
|
||||
|
||||
|
||||
### 配置示例
|
||||
|
||||
```toml
|
||||
@@ -148,7 +146,6 @@ $ ssh -J user@proxy_host1:port1,user@proxy_host2:port2 user@remote_host3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
|
||||
### ssh-copy-id
|
||||
|
||||
```shell
|
||||
@@ -229,7 +226,6 @@ $ ssh-keygen -p -f ~/.ssh/id_rsa
|
||||
- dsa
|
||||
- ecdsa
|
||||
|
||||
|
||||
### known_hosts
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
@@ -3,7 +3,6 @@ styled-components 备忘清单
|
||||
|
||||
此快速参考备忘单提供了使用 CSS in JS 工具的各种方法。
|
||||
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
@@ -29,6 +28,7 @@ import styled from 'styled-components';
|
||||
```
|
||||
|
||||
创建一个 Title 组件
|
||||
|
||||
```jsx
|
||||
// 该组件将呈现具有样式的 <h1> 标签
|
||||
const Title = styled.h1`
|
||||
@@ -236,7 +236,6 @@ const Demo = () => (
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
### 样式对象
|
||||
|
||||
```jsx {2,5}
|
||||
|
@@ -84,6 +84,7 @@ h5 {
|
||||
}
|
||||
```
|
||||
|
||||
<!-- markdownlint-disable MD051 -->
|
||||
另见:下面[Mixins](#混合-Mixins)
|
||||
|
||||
### 变量 Variables
|
||||
@@ -388,6 +389,7 @@ for i in 1..3
|
||||
.text-{i}
|
||||
font-size: lookup('font-size-' + i)
|
||||
```
|
||||
|
||||
### 定义检查
|
||||
|
||||
```stylus {1}
|
||||
|
@@ -79,9 +79,9 @@ Sublime Text 备忘清单
|
||||
|
||||
快捷键 | 说明
|
||||
:- | -
|
||||
`⌘ P` | 去任何地方
|
||||
`⌘ G` | 转到行号
|
||||
`⌘ R` | 转到符号
|
||||
`⌘ P` | 去任何地方
|
||||
`⌘ G` | 转到行号
|
||||
`⌘ R` | 转到符号
|
||||
`⌘ P, :` | 转到行号(`:`之后输入数字)
|
||||
`⌘ P, #` | 转到并列出字符串模糊匹配(`#`之后输入字符)
|
||||
`⌘ P, @` | 转到并列出符号(`@`之后开始输入符号名称)
|
||||
|
@@ -34,11 +34,11 @@ var price: Double = 8.99
|
||||
### 算术运算符
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
- `+` 添加
|
||||
- `-` 减法
|
||||
- `*` 乘法
|
||||
- `/` 分配
|
||||
- `%` 余数
|
||||
- `+` 添加
|
||||
- `-` 减法
|
||||
- `*` 乘法
|
||||
- `/` 分配
|
||||
- `%` 余数
|
||||
<!--rehype:className=cols-5 style-none-->
|
||||
|
||||
----
|
||||
@@ -444,7 +444,7 @@ switch num {
|
||||
// 打印: 7 奇数
|
||||
```
|
||||
|
||||
### 逻辑运算符!
|
||||
### 逻辑运算符
|
||||
|
||||
```swift
|
||||
!true // false
|
||||
@@ -480,6 +480,7 @@ false || false // false
|
||||
```swift
|
||||
false || true && false // false
|
||||
```
|
||||
|
||||
`true && false` 首先计算返回 `false` 然后,表达式,`false` || `false` 评估并返回最终结果 `false`
|
||||
|
||||
### 控制执行顺序
|
||||
@@ -1431,9 +1432,9 @@ enum Dessert {
|
||||
let customerOrder: Dessert = .cake(flavor: "红色天鹅绒")
|
||||
switch customerOrder {
|
||||
case let .cake(flavor):
|
||||
print("你点了一个 \(flavor) 蛋糕")
|
||||
print("你点了一个 \(flavor) 蛋糕")
|
||||
case .brownie:
|
||||
print("你点了一块巧克力蛋糕")
|
||||
print("你点了一块巧克力蛋糕")
|
||||
}
|
||||
// 打印: "你点了一个红色天鹅绒蛋糕"
|
||||
```
|
||||
@@ -1521,7 +1522,7 @@ enum ShirtSize: String {
|
||||
case medium = "M"
|
||||
case large = "L"
|
||||
case extraLarge = "XL"
|
||||
var description: String {
|
||||
var description: String {
|
||||
return "这件衬衫尺码是 \(self.rawValue)"
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ struct AlbumDetail: View {
|
||||
- [Picker](#picker-选择控件) _(UISegmentedControl)_
|
||||
- [Stepper](#stepper-执行语义递增和递减操作的控件) _(UIStepper)_
|
||||
- [DatePicker](#datepicker-日期控件) _(UIDatePicker)_
|
||||
- [Text](#text-文本) _(NSAttributedString)无等效项)_
|
||||
- [Text](#text) _(NSAttributedString)无等效项)_
|
||||
- [Map](#map-地图界面的视图) _(MapKit)_
|
||||
- [ProgressView](#progressview-进度视图) _(UIProgressView)_
|
||||
- [Shape](#shape) / [Rectangle](#shape) / [Circle](#shape)
|
||||
@@ -230,7 +230,6 @@ Map(coordinateRegion: $region,
|
||||
|
||||
文档 - [Map](https://developer.apple.com/documentation/mapkit/map)
|
||||
|
||||
|
||||
Layout(布局)
|
||||
----
|
||||
|
||||
@@ -620,7 +619,6 @@ DatePicker("Maximum Date", selection: $selectedDate,
|
||||
|
||||
文档 - [DatePicker](https://developer.apple.com/documentation/swiftui/datepicker)
|
||||
|
||||
|
||||
### Slider 滑动输入条
|
||||
|
||||
用于从值的有界线性范围中选择一个值的控件。
|
||||
@@ -673,6 +671,7 @@ NavigationView {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
您可以使用 `.pickerStyle(WheelPickerStyle())` 覆盖样式。
|
||||
|
||||
```swift
|
||||
@@ -1200,7 +1199,6 @@ struct SheetDetail: Identifiable {
|
||||
|
||||
文档 - [ActionSheet](https://developer.apple.com/documentation/swiftui/actionsheet)
|
||||
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
110
docs/systemd.md
Normal file
@@ -0,0 +1,110 @@
|
||||
Systemd
|
||||
===
|
||||
|
||||
最常用的 [Systemd](https://systemd.io/) 命令备忘单快速参考
|
||||
|
||||
命令
|
||||
----
|
||||
|
||||
### 查看系统信息
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`systemctl list-dependencies` | 显示单元的依赖关系
|
||||
`systemctl list-sockets` | 列出套接字和激活的内容
|
||||
`systemctl list-jobs` | 查看活动的 systemd 作业
|
||||
`systemctl list-unit-files` | 查看单元文件及其状态
|
||||
`systemctl list-units` | 显示单位是否已加载/活动
|
||||
`systemctl get-default` | 列出默认目标(如运行级别)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### 改变系统状态
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`systemctl reboot` | 重启系统(reboot.target)
|
||||
`systemctl poweroff` | 关闭系统(poweroff.target)
|
||||
`systemctl emergency` | 进入紧急模式(emergency.target)
|
||||
`systemctl default` | 返回默认目标(multi-user.target)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### 使用服务
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`systemctl stop service` | <red>停止</red>正在运行的服务
|
||||
`systemctl start service` | 启动服务
|
||||
`systemctl restart service` | 重新启动正在运行的服务
|
||||
`systemctl reload service` | 重新加载服务中的所有配置文件
|
||||
`systemctl daemon-reload` | 必须运行以重新加载更改的单元文件
|
||||
`systemctl status` | service 查看服务是否正在运行/启用
|
||||
`systemctl --failed` | 显示未能运行的服务
|
||||
`systemctl reset-failed` | 将任何单位从失败状态重置
|
||||
`systemctl enable service` | 使服务在启动时启动
|
||||
`systemctl disable service` | 禁用服务 - 不会在启动时启动
|
||||
`systemctl show service` | 显示服务(或其他单元)的属性
|
||||
`systemctl edit service` | 创建片段以放入单元文件
|
||||
`systemctl edit --full service` | 编辑整个单元文件以进行服务
|
||||
`systemctl -H host status network` | 远程运行任何 systemctl 命令
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### 查看日志消息
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`journalctl` | 显示所有收集的日志消息
|
||||
`journalctl -u network.service` | 查看网络服务消息
|
||||
`journalctl -f` | 关注出现的消息
|
||||
`journalctl -k` | 仅显示内核消息
|
||||
|
||||
### SysVinit 到 Systemd
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
SysVinit | Systemd | 说明
|
||||
:- | - | -
|
||||
`service SERVICE_NAME start` | `systemctl start SERVICE_NAME` | 用于启动服务(不重启持久)
|
||||
`service SERVICE_NAME stop` | `systemctl stop SERVICE_NAME` | 用于停止服务(不永久重启)
|
||||
`service SERVICE_NAME restart` | `systemctl restart SERVICE_NAME` | 用于停止然后启动服务
|
||||
`service SERVICE_NAME reload` | `systemctl reload SERVICE_NAME` | 重新加载配置文件而不中断挂起的操作
|
||||
`service SERVICE_NAME condrestart` | `systemctl condrestart SERVICE_NAME` | 如果服务已在运行,则重新启动
|
||||
`service SERVICE_NAME status` | `systemctl status SERVICE_NAME` | 判断服务当前是否正在运行
|
||||
`chkconfig SERVICE_NAME on` | `systemctl enable SERVICE_NAME` | 打开服务,以便在下次启动时启动,或其他触发器
|
||||
`chkconfig SERVICE_NAME off` | `systemctl disable SERVICE_NAME` | 为下次重新启动或任何其他触发器关闭服务
|
||||
`chkconfig SERVICE_NAME` | `systemctl is-enabled SERVICE_NAME` | 用于检查服务是否配置为在当前环境中启动
|
||||
`chkconfig –list` | `systemctl list-unit-files –type=service` (or) <br/>`ls /etc/systemd/system/*.wants/` | 打印一个服务表,列出每个配置的运行级别打开或关闭
|
||||
`chkconfig –list \| grep 5:on` | `systemctl list-dependencies graphical.target` | 打印启动到图形模式时将启动的服务表
|
||||
`chkconfig SERVICE_NAME –list` | `ls /etc/systemd/system/*.wants/SERVICE_NAME.service` | 用于列出此服务配置为打开或关闭的级别
|
||||
`chkconfig SERVICE_NAME –add` | `systemctl daemon-reload` | 在创建新服务文件或修改任何配置时使用
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 目标运行级别
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
SysVinit | Systemd | 说明
|
||||
:- | - | -
|
||||
`0` | `runlevel0.target`, `poweroff.target` | 停止系统
|
||||
`1`, `s`, `single` | `runlevel1.target`, `rescue.target` | 单用户模式
|
||||
`2`, `4` | `runlevel2.target`, `runlevel4.target`, `multi-user.target` | 用户定义/站点特定的运行级别。 默认情况下,与 3 相同
|
||||
`3` | `runlevel3.target`, `multi-user.target` | 多用户,非图形。 用户通常可以通过多个控制台或通过网络登录
|
||||
`5` | `runlevel5.target`, `graphical.target` | 多用户,图形。 通常具有运行级别 3 的所有服务以及图形登录
|
||||
`6` | `runlevel6.target`, `reboot.target` | 重启
|
||||
`emergency` | `emergency.target` | 应急外壳
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 更改运行级别
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
SysVinit | Systemd | 说明
|
||||
:- | - | -
|
||||
`telinit 3` | `systemctl isolate multi-user.target` <br/>OR `systemctl isolate runlevel3.target`<br/>OR `telinit 3` | 更改为多用户运行级别
|
||||
`sed s/^id:.*:initdefault:/id:3:initdefault:/` | `ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target` | 设置为在下次重新启动时使用多用户运行级别
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Systemd 官网](https://systemd.io/) _(systemd.io)_
|
||||
- [Systemd Cheat Sheet](https://access.redhat.com/sites/default/files/attachments/12052018_systemd_6.pdf) _(access.redhat.com)_
|
||||
- [Systemd Cheat Sheet](https://www.linuxtrainingacademy.com/systemd-cheat-sheet/) _(linuxtrainingacademy.com)_
|
243
docs/tmux.md
Normal file
@@ -0,0 +1,243 @@
|
||||
Tmux 备忘清单
|
||||
===
|
||||
|
||||
最常用的快捷键和命令的 tmux 备忘单快速参考
|
||||
|
||||
Tmux CLI
|
||||
-------
|
||||
|
||||
### 新会话
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
开始一个新的会话
|
||||
|
||||
```bash
|
||||
$ tmux
|
||||
$ tmux new
|
||||
$ tmux new-session
|
||||
|
||||
:new
|
||||
```
|
||||
|
||||
开始一个名为 myname 的新会话
|
||||
|
||||
```bash
|
||||
$ tmux new -s myname
|
||||
|
||||
:new -s myname
|
||||
```
|
||||
|
||||
显示所有会话,或者 <kbd>Ctrl</kbd> + <kbd>b</kbd> + <kbd>s</kbd> 快捷键
|
||||
|
||||
```bash
|
||||
$ tmux ls
|
||||
$ tmux list-sessions
|
||||
```
|
||||
|
||||
### 附加会话
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
附加到上一个会话
|
||||
|
||||
```bash
|
||||
$ tmux a
|
||||
$ tmux at
|
||||
$ tmux attach
|
||||
$ tmux attach-session
|
||||
```
|
||||
|
||||
附加到命名
|
||||
|
||||
```bash
|
||||
$ tmux a -t myname
|
||||
```
|
||||
|
||||
附加到名为 myname 的会话
|
||||
|
||||
```bash
|
||||
$ tmux a -t myname
|
||||
$ tmux at -t myname
|
||||
$ tmux attach -t myname
|
||||
$ tmux attach-session -t myname
|
||||
```
|
||||
|
||||
### 终止会话
|
||||
|
||||
按名称终止会话
|
||||
|
||||
```bash
|
||||
$ tmux kill-ses -t myname # 杀死/删除会话
|
||||
$ tmux kill-session -t myname
|
||||
```
|
||||
|
||||
杀死/删除除当前会话之外的所有会话
|
||||
|
||||
```bash
|
||||
$ tmux kill-ses -a
|
||||
```
|
||||
|
||||
杀死/删除除 myname 之外的所有会话
|
||||
|
||||
```bash
|
||||
$ tmux kill-ses -a -t myname
|
||||
```
|
||||
|
||||
### Tmux 帮助
|
||||
|
||||
```bash
|
||||
$ tmux info
|
||||
```
|
||||
|
||||
### 配置
|
||||
|
||||
重新加载配置
|
||||
|
||||
```bash
|
||||
$ tmux source-file ~/.tmux.conf
|
||||
```
|
||||
|
||||
显示配置
|
||||
|
||||
```bash
|
||||
$ tmux show-options -g
|
||||
```
|
||||
|
||||
### 复制模式
|
||||
|
||||
命令 | 描述
|
||||
:- | -
|
||||
`Ctrl+b` `[` | 进入复制模式
|
||||
`<Space>` | 开始选择
|
||||
`Enter` | 复制选择
|
||||
`q` | 退出复制模式
|
||||
`Ctrl+b` `]` | 粘贴 buffer_0 的内容
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
主要作用类似于在 [Vim](./vim.md#动作) 中选择文本
|
||||
|
||||
Tmux 快捷键
|
||||
----------
|
||||
|
||||
### 入门
|
||||
<!--rehype:style=background:rgb(245 158 11/1);-->
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
| `Ctrl+b` `?` | List all shortcuts |
|
||||
<!--rehype:className=shortcuts show-header-->
|
||||
|
||||
----
|
||||
|
||||
显示每个会话、窗口、窗格等
|
||||
|
||||
```bash
|
||||
$ tmux info
|
||||
```
|
||||
|
||||
### 窗格(拆分)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`Ctrl+b` `"` _/_ `%` | 水平分割/垂直
|
||||
`Ctrl+b` `!` | 窗格 -> 窗口
|
||||
`Ctrl+b` `x` | 杀死窗格
|
||||
`Ctrl+b` \<Arrow> | 导航窗格
|
||||
`Ctrl+b` \<Space> | 切换布局
|
||||
`Ctrl+b` `{` _/_ `}` | 向左/向右移动
|
||||
`Ctrl+b` `o` | 转到下一个窗格
|
||||
`Ctrl+b` `z` | 切换全屏
|
||||
`Ctrl+b` `;` | 切换最后一个窗格
|
||||
`Ctrl+b` `q` | 显示号码
|
||||
`Ctrl+b` `q` `0`...`9` | 转到 # 窗格
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Window (Tabs)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`Ctrl+b` `c` | 创建窗口
|
||||
`Ctrl+b` `p` _/_ `n` | 上一个/下一个窗口
|
||||
`Ctrl+b` `"` _/_ `%` | 水平分割/垂直
|
||||
`Ctrl+b` `w` | 列表窗口
|
||||
`Ctrl+b` `,` | 重命名窗口
|
||||
`Ctrl+b` `f` | 查找窗口
|
||||
`Ctrl+b` `l` | 最后一个窗口
|
||||
`Ctrl+b` `.` | 移动窗口
|
||||
`Ctrl+b` `&` | 关闭窗口
|
||||
`Ctrl+b` `0`...`9` | 转到#窗口
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 会话(Windows 组)
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`Ctrl+b` `d` | <red>从会话中分离</red>
|
||||
`Ctrl+b` `s` | 显示所有会话
|
||||
`Ctrl+b` `$` | 重命名会话
|
||||
`Ctrl+b` `(` _/_ `)` | 上一届/下一届
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
Tmux 命令模式
|
||||
-----------
|
||||
|
||||
### 用法
|
||||
<!--rehype:style=background:rgb(245 158 11/1);-->
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`Ctrl+b` `:` | 进入命令模式
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调整大小
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`resize-pane -D 20` | 缩小尺寸
|
||||
`resize-pane -U 20` | 调整大小
|
||||
`resize-pane -L 20` | 向左调整大小
|
||||
`resize-pane -R 20` | 向右调整大小
|
||||
|
||||
### 清单
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`list-keys` | 所有命令
|
||||
`list-panes` | 所有窗格
|
||||
`list-windows` | 所有窗口
|
||||
|
||||
### 复印
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`list-buffers` | 列出所有缓冲区
|
||||
`show-buffer` | 显示 #0 内容
|
||||
`capture-pane` | 窗格的副本
|
||||
`choose-buffer` | 显示和粘贴
|
||||
`save-buffer a.txt` | 保存到文件
|
||||
`delete-buffer -b 1` | 删除缓冲区 1
|
||||
|
||||
### 环境
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`set -g OPTION` | 为所有会话设置
|
||||
`setw -g OPTION` | 为所有窗口设置
|
||||
`setw -g mode-keys vi` | 启用 vi 模式
|
||||
`set -g prefix C-a` | 设置前缀
|
||||
|
||||
### 杂项
|
||||
|
||||
快捷键/命令 | 描述
|
||||
:- | -
|
||||
`swap-pane -s 3 -t 1` | 交换窗格
|
||||
`swap-window -t -1` | 向左移动
|
||||
`setw synchronize-panes` | 同步窗格
|
||||
`join-pane -t :#` | 加入窗格
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Tmux 开源仓库](https://github.com/tmux/tmux) _(github.com)_
|
||||
- [Tmux Cheat Sheet & Quick Reference](https://tmuxcheatsheet.com/) _(tmuxcheatsheet.com)_
|
45
docs/toml.md
@@ -44,7 +44,6 @@ int3 = -21
|
||||
integerRange = 64
|
||||
```
|
||||
|
||||
|
||||
### 浮点数
|
||||
|
||||
```toml
|
||||
@@ -80,7 +79,7 @@ str2 = "You can \"quote\" me."
|
||||
str3 = "Name\tJos\u00E9\nLoc\tSF."
|
||||
```
|
||||
|
||||
See: [Strings](#toml-strings)
|
||||
See: [Strings](#字符串)
|
||||
|
||||
### Table
|
||||
|
||||
@@ -165,9 +164,9 @@ bar = 2
|
||||
|
||||
```toml
|
||||
[table1]
|
||||
foo = "bar"
|
||||
foo = "bar"
|
||||
[table1.nested_table]
|
||||
baz = "bat"
|
||||
baz = "bat"
|
||||
```
|
||||
|
||||
### 类数组
|
||||
@@ -186,16 +185,16 @@ text = "Love it!"
|
||||
|
||||
```json
|
||||
{
|
||||
"comments" : [
|
||||
{
|
||||
"author" : "Nate",
|
||||
"text" : "Great Article!"
|
||||
},
|
||||
{
|
||||
"author" : "Anonymous",
|
||||
"text" : "Love It!"
|
||||
}
|
||||
]
|
||||
"comments" : [
|
||||
{
|
||||
"author" : "Nate",
|
||||
"text" : "Great Article!"
|
||||
},
|
||||
{
|
||||
"author" : "Anonymous",
|
||||
"text" : "Love It!"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -224,17 +223,18 @@ type = "pug"
|
||||
[foo.bar.baz]
|
||||
bat = "hi"
|
||||
```
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json
|
||||
{
|
||||
"foo" : {
|
||||
"bar" : {
|
||||
"baz" : {
|
||||
"bat" : "hi"
|
||||
}
|
||||
}
|
||||
}
|
||||
"foo" : {
|
||||
"bar" : {
|
||||
"baz" : {
|
||||
"bat" : "hi"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -247,7 +247,7 @@ bat = "hi"
|
||||
[ j . "ʞ" .'l' ] # same as [j."ʞ".'l']
|
||||
```
|
||||
|
||||
### Inline Table
|
||||
### 内联表
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```toml
|
||||
@@ -263,6 +263,5 @@ animal = { type.name = "pug" }
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/toml/) _(learnxinyminutes.com)_
|
||||
- [Better TOML VSCode 插件](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) _(visualstudio.com)_
|
||||
|
||||
|
||||
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
|
||||
- [YAML 格式配置文件备忘清单](./yaml.md) _(jaywcjlove.github.io)_
|
@@ -240,7 +240,6 @@ type Data = typeof data
|
||||
|
||||
通过 typeof 运算符重用来自现有 JavaScript 运行时值的类型。
|
||||
|
||||
|
||||
### 从函数返回类型
|
||||
|
||||
```ts
|
||||
@@ -1077,11 +1076,9 @@ console.log(fiveToHex());
|
||||
|
||||
从 Type 中移除 this 参数。 如果 Type 没有显式声明此参数,则结果只是 Type。 否则,从 Type 创建一个不带此参数的新函数类型。 泛型被删除,只有最后一个重载签名被传播到新的函数类型中。
|
||||
|
||||
|
||||
JSX
|
||||
----
|
||||
|
||||
|
||||
### JSX 介绍
|
||||
|
||||
JSX 规范是对 ECMAScript 的类似 XML 的语法扩展。
|
||||
@@ -1233,7 +1230,6 @@ function NotAValidFactoryFunction() {
|
||||
|
||||
默认情况下,`JSX.ElementClass` 是 {},但可以对其进行扩展,以将 `JSX` 的使用限制为仅限于符合适当接口的类型。
|
||||
|
||||
|
||||
### 类组件
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
@@ -276,7 +276,6 @@ Vim 文本对象
|
||||
### 用法
|
||||
<!--rehype:style=background:#d7a100;-->
|
||||
|
||||
|
||||
快捷方式 | 说明
|
||||
:- | -
|
||||
`v` | <pur>i</pur> _/_ <pur>a</pur> | <yel>p</yel>
|
||||
@@ -435,6 +434,7 @@ Vim 搜索和替换
|
||||
```vim
|
||||
:%s/{pattern}/{str}/[flags]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
@@ -460,7 +460,7 @@ Vim 搜索和替换
|
||||
`,3` | 接下来的 `3` 行
|
||||
`-3,` | 转发 `3` 行
|
||||
|
||||
### 全局命令
|
||||
### 全局命令
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```vim
|
||||
@@ -516,7 +516,6 @@ Vim 搜索和替换
|
||||
### 例子
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
||||
```shell
|
||||
:s/a\|b/xxx\0xxx/g # 将 "a b" 修改为 "xxxaxxx xxxbxxx"
|
||||
:s/test/\U& file/ # 将 "test" 修改为 "TEST FILE"
|
||||
|
@@ -61,11 +61,10 @@ VSCode 备忘清单
|
||||
| `F8` | 转到下一个错误 |
|
||||
| `Shift` `F8` | 转到上一个错误 |
|
||||
| `Ctrl` `Shift` `Tab` | 浏览编辑组历史 |
|
||||
| `Alt` ` ←` _/_ `→` | 后退/前进 |
|
||||
| `Alt` `←` _/_ `→` | 后退/前进 |
|
||||
| `Ctrl` `M` | 切换 Tab 移动焦点 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 搜索和替换
|
||||
|
||||
| - | - |
|
||||
@@ -115,7 +114,6 @@ VSCode 备忘清单
|
||||
| `Ctrl` `K` `M` | 更改文件语言 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 编辑管理
|
||||
|
||||
| - | - |
|
||||
@@ -123,7 +121,7 @@ VSCode 备忘清单
|
||||
| `Ctrl` `F4` `Ctrl` `W` | 关闭编辑器 |
|
||||
| `Ctrl` `K` `F` | 关闭文件夹 |
|
||||
| `Ctrl` `\` | 拆分编辑器 |
|
||||
| `Ctrl` ` 1` _/_ `2` _/_ `3` | 专注于第一、第二或第三编辑组 |
|
||||
| `Ctrl` `1` _/_ `2` _/_ `3` | 专注于第一、第二或第三编辑组 |
|
||||
| `Ctrl` `K` `Ctrl` `←` _/_ `→` | 专注于上一个/下一个编辑组 |
|
||||
| `Ctrl` `Shift` `PgUp` _/_ `PgDn` | 向左/向右移动编辑器 |
|
||||
| `Ctrl` `K` `←` _/_ `→` | 移动活动编辑器组 |
|
||||
@@ -170,7 +168,6 @@ VSCode 备忘清单
|
||||
| `Ctrl` `K` `Z` | Zen 模式(Esc Esc 退出) |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 调试
|
||||
|
||||
| - | - |
|
||||
|
379
docs/vue.md
@@ -3,7 +3,6 @@ Vue 3 备忘清单
|
||||
|
||||
渐进式 JavaScript 框架 [Vue 3](https://cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
@@ -11,8 +10,9 @@ Vue 3 备忘清单
|
||||
|
||||
Vue 是一套用于构建用户界面的渐进式框架
|
||||
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/) _(cn.vuejs.org)_
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/) _(router.vuejs.org)_
|
||||
- [Vue 2 备忘清单](./vue2.md)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 3.x 版本对应 Vue Router 4.x 路由版本
|
||||
@@ -208,7 +208,6 @@ data() {
|
||||
</span>
|
||||
```
|
||||
|
||||
|
||||
### 指令 Directives
|
||||
|
||||
```html
|
||||
@@ -269,3 +268,375 @@ v-on:submit.prevent="onSubmit"
|
||||
┆ ╰─ Argument 跟随冒号或速记符号
|
||||
╰─ Name 以 v- 开头使用速记时可以省略
|
||||
```
|
||||
|
||||
响应式基础
|
||||
---
|
||||
|
||||
### 声明状态
|
||||
|
||||
```html
|
||||
<div>{{ count }}</div>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```js {2,4}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### 声明方法
|
||||
|
||||
```html
|
||||
<button @click="increment">
|
||||
{{ count }}
|
||||
</button>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```js {8-10}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
increment() {
|
||||
this.count++
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 有状态方法
|
||||
|
||||
```js
|
||||
import { debounce } from 'lodash-es'
|
||||
export default {
|
||||
created() {
|
||||
// 每个实例都有了自己的预置防抖的处理函数
|
||||
this.debouncedClick = debounce(this.click, 500)
|
||||
},
|
||||
unmounted() {
|
||||
// 最好是在组件卸载时
|
||||
// 清除掉防抖计时器
|
||||
this.debouncedClick.cancel()
|
||||
},
|
||||
methods: {
|
||||
click() {
|
||||
// ... 对点击的响应 ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
API 参考
|
||||
---
|
||||
|
||||
### 全局 API - 应用实例
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`createApp()` | [#](https://cn.vuejs.org/api/application.html#create-app)
|
||||
`createSSRApp()` | [#](https://cn.vuejs.org/api/application.html#create-ssr-app)
|
||||
`app.mount()` | [#](https://cn.vuejs.org/api/application.html#app-mount)
|
||||
`app.unmount()` | [#](https://cn.vuejs.org/api/application.html#app-unmount)
|
||||
`app.provide()` | [#](https://cn.vuejs.org/api/application.html#app-provide)
|
||||
`app.component()` | [#](https://cn.vuejs.org/api/application.html#app-component)
|
||||
`app.directive()` | [#](https://cn.vuejs.org/api/application.html#app-directive)
|
||||
`app.use()` | [#](https://cn.vuejs.org/api/application.html#app-use)
|
||||
`app.mixin()` | [#](https://cn.vuejs.org/api/application.html#app-mixin)
|
||||
`app.version` | [#](https://cn.vuejs.org/api/application.html#app-version)
|
||||
`app.config` | [#](https://cn.vuejs.org/api/application.html#app-config)
|
||||
`app.config.errorHandler` | [#](https://cn.vuejs.org/api/application.html#app-config-errorhandler)
|
||||
`app.config.warnHandler` | [#](https://cn.vuejs.org/api/application.html#app-config-warnhandler)
|
||||
`app.config.performance` | [#](https://cn.vuejs.org/api/application.html#app-config-performance)
|
||||
`app.config.compilerOptions` | [#](https://cn.vuejs.org/api/application.html#app-config-compileroptions)
|
||||
`app.config.globalProperties` | [#](https://cn.vuejs.org/api/application.html#app-config-globalproperties)
|
||||
`app.config.optionMergeStrategies` | [#](https://cn.vuejs.org/api/application.html#app-config-optionmergestrategies)
|
||||
|
||||
### 全局 API - 通用
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`version` | [#](https://cn.vuejs.org/api/general.html#version)
|
||||
`nextTick()` | [#](https://cn.vuejs.org/api/general.html#nexttick)
|
||||
`defineComponent()` | [#](https://cn.vuejs.org/api/general.html#definecomponent)
|
||||
`defineAsyncComponent()` | [#](https://cn.vuejs.org/api/general.html#defineasynccomponent)
|
||||
`defineCustomElement()` | [#](https://cn.vuejs.org/api/general.html#definecustomelement)
|
||||
|
||||
### 组合式 API - setup()
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`基本使用` | [#](https://cn.vuejs.org/api/composition-api-setup.html#basic-usage)
|
||||
`访问 Props` | [#](https://cn.vuejs.org/api/composition-api-setup.html#accessing-props)
|
||||
`Setup 上下文` | [#](https://cn.vuejs.org/api/composition-api-setup.html#setup-context)
|
||||
`与渲染函数一起使用` | [#](https://cn.vuejs.org/api/composition-api-setup.html#usage-with-render-functions)
|
||||
|
||||
### 组合式 API - 响应式: 工具
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`isRef()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isref)
|
||||
`unref()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#unref)
|
||||
`toRef()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#toref)
|
||||
`toRefs()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#torefs)
|
||||
`isProxy()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isproxy)
|
||||
`isReactive()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isreactive)
|
||||
`isReadonly()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isreadonly)
|
||||
|
||||
### 组合式 API - 生命周期钩子
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`onMounted()` | 组件挂载完成后执行 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onmounted)
|
||||
`onUpdated()` | 状态变更而更新其 DOM 树之后调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onupdated)
|
||||
`onUnmounted()` | 组件实例被卸载之后调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onunmounted)
|
||||
`onBeforeMount()` | 组件被挂载之前被调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforemount)
|
||||
`onBeforeUpdate()` | 状态变更而更新其 DOM 树之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforeupdate)
|
||||
`onBeforeUnmount()` | 组件实例被卸载之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforeunmount)
|
||||
`onErrorCaptured()` | 捕获了后代组件传递的错误时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured)
|
||||
`onRenderTracked()` | 组件渲染过程中追踪到响应式依赖时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onrendertracked)
|
||||
`onRenderTriggered()` | 响应式依赖的变更触发了组件渲染时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onrendertriggered)
|
||||
`onActivated()` | 若组件实例是 \<KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onactivated)
|
||||
`onDeactivated()` | 若组件实例是 \<KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#ondeactivated)
|
||||
`onServerPrefetch()` | 组件实例在服务器上被渲染之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onserverprefetch)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### 组合式 API - 依赖注入
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`provide()` | [#](https://cn.vuejs.org/api/composition-api-dependency-injection.html#provide)
|
||||
`inject()` | [#](https://cn.vuejs.org/api/composition-api-dependency-injection.html#inject)
|
||||
|
||||
### 组合式 API - 响应式: 核心
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`ref()` | [#](https://cn.vuejs.org/api/reactivity-core.html#ref)
|
||||
`computed ()` | [#](https://cn.vuejs.org/api/reactivity-core.html#computed)
|
||||
`reactive()` | [#](https://cn.vuejs.org/api/reactivity-core.html#reactive)
|
||||
`readonly()` | [#](https://cn.vuejs.org/api/reactivity-core.html#readonly)
|
||||
`watchEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watcheffect)
|
||||
`watchPostEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watchposteffect)
|
||||
`watchSyncEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watchsynceffect)
|
||||
`watch()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watch)
|
||||
|
||||
### 选项式 API - 状态选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`data` | [#](https://cn.vuejs.org/api/options-state.html#data)
|
||||
`props` | [#](https://cn.vuejs.org/api/options-state.html#props)
|
||||
`computed` | [#](https://cn.vuejs.org/api/options-state.html#computed)
|
||||
`methods` | [#](https://cn.vuejs.org/api/options-state.html#methods)
|
||||
`watch` | [#](https://cn.vuejs.org/api/options-state.html#watch)
|
||||
`emits` | [#](https://cn.vuejs.org/api/options-state.html#emits)
|
||||
`expose` | [#](https://cn.vuejs.org/api/options-state.html#expose)
|
||||
|
||||
### 选项式 API - 生命周期选项
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`beforeCreate` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforecreate)
|
||||
`created` | [#](https://cn.vuejs.org/api/options-lifecycle.html#created)
|
||||
`beforeMount` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforemount)
|
||||
`mounted` | [#](https://cn.vuejs.org/api/options-lifecycle.html#mounted)
|
||||
`beforeUpdate` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforeupdate)
|
||||
`updated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#updated)
|
||||
`beforeUnmount` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforeunmount)
|
||||
`unmounted` | [#](https://cn.vuejs.org/api/options-lifecycle.html#unmounted)
|
||||
`errorCaptured` | [#](https://cn.vuejs.org/api/options-lifecycle.html#errorcaptured)
|
||||
`renderTracked` | [#](https://cn.vuejs.org/api/options-lifecycle.html#rendertracked)
|
||||
`renderTriggered` | [#](https://cn.vuejs.org/api/options-lifecycle.html#rendertriggered-sup-classvt-badge-dev-only)
|
||||
`activated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#activated)
|
||||
`deactivated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#deactivated)
|
||||
`serverPrefetch` | [#](https://cn.vuejs.org/api/options-lifecycle.html#serverprefetch)
|
||||
|
||||
### 选项式 API - 其他杂项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`name` | 显式声明组件展示时的名称 [#](https://cn.vuejs.org/api/options-misc.html#name)
|
||||
`inheritAttrs` | 默认的组件 `attribute` 透传行为 [#](https://cn.vuejs.org/api/options-misc.html#inheritattrs)
|
||||
`components` | [#](https://cn.vuejs.org/api/options-misc.html#components)
|
||||
`directives` | [#](https://cn.vuejs.org/api/options-misc.html#directives)
|
||||
|
||||
### 选项式 API - 渲染选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`template` | [#](https://cn.vuejs.org/api/options-rendering.html#template)
|
||||
`render` | [#](https://cn.vuejs.org/api/options-rendering.html#render)
|
||||
`compilerOptions` | [#](https://cn.vuejs.org/api/options-rendering.html#compileroptions)
|
||||
|
||||
### 选项式 API - 组件实例
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`$data` | [#](https://cn.vuejs.org/api/component-instance.html#data)
|
||||
`$props` | [#](https://cn.vuejs.org/api/component-instance.html#props)
|
||||
`$el` | [#](https://cn.vuejs.org/api/component-instance.html#el)
|
||||
`$options` | [#](https://cn.vuejs.org/api/component-instance.html#options)
|
||||
`$parent` | [#](https://cn.vuejs.org/api/component-instance.html#parent)
|
||||
`$root` | [#](https://cn.vuejs.org/api/component-instance.html#root)
|
||||
`$slots` | [#](https://cn.vuejs.org/api/component-instance.html#slots)
|
||||
`$refs` | [#](https://cn.vuejs.org/api/component-instance.html#refs)
|
||||
`$attrs` | [#](https://cn.vuejs.org/api/component-instance.html#attrs)
|
||||
`$watch()` | [#](https://cn.vuejs.org/api/component-instance.html#watch)
|
||||
`$emit()` | [#](https://cn.vuejs.org/api/component-instance.html#emit)
|
||||
`$forceUpdate()` | [#](https://cn.vuejs.org/api/component-instance.html#forceupdate)
|
||||
`$nextTick()` | [#](https://cn.vuejs.org/api/component-instance.html#nexttick)
|
||||
|
||||
### 选项式 API - 组合选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`provide` | [#](https://cn.vuejs.org/api/options-composition.html#provide)
|
||||
`inject` | [#](https://cn.vuejs.org/api/options-composition.html#inject)
|
||||
`mixins` | [#](https://cn.vuejs.org/api/options-composition.html#mixins)
|
||||
`extends` | [#](https://cn.vuejs.org/api/options-composition.html#extends)
|
||||
|
||||
### 内置内容 - 指令
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`v-text` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-text)
|
||||
`v-html` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-html)
|
||||
`v-show` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-show)
|
||||
`v-if` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-if)
|
||||
`v-else` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-else)
|
||||
`v-else-if` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-else-if)
|
||||
`v-for` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-for)
|
||||
`v-on` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-on)
|
||||
`v-bind` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-bind)
|
||||
`v-model` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-model)
|
||||
`v-slot` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-slot)
|
||||
`v-pre` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-pre)
|
||||
`v-once` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-once)
|
||||
`v-memo` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-memo)
|
||||
`v-cloak` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-cloak)
|
||||
|
||||
### 内置内容 - 组件
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`<Transition>` | [#](https://cn.vuejs.org/api/built-in-components.html#transition)
|
||||
`<TransitionGroup>` | [#](https://cn.vuejs.org/api/built-in-components.html#transitiongroup)
|
||||
`<KeepAlive>` | [#](https://cn.vuejs.org/api/built-in-components.html#keepalive)
|
||||
`<Teleport>` | [#](https://cn.vuejs.org/api/built-in-components.html#teleport)
|
||||
`<Suspense>` | [#](https://cn.vuejs.org/api/built-in-components.html#suspense)
|
||||
|
||||
### 内置内容 - 特殊 Attributes
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`key` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#key)
|
||||
`ref` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#ref)
|
||||
`is` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#is)
|
||||
|
||||
### 内置内容 - 特殊元素
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`<component>` | [#](https://cn.vuejs.org/api/built-in-special-elements.html#component)
|
||||
`<slot>` | [#](https://cn.vuejs.org/api/built-in-special-elements.html#slot)
|
||||
|
||||
### 单文件组件 - 语法定义
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`总览` | [#](https://cn.vuejs.org/api/sfc-spec.html#overview)
|
||||
`相应语言块` | [#](https://cn.vuejs.org/api/sfc-spec.html#language-blocks)
|
||||
`自动名称推导` | [#](https://cn.vuejs.org/api/sfc-spec.html#automatic-name-inference)
|
||||
`预处理器` | [#](https://cn.vuejs.org/api/sfc-spec.html#pre-processors)
|
||||
`Src 导入` | [#](https://cn.vuejs.org/api/sfc-spec.html#src-imports)
|
||||
`注释` | [#](https://cn.vuejs.org/api/sfc-spec.html#comments)
|
||||
|
||||
### 单文件组件 - \<script setup>
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`基本语法` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#basic-syntax)
|
||||
`响应式` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#reactivity)
|
||||
`使用组件` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#using-components)
|
||||
`使用自定义指令` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#using-custom-directives)
|
||||
`defineProps() 和 defineEmits()` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#defineprops-defineemits)
|
||||
`defineExpose` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#defineexpose)
|
||||
`useSlots() 和 useAttrs()` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#useslots-useattrs)
|
||||
`与普通的 <script> 一起使用` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#usage-alongside-normal-script)
|
||||
`顶层 await` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#top-level-await)
|
||||
`针对 TypeScript 的功能` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#typescript-only-features)
|
||||
`限制` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#restrictions)
|
||||
|
||||
### 单文件组件 - CSS 功能
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`组件作用域 CSS` | [#](https://cn.vuejs.org/api/sfc-css-features.html#scoped-css)
|
||||
`CSS Modules` | [#](https://cn.vuejs.org/api/sfc-css-features.html#css-modules)
|
||||
`CSS 中的 v-bind()` | [#](https://cn.vuejs.org/api/sfc-css-features.html#v-bind-in-css)
|
||||
|
||||
### 进阶 API - 渲染函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`h()` | [#](https://cn.vuejs.org/api/render-function.html#h)
|
||||
`mergeProps()` | [#](https://cn.vuejs.org/api/render-function.html#mergeprops)
|
||||
`cloneVNode()` | [#](https://cn.vuejs.org/api/render-function.html#clonevnode)
|
||||
`isVNode()` | [#](https://cn.vuejs.org/api/render-function.html#isvnode)
|
||||
`resolveComponent()` | [#](https://cn.vuejs.org/api/render-function.html#resolvecomponent)
|
||||
`resolveDirective()` | [#](https://cn.vuejs.org/api/render-function.html#resolvedirective)
|
||||
`withDirectives()` | [#](https://cn.vuejs.org/api/render-function.html#withdirectives)
|
||||
`withModifiers()` | [#](https://cn.vuejs.org/api/render-function.html#withmodifiers)
|
||||
|
||||
### 进阶 API - 服务端渲染
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`renderToString()` | [#](https://cn.vuejs.org/api/ssr.html#rendertostring)
|
||||
`renderToNodeStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertonodestream)
|
||||
`pipeToNodeWritable()` | [#](https://cn.vuejs.org/api/ssr.html#pipetonodewritable)
|
||||
`renderToWebStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertowebstream)
|
||||
`pipeToWebWritable()` | [#](https://cn.vuejs.org/api/ssr.html#pipetowebwritable)
|
||||
`renderToSimpleStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertosimplestream)
|
||||
`useSSRContext()` | [#](https://cn.vuejs.org/api/ssr.html#usessrcontext)
|
||||
|
||||
### 进阶 API - TypeScript 工具类型
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`PropType<T>` | [#](https://cn.vuejs.org/api/utility-types.html#proptypet)
|
||||
`ComponentCustomProperties` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomproperties)
|
||||
`ComponentCustomOptions` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomoptions)
|
||||
`ComponentCustomProps` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomprops)
|
||||
`CSSProperties` | [#](https://cn.vuejs.org/api/utility-types.html#cssproperties)
|
||||
|
||||
### 进阶 API - 自定义渲染
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`createRenderer()` | [#](https://cn.vuejs.org/api/custom-renderer.html#create-renderer)
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
|
||||
|
16
docs/vue2.md
@@ -1,4 +1,4 @@
|
||||
Vue2 备忘清单
|
||||
Vue 2 备忘清单
|
||||
===
|
||||
|
||||
渐进式 JavaScript 框架 [Vue 2](https://v2.cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
@@ -10,8 +10,9 @@ Vue2 备忘清单
|
||||
|
||||
Vue 是一套用于构建用户界面的渐进式框架
|
||||
|
||||
- [Vue 2.x 官方文档](https://v2.cn.vuejs.org/)
|
||||
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/)
|
||||
- [Vue 2.x 官方文档](https://v2.cn.vuejs.org/) _(v2.cn.vuejs.org)_
|
||||
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/) _(v3.router.vuejs.org)_
|
||||
- [Vue 3 备忘清单](./vue.md)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 2.x 版本对应 Vue Router 3.x 路由版本
|
||||
@@ -549,7 +550,6 @@ data: {
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
```js
|
||||
var example1 = new Vue({
|
||||
el: '#example-1',
|
||||
@@ -1194,6 +1194,7 @@ vm.selected.number // => 123
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
- 将 `HTML`/`CSS`/`JS` 三部分存放到一个 `Hello.vue` 文件中
|
||||
|
||||
```html
|
||||
<template>
|
||||
<p>{{ title }} World!</p>
|
||||
@@ -1221,7 +1222,9 @@ vm.selected.number // => 123
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
- 使用 `Hello.vue` 组件
|
||||
|
||||
```html
|
||||
<script>
|
||||
import Vue from "vue";
|
||||
@@ -1680,7 +1683,7 @@ Vue.component('alert-box', {
|
||||
`leave-active-class` | [#](https://v2.cn.vuejs.org/v2/guide/transitions.html#自定义过渡的类名)
|
||||
`leave-to-class` _(2.1.8+)_ | [#](https://v2.cn.vuejs.org/v2/guide/transitions.html#自定义过渡的类名)
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
```html
|
||||
<transition
|
||||
@@ -2025,7 +2028,6 @@ Vue 2 API 参考
|
||||
`v-on:click.passive` _(2.3.0)_ [#](https://v2.cn.vuejs.org/v2/api/#v-on) | 以 { passive: true } 模式添加侦听器
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
|
||||
### v-on (鼠标)修饰符
|
||||
|
||||
:- | :-
|
||||
@@ -2051,7 +2053,7 @@ Vue 2 API 参考
|
||||
:- | :-
|
||||
`v-on:keyup.enter` | [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.tab` | [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.delete ` | 捕获“删除”和“退格”键 [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.delete` | 捕获“删除”和“退格”键 [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.esc` | [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.space` | [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
`v-on:keyup.up` | [#](https://v2.cn.vuejs.org/v2/guide/events.html#按键修饰符)
|
||||
|
101
docs/xcode.md
Normal file
@@ -0,0 +1,101 @@
|
||||
Xcode 备忘清单
|
||||
====
|
||||
|
||||
这个 Xcode 快速参考备忘单显示了它的键盘快捷键和命令。
|
||||
|
||||
Xcode
|
||||
---
|
||||
|
||||
### 搜索
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + F` | 在文件中查找
|
||||
`Cmd + Option + F` | 在文件中查找和替换
|
||||
`Cmd + Shift + F` | 在项目中查找
|
||||
`Cmd + Option + Shift + F` | 在项目中查找和替换
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 选项卡
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + T` | 新选项卡
|
||||
`Cmd + }` | 上一个选项卡
|
||||
`Cmd + {` | 下一个选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 导航
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Shift + O` | 快速打开
|
||||
`Cmd + J` | 专注于编辑
|
||||
`Cmd + Ctrl + UP` | 下一个对手
|
||||
`Cmd + Ctrl + DOWN` | 上一个对手
|
||||
`Cmd + Ctrl + RIGHT` | 下一个最近的文件
|
||||
`Cmd + Ctrl + LEFT` | 上一个 最近的文件
|
||||
`Cmd + click` | 符号的定义
|
||||
`Cmd + L` | 去线
|
||||
`Cmd + Option + LEFT` | 折叠部分
|
||||
`Cmd + Option + RIGHT` | 展开部分
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调试
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Shift + Y` | 切换调试区域
|
||||
`Cmd + '` | 下一期
|
||||
`Cmd + "` | 上一期
|
||||
`Cmd + \` | 添加/删除断点
|
||||
`Cmd + Y` | 活动/非活动断点
|
||||
`Cmd + K` | 清除控制台
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 导航器(左侧面板)
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + 0` | 显示隐藏
|
||||
`Cmd + 1-8` | 切换标签
|
||||
`Option + click` | 打开助理编辑器
|
||||
`Shift + Option + click` | 决定在哪里打开
|
||||
`double click` | 在新窗口中打开
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 编辑
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Option + ENTER` | 显示助理编辑器
|
||||
`Cmd + ENTER` | 隐藏助理编辑器
|
||||
`Ctrl + SPACE or ESC` | 切换完成
|
||||
`Cmd + ]` | 缩进部分
|
||||
`Cmd + [` | 突出部分
|
||||
`Ctrl + i` | 修复缩进
|
||||
`Cmd + /` | 评论/取消评论
|
||||
`Cmd + Option + [` | 向上移动队列
|
||||
`Cmd + Option + ]` | 下移线
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 实用程序(右面板)
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Option + 0` | 显示隐藏
|
||||
`Cmd + Option + 1-9` | 转到选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调试和运行
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + B` | 建造
|
||||
`Cmd + R` | 运行
|
||||
`Cmd + .` | 停止
|
||||
`Cmd + Shift + B` | 分析
|
||||
`Cmd + U` | 测试
|
||||
`Cmd + Shift + K` | 清理
|
||||
<!--rehype:className=shortcuts-->
|
@@ -118,10 +118,9 @@ $x('//a[text()="XPath"]')[0].click()
|
||||
### 运算符
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
||||
运算符 | 说明 | 示例
|
||||
运算符 | 说明 | 示例
|
||||
:- | - | -
|
||||
`\|` | 计算两个节点集 | `//book \| //cd`
|
||||
`\|` | 计算两个节点集 | `//book \| //cd`
|
||||
`+` | 添加 | `6 + 4`
|
||||
`-` | 减法 | `6 - 4`
|
||||
`*` | 乘法 | `6 * 4`
|
||||
@@ -137,8 +136,6 @@ $x('//a[text()="XPath"]')[0].click()
|
||||
`mod` | 模数(除法余数) | `5` mod `2`
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
|
||||
XPath 表达式
|
||||
-----------
|
||||
|
||||
@@ -149,7 +146,6 @@ XPath 表达式
|
||||
| `//` | `ul` | `/` | `a[@id='link']` |
|
||||
| Axis | Step | Axis | Step |
|
||||
|
||||
|
||||
### 前缀
|
||||
|
||||
| 前缀 | 例子 | 意思是 |
|
||||
@@ -202,6 +198,7 @@ XPath Predicates(谓词)
|
||||
//ul[count(li) > 2]
|
||||
//ul[count(li[@class='hide']) > 0]
|
||||
```
|
||||
|
||||
```bash
|
||||
# 返回具有 `<li>` 子级的 `<ul>`
|
||||
//ul[li]
|
||||
@@ -251,6 +248,7 @@ text() # //button[text()="Submit"]
|
||||
lang(str)
|
||||
namespace-uri()
|
||||
```
|
||||
|
||||
```bash
|
||||
count() # //table[count(tr)=1]
|
||||
position() # //ol/li[position()=2]
|
||||
@@ -429,5 +427,5 @@ count(//*) # 计算所有元素
|
||||
另见
|
||||
--------
|
||||
|
||||
* [Devhints](https://devhints.io/xpath) _(devhints.io)_
|
||||
* [Xpath test bed](http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm) _(whitebeam.org)_
|
||||
- [Devhints](https://devhints.io/xpath) _(devhints.io)_
|
||||
- [Xpath test bed](http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm) _(whitebeam.org)_
|
||||
|
16
docs/yaml.md
@@ -18,7 +18,6 @@ YAML 备忘清单
|
||||
- Ansible playbook 是 YAML 文件
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
|
||||
### 标量类型
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -57,7 +56,7 @@ other_thing: *VAR_NAME
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"some_thing": "foobar",
|
||||
"other_thing": "foobar"
|
||||
@@ -84,7 +83,7 @@ description: |
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{"description": "hello\nworld\n"}
|
||||
```
|
||||
|
||||
@@ -102,7 +101,7 @@ child:
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"parent": {
|
||||
"a": 2,
|
||||
@@ -129,7 +128,7 @@ other_values:
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"values": [
|
||||
"Will be",
|
||||
@@ -154,7 +153,7 @@ description: >
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{"description": "hello world\n"}
|
||||
```
|
||||
|
||||
@@ -350,7 +349,6 @@ set2: !!set {'one', "two"}
|
||||
|
||||
集合表示为一个映射,其中每个键都与一个空值相关联
|
||||
|
||||
|
||||
### 有序映射
|
||||
|
||||
```yaml
|
||||
@@ -450,7 +448,6 @@ YAML 参考
|
||||
| `#` | 一次性评论指示器 |
|
||||
| <code>\`@</code> | 两者都保留供将来使用 |
|
||||
|
||||
|
||||
### 核心类型(默认自动标签)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@@ -474,11 +471,12 @@ YAML 参考
|
||||
|
||||
- `\\` (\\)
|
||||
- `\"` (")
|
||||
- `\ ` ( )
|
||||
- `\` ( )
|
||||
- `\<TAB>` (TAB)
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
#### C
|
||||
|
||||
- `\0` (NUL)
|
||||
- `\a` (BEL)
|
||||
- `\b` (BS)
|
||||
|
423
docs/yum.md
Normal file
@@ -0,0 +1,423 @@
|
||||
YUM 备忘清单
|
||||
===
|
||||
|
||||
这个 YUM 快速参考备忘单显示了它的常用命令使用清单。
|
||||
|
||||
YUM 清单查询
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
yum(`Y`ellow dog `U`pdater, `M`odified)是一个在 `Fedora` 和 `RedHat` 以及 SUSE 中的 `Shell` 前端软件包管理器
|
||||
|
||||
```bash
|
||||
$ yum [options] [command] [package ...]
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- [YUM 官方网站](http://yum.baseurl.org/) _(yum.baseurl.org)_
|
||||
- [Fedora 中的 Yum 文档](https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/ch-yum.html) _(fedoraproject.org)_
|
||||
- [CentOS 中的 Yum 文档](http://wiki.centos.org/PackageManagement/Yum/) _(wiki.centos.org)_
|
||||
- [Scientific Linux 中的 Yum 文档](https://www.scientificlinux.org/documentation/faq/yum.apt.repo) _(scientificlinux.org)_
|
||||
|
||||
### YUM 查询
|
||||
|
||||
子命令描述和任务
|
||||
|
||||
#### help
|
||||
|
||||
显示 yum 命令和选项
|
||||
|
||||
```bash
|
||||
yum help
|
||||
```
|
||||
|
||||
显示 yum 子命令和选项
|
||||
|
||||
### 单独的包
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
#### list
|
||||
|
||||
列出存储库中的包名称
|
||||
|
||||
```bash
|
||||
# 列出存储库中的包名称
|
||||
yum list available
|
||||
# 列出所有可用的包
|
||||
yum list installed
|
||||
# 列出所有已安装的包
|
||||
yum list all
|
||||
# 列出已安装和可用的软件包
|
||||
yum list kernel
|
||||
```
|
||||
|
||||
#### info
|
||||
|
||||
列出已安装和可用的内核包
|
||||
|
||||
```bash
|
||||
# 列出有关 `vsftpd` 软件包的信息
|
||||
$ yum info vsftpd
|
||||
```
|
||||
|
||||
#### deplist
|
||||
|
||||
显示包的依赖项
|
||||
|
||||
```bash
|
||||
$ yum deplist nfs-utils
|
||||
```
|
||||
|
||||
列出依赖项和提供它们的包
|
||||
|
||||
#### provides
|
||||
|
||||
```bash
|
||||
# 查找提供查询文件的包
|
||||
$ yum provides “*bin/top”
|
||||
# 显示包含 README.top 文件的包
|
||||
$ yum provides “*/README.top”
|
||||
```
|
||||
|
||||
#### search
|
||||
|
||||
```bash
|
||||
# 查找名称或描述中带有 samba 的软件包
|
||||
$ yum search samba
|
||||
```
|
||||
|
||||
#### updateinfo
|
||||
|
||||
```bash
|
||||
# 获取有关可用软件包更新的信息
|
||||
$ yum updateinfo security
|
||||
```
|
||||
|
||||
获取有关可用 security 更新的信息
|
||||
|
||||
### 包组
|
||||
|
||||
#### grouplist
|
||||
|
||||
列出已安装和可用软件包组的名称
|
||||
|
||||
#### groupinfo
|
||||
|
||||
```bash
|
||||
# 查看 Web 服务器组中的包
|
||||
$ yum groupinfo "Web Server"
|
||||
```
|
||||
|
||||
#### check-update
|
||||
|
||||
查询存储库以获取可用的软件包更新
|
||||
|
||||
### 管理 YUM 存储库
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### repolist
|
||||
|
||||
显示启用的软件存储库
|
||||
|
||||
#### repoinfo
|
||||
|
||||
显示有关启用的 `yum` 存储库的信息 *
|
||||
|
||||
```bash
|
||||
$ yum repoinfo rhel-7-server-rpms
|
||||
```
|
||||
|
||||
请参阅有关 rhel-7-server-rpms 存储库的信息
|
||||
|
||||
#### repo-pkgs
|
||||
|
||||
使用特定存储库中的包 *
|
||||
|
||||
```bash
|
||||
# 列出来自 my-rpms 存储库的软件包
|
||||
$ yum repo-pkgs my-rpms list
|
||||
# 从 my-rpms repo 安装所有软件包
|
||||
$ yum repo-pkgs my-rpms install
|
||||
# 从 my-rpms 存储库中删除所有软件包
|
||||
$ yum repo-pkgs my-rpms remove
|
||||
```
|
||||
|
||||
#### makecache
|
||||
|
||||
下载 `yum` 存储库数据到缓存
|
||||
|
||||
### 故障排除和维护 YUM
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### check
|
||||
|
||||
检查本地 RPM 数据库是否有问题(运行了很长时间)
|
||||
|
||||
#### history
|
||||
|
||||
```bash
|
||||
# 列出所有 yum 安装、更新和清理操作
|
||||
$ yum history list
|
||||
# 显示 yum info 3 的详细信息
|
||||
$ yum history info 3
|
||||
# 撤消事务 3 中的 yum 操作
|
||||
$ yum history undo 3
|
||||
# 重做事务 3 中撤消的 yum 操作
|
||||
$ yum history redo 3
|
||||
```
|
||||
|
||||
#### clean
|
||||
|
||||
```bash
|
||||
# 删除缓存中保存的包
|
||||
$ yum clean packages
|
||||
# 从缓存中清除所有包和元数据
|
||||
$ yum clean all
|
||||
```
|
||||
|
||||
清除缓存的包数据
|
||||
|
||||
#### fssnapshot
|
||||
|
||||
列出 LVM 快照(帮助在包更新后回滚)
|
||||
|
||||
#### fs
|
||||
|
||||
```bash
|
||||
# 列出启用的文件系统过滤器
|
||||
$ yum fs filters
|
||||
# 过滤所有正在安装的文档(小心!)
|
||||
$ yum fs documentation
|
||||
```
|
||||
|
||||
对文件系统采取行动(防止在最小系统上安装 doc 或语言文件)非常有用!
|
||||
|
||||
### 使用 YUM 管理语言包
|
||||
|
||||
#### langavailable
|
||||
|
||||
列出已安装的语言 *
|
||||
|
||||
#### langinfo
|
||||
|
||||
```bash
|
||||
# 列出与西班牙语相关的软件包
|
||||
$ yum langinfo es
|
||||
```
|
||||
|
||||
#### langinstall
|
||||
|
||||
```bash
|
||||
# 安装与西班牙语相关的软件包
|
||||
$ yum langinstall es
|
||||
```
|
||||
|
||||
#### langlist
|
||||
|
||||
列出已安装的语言 *
|
||||
|
||||
#### langremove
|
||||
|
||||
```bash
|
||||
# 删除与西班牙语相关的软件包
|
||||
$ yum langremove es
|
||||
```
|
||||
|
||||
### 使用 YUM 安装、删除和升级软件包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### install
|
||||
|
||||
```bash
|
||||
# 安装 vsftpd 包
|
||||
$ yum install vsftpd
|
||||
```
|
||||
|
||||
#### update
|
||||
|
||||
```bash
|
||||
# 使用可用更新更新所有软件包
|
||||
$ yum update
|
||||
# 更新 httpd 包(如果可用)
|
||||
$ yum update httpd
|
||||
# 应用与安全相关的包更新
|
||||
$ yum update --security
|
||||
```
|
||||
|
||||
#### update-to
|
||||
|
||||
将一个或所有软件包更新到特定版本
|
||||
|
||||
#### upgrade
|
||||
|
||||
```bash
|
||||
$ yum -y upgrade
|
||||
```
|
||||
|
||||
更新包考虑过时,只升级所有包,不升级软件和系统内核
|
||||
|
||||
#### localinstall
|
||||
|
||||
```bash
|
||||
# 从本地文件、http 或 ftp 安装包
|
||||
$ yum localinstall abc-1-1.i686.rpm
|
||||
# 从本地目录安装 abc 包
|
||||
$ yum localinstall http://myrepo/abc-1-1.i686.rpm
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
从 FTP 站点安装 abc
|
||||
|
||||
#### downgrade
|
||||
|
||||
将软件包降级到早期版本
|
||||
|
||||
```bash
|
||||
$ yum downgrade abc
|
||||
```
|
||||
|
||||
将 abc 包降级到早期版本
|
||||
|
||||
#### reinstall
|
||||
|
||||
```bash
|
||||
# 重新安装 util-linux(以替换任何已删除的文件)
|
||||
$ yum reinstall util-linux
|
||||
```
|
||||
|
||||
#### swap
|
||||
|
||||
```bash
|
||||
# 删除 ftp 包并安装 lftp 包
|
||||
$ yum swap ftp lftp
|
||||
```
|
||||
|
||||
#### erase/remove
|
||||
|
||||
```bash
|
||||
# 删除 vsftpd 包和依赖
|
||||
$ yum remove vsftpd
|
||||
```
|
||||
|
||||
#### autoremove
|
||||
|
||||
```bash
|
||||
# 删除 httpd 和其他不需要的包
|
||||
$ yum autoremove httpd
|
||||
```
|
||||
|
||||
#### groupinstall
|
||||
|
||||
```bash
|
||||
# 安装 Web 服务器包
|
||||
$ yum groupinstall "Web server"
|
||||
```
|
||||
|
||||
### 更多 YUM 相关命令(安装 yum-utils 软件包)
|
||||
|
||||
#### find-repos-of-install
|
||||
|
||||
查找包来自哪个存储库
|
||||
|
||||
#### needs-restarting
|
||||
|
||||
查找已更新且需要重启的进程
|
||||
|
||||
#### repoclosure
|
||||
|
||||
从存储库中获取未满足的依赖项列表
|
||||
|
||||
#### repoquery
|
||||
|
||||
查询远程仓库和本地 `RPM` 数据库
|
||||
|
||||
```bash
|
||||
# 显示依赖包
|
||||
$ repoquery --requires --resolve bash
|
||||
```
|
||||
|
||||
#### reposync
|
||||
|
||||
将 `yum` 存储库同步到本地目录
|
||||
|
||||
```bash
|
||||
# 从 repo 获取包
|
||||
$ reposync -r rhel-atomic-host-beta-rpms
|
||||
```
|
||||
|
||||
#### repotrack
|
||||
|
||||
下载一个包及其所有依赖项
|
||||
|
||||
#### show-installed
|
||||
|
||||
列出已安装的 RPM 包和统计信息
|
||||
|
||||
#### verifytree
|
||||
|
||||
检查本地 yum 存储库的一致性
|
||||
|
||||
#### yum-complete-transaction
|
||||
|
||||
尝试完成未完成的 yum 交易
|
||||
|
||||
#### yumdb
|
||||
|
||||
检查或更改 yum 数据库
|
||||
|
||||
#### yumdownloader
|
||||
|
||||
```bash
|
||||
# 使用本地源离线安装 net-tools 工具包
|
||||
$ yumdownloader net-tools.x86_64
|
||||
# 使用 –destdir 参数设置下载的目标目录
|
||||
$ yumdownloader net-tools.x86_64 --destdir=/usr/local/bin/
|
||||
# 使用 –resolve 参数解决依赖关系并下载所需的安装包
|
||||
$ yumdownloader net-tools.x86_64 --resolve --destdir=/usr/local/bin/
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
从 repo 下载一个包到当前目录
|
||||
|
||||
### 不同 YUM 命令的常用选项
|
||||
|
||||
```bash
|
||||
yum --disableplugin=langpacks info vsftpd
|
||||
# 显示与正在运行的进程相关的包
|
||||
yum --enableplugin=ps ps
|
||||
yum install docker \
|
||||
--enablerepo=rhel-7-server-extras-rpm
|
||||
yum list available --disablerepo=epel
|
||||
# 下载 vsftpd 包到缓存
|
||||
yum install --downloadonly vsftpd
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-y` | 如果出现提示,假设是
|
||||
`--assumeno` | 如果提示,则假设否
|
||||
`-q` | 不产生任何输出
|
||||
`-v` | 产生额外的调试输出
|
||||
`--noplugins` | 运行命令而不加载任何 yum 插件
|
||||
`--disableplugin=` | 禁用单个命令的特定插件
|
||||
`--enableplugin=` | 启用已安装但当前已禁用的插件
|
||||
`--enablerepo=` | 为单个命令启用当前禁用的 repo(通配符可以)
|
||||
`--disablerepo=` | 为单个命令禁用当前启用的 repo(通配符可以)
|
||||
`--downloadonly` | 下载到 `/var/cache/yum/arch/prod/repo/packages/`,但不要安装
|
||||
`--filter-???=` | 代替???与vendors, rpm-groups, arches 和其他人一起过滤输出
|
||||
`--changelog` | 显示包的变更日志信息
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [YUM 官方网站](http://yum.baseurl.org/) _(yum.baseurl.org)_
|
||||
- [YUM 备忘清单(适用于红帽 RedHad 企业 Linux)](https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf) _(access.redhat.com)_
|
||||
- [用 yum 管理软件包](http://prefetch.net/articles/yum.html) _(prefetch.net)_
|
||||
- [Fedora 中的 Yum 文档](https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/ch-yum.html) _(fedoraproject.org)_
|
||||
- [CentOS 中的 Yum 文档](http://wiki.centos.org/PackageManagement/Yum/) _(wiki.centos.org)_
|
||||
- [Scientific Linux 中的 Yum 文档](https://www.scientificlinux.org/documentation/faq/yum.apt.repo) _(scientificlinux.org)_
|
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.15.0",
|
||||
"version": "1.19.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
@@ -10,7 +10,8 @@
|
||||
"prepare": "husky install",
|
||||
"build": "node scripts/build.mjs",
|
||||
"start": "node scripts/watch.mjs",
|
||||
"prettier": "prettier --write '**/*.{mjs,css,json,prettierrc,lintstagedrc}'"
|
||||
"prettier": "prettier --write '**/*.{mjs,css,json,prettierrc,lintstagedrc}'",
|
||||
"markdownlint": "npx markdownlint-cli --fix ./docs/*.md"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -26,12 +27,19 @@
|
||||
"fs-extra": "^10.1.0",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"markdownlint-cli": "^0.32.2",
|
||||
"prettier": "^2.7.1",
|
||||
"recursive-readdir-files": "^2.3.0",
|
||||
"rehype-autolink-headings": "^6.1.1",
|
||||
"rehype-document": "^6.1.0",
|
||||
"rehype-parse": "^8.0.4",
|
||||
"rehype-raw": "^6.1.1",
|
||||
"rehype-rewrite": "^3.0.6",
|
||||
"rehype-slug": "^5.0.1",
|
||||
"remark-gemoji": "^7.0.1"
|
||||
"remark-gemoji": "^7.0.1",
|
||||
"unified": "^10.1.2",
|
||||
"unist-util-visit": "^4.1.1",
|
||||
"vfile": "^5.3.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
|
3
scripts/assets/ansible.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 65 65">
|
||||
<path fill="currentColor" d="M32,0 C49.672,0 64,14.328 64,32 C64,49.674 49.674,64 32,64 C14.326,64 0,49.674 0,32 C0,14.326 14.328,0 32,0 Z M32.539,12.688 C31.666,12.688 30.875,13.156 30.511,14.04 L16.52,47.664 L21.303,47.664 L26.837,33.801 L43.352,47.144 C44.016,47.681 44.496,47.924 45.119,47.924 C46.367,47.924 47.457,46.988 47.457,45.638 C47.457,45.418 47.379,45.068 47.239,44.694 L34.512,14.04 C34.148,13.156 33.412,12.688 32.539,12.688 Z M32.54,19.548 L40.82,39.986 L28.312,30.133 L32.54,19.548 Z" transform="translate(.38 .76)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 648 B |
3
scripts/assets/cargo.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 32 32">
|
||||
<path d="M15 3.77a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0M3.654 12.38a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m22.692.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0M6.406 13.73a.87.87 0 0 0 .441-1.146l-.422-.954h1.66v7.48H4.736a11.71 11.71 0 0 1-.379-4.47zm6.942.184v-2.205H17.3c.204 0 1.44.236 1.44 1.16 0 .768-.95 1.044-1.73 1.044zM7.952 25.785a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m14.093.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0m.294-2.157a.867.867 0 0 0-1.03.667l-.477 2.228a11.71 11.71 0 0 1-9.765-.047l-.477-2.228a.865.865 0 0 0-1.03-.667l-1.967.422a11.71 11.71 0 0 1-1.017-1.199h9.57c.108 0 .18-.02.18-.118v-3.385c0-.1-.072-.118-.18-.118h-2.8v-2.146h3.027c.276 0 1.477.08 1.862 1.614l.565 2.5c.18.55.913 1.653 1.693 1.653h4.94a11.71 11.71 0 0 1-1.085 1.255zm5.314-8.938a11.71 11.71 0 0 1 .025 2.033h-1.2c-.12 0-.17.08-.17.197v.552c0 1.3-.732 1.58-1.374 1.653-.61.07-1.29-.256-1.372-.63-.36-2.028-.96-2.46-1.9-3.21 1.177-.748 2.402-1.85 2.402-3.327 0-1.594-1.093-2.598-1.838-3.09-1.045-.69-2.202-.827-2.514-.827H7.277a11.71 11.71 0 0 1 6.551-3.697l1.465 1.537c.33.347.88.36 1.226.028l1.64-1.567a11.71 11.71 0 0 1 8.017 5.709l-1.122 2.534a.87.87 0 0 0 .441 1.146zm2.798.04-.038-.392 1.156-1.078c.235-.22.147-.66-.153-.772l-1.477-.552-.116-.38.92-1.28c.188-.26.015-.675-.3-.727l-1.558-.253-.187-.35.655-1.437c.134-.293-.115-.667-.437-.655l-1.58.055-.25-.303.363-1.54c.073-.313-.244-.63-.557-.557l-1.54.363-.304-.25.055-1.58c.012-.32-.362-.57-.654-.437l-1.436.655-.35-.188-.254-1.558c-.05-.316-.467-.488-.727-.3l-1.28.92-.38-.115L19.47.586c-.112-.3-.553-.388-.772-.154L17.62 1.588l-.392-.038-.832-1.345c-.168-.272-.62-.272-.787 0l-.832 1.345-.392.038L13.305.43c-.22-.234-.66-.147-.772.154l-.552 1.477-.38.115-1.28-.92c-.26-.188-.676-.015-.727.3L9.34 3.114l-.35.188-1.436-.655c-.292-.133-.667.117-.654.437l.055 1.58-.304.25-1.54-.363c-.313-.073-.63.244-.557.557l.363 1.54-.25.303-1.58-.055c-.32-.01-.57.362-.437.655l.655 1.437-.188.35-1.558.253c-.316.05-.488.467-.3.727l.92 1.28-.116.38-1.477.552c-.3.112-.388.553-.153.772l1.156 1.078-.038.392-1.345.832c-.272.168-.272.62 0 .787l1.345.832.038.392L.43 18.697c-.234.22-.147.66.153.772l1.477.552.116.38-.92 1.28c-.187.26-.015.676.3.727l1.557.253.188.35-.655 1.436c-.133.292.118.667.437.655l1.58-.055.25.304-.363 1.54c-.073.312.244.63.557.556l1.54-.363.304.25-.055 1.58c-.012.32.362.57.654.437l1.436-.655.35.188.254 1.557c.05.317.467.488.727.302l1.28-.922.38.116.552 1.477c.112.3.553.388.772.153l1.078-1.156.392.04.832 1.345c.168.27.618.272.787 0l.832-1.345.392-.04 1.078 1.156c.22.235.66.147.772-.153l.552-1.477.38-.116 1.28.922c.26.187.676.015.727-.302l.254-1.557.35-.188 1.436.655c.292.133.666-.116.654-.437l-.055-1.58.303-.25 1.54.363c.313.073.63-.244.557-.556l-.363-1.54.25-.304 1.58.055c.32.013.57-.363.437-.655l-.655-1.436.187-.35 1.558-.253c.317-.05.49-.466.3-.727l-.92-1.28.116-.38 1.477-.552c.3-.113.388-.553.153-.772l-1.156-1.078.038-.392 1.345-.832c.272-.168.273-.618 0-.787z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
3
scripts/assets/cmake.svg
Normal 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="M11.769.066.067 23.206l12.76-10.843zm11.438 23.868L7.471 17.587 0 23.934zm.793-.198L12.298.463l1.719 19.24zM12.893 12.959l-5.025 4.298 5.62 2.248z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 274 B |
3
scripts/assets/conan.svg
Normal 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="M11.709 0 0 5.534V16.76L11.984 24l4.857-2.706V9.998c.13-.084.275-.196.399-.27l.032-.017c.197-.11.329-.102.23.33v10.884l6.466-3.603V6.11L24 6.093Zm.915 2.83c.932.02 1.855.191 2.706.552a9.106 9.106 0 0 1 3.45 2.429 62.814 62.814 0 0 1-3.044 1.616c.56-.853.14-2.009-.76-2.455-.93-.648-2.093-.73-3.205-.674-1.064.175-2.258.51-2.893 1.474-.722.862-.084 2.11.914 2.408 1.2.509 2.543.38 3.806.413-.975.457-1.931.97-2.927 1.358-1.701-.176-3.585-.917-4.374-2.51-.574-1.178.215-2.572 1.319-3.14a11.426 11.426 0 0 1 3.336-1.348 9.212 9.212 0 0 1 1.672-.123Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 674 B |
3
scripts/assets/gmail.svg
Normal 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="M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64 12 9.548l6.545-4.91 1.528-1.145C21.69 2.28 24 3.434 24 5.457z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 358 B |
3
scripts/assets/graphql.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="m2.61 4.432 4.142-2.417-.504-.864-4.143 2.417.504.864ZM2 9.5v-4H1v4h1Zm6.248-7.485 4.143 2.417.504-.864-4.143-2.417-.504.864ZM13 5.5v4h1v-4h-1Zm-.252 4.86-4.5 2.625.504.864 4.5-2.625-.504-.864Zm-5.996 2.625-4.143-2.417-.504.864 4.143 2.417.504-.864ZM6.584 1.973l-5 7.5.832.554 5-7.5-.832-.554Zm6.832 7.5-5-7.5-.832.554 5 7.5.832-.554ZM2.5 11h10v-1h-10v1Zm5-9a.5.5 0 0 1-.5-.5H6A1.5 1.5 0 0 0 7.5 3V2Zm.5-.5a.5.5 0 0 1-.5.5v1A1.5 1.5 0 0 0 9 1.5H8ZM7.5 1a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 7.5 0v1Zm0-1A1.5 1.5 0 0 0 6 1.5h1a.5.5 0 0 1 .5-.5V0Zm6 5a.5.5 0 0 1-.5-.5h-1A1.5 1.5 0 0 0 13.5 6V5Zm.5-.5a.5.5 0 0 1-.5.5v1A1.5 1.5 0 0 0 15 4.5h-1Zm-.5-.5a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 13.5 3v1Zm0-1A1.5 1.5 0 0 0 12 4.5h1a.5.5 0 0 1 .5-.5V3Zm0 8a.5.5 0 0 1-.5-.5h-1a1.5 1.5 0 0 0 1.5 1.5v-1Zm.5-.5a.5.5 0 0 1-.5.5v1a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5-.5a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 13.5 9v1Zm0-1a1.5 1.5 0 0 0-1.5 1.5h1a.5.5 0 0 1 .5-.5V9Zm-6 5a.5.5 0 0 1-.5-.5H6A1.5 1.5 0 0 0 7.5 15v-1Zm.5-.5a.5.5 0 0 1-.5.5v1A1.5 1.5 0 0 0 9 13.5H8Zm-.5-.5a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 7.5 12v1Zm0-1A1.5 1.5 0 0 0 6 13.5h1a.5.5 0 0 1 .5-.5v-1Zm-6-1a.5.5 0 0 1-.5-.5H0A1.5 1.5 0 0 0 1.5 12v-1Zm.5-.5a.5.5 0 0 1-.5.5v1A1.5 1.5 0 0 0 3 10.5H2Zm-.5-.5a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 1.5 9v1Zm0-1A1.5 1.5 0 0 0 0 10.5h1a.5.5 0 0 1 .5-.5V9Zm0-4a.5.5 0 0 1-.5-.5H0A1.5 1.5 0 0 0 1.5 6V5Zm.5-.5a.5.5 0 0 1-.5.5v1A1.5 1.5 0 0 0 3 4.5H2ZM1.5 4a.5.5 0 0 1 .5.5h1A1.5 1.5 0 0 0 1.5 3v1Zm0-1A1.5 1.5 0 0 0 0 4.5h1a.5.5 0 0 1 .5-.5V3Z" fill="currentColor" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
3
scripts/assets/matlab.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 170 155">
|
||||
<path fill="currentColor" d="M114.011719,0 C114.031753,0 114.051781,9.66838127e-05 114.071803,0.00028991369 L113.950625,0 C114.100589,0 114.249952,0.00491257692 114.398738,0.0147015257 C114.496091,0.0180986001 114.59346,0.0264563127 114.690679,0.0370869506 C114.763187,0.0481571338 114.835494,0.0572318789 114.907669,0.067464417 C114.971991,0.0739091229 115.036007,0.0841522806 115.099959,0.0953775501 C115.24595,0.122450074 115.39156,0.152173631 115.536656,0.18662408 C115.540798,0.188498498 115.544794,0.189486731 115.54879,0.190478791 C119.122197,1.04453486 122.383831,4.76737051 125.66002,10.8263087 C134.504866,26.8199813 143.233527,58.3720491 155.079417,90.6337197 C159.654754,102.628081 164.55935,114.497108 169.788199,126.226944 L169.804687,126.261915 C169.561883,126.036533 169.320725,125.810778 169.080287,125.584766 C157.868517,115.075569 148.22195,104.663526 137.239023,104.2475 C132.658523,104.354002 127.856902,106.798464 122.838279,110.852094 C115.884496,116.808357 108.801576,125.883622 101.371385,134.204547 C98.5874924,137.56095 95.5963582,140.611013 92.6231575,143.258032 C88.7439115,146.854737 84.755953,149.885794 80.6318234,151.86198 C77.8565289,153.320564 75.5138817,154.09239 73.9252344,154.03711 C73.9252344,154.03711 73.6050703,153.13142 73.0221211,151.57669 C72.3047411,149.730047 71.5034539,147.651723 70.6255994,145.430214 C66.7152626,135.747112 59.8767348,120.415838 53.1632895,113.088875 C51.6852935,111.572994 50.1641478,110.359882 48.6081822,109.545946 C44.005418,107.866712 38.8723879,108.38614 34.6886719,110.979493 L0.055,86.396 L48.3332422,66.8904688 L48.6560848,66.4654629 C53.451559,60.1199079 58.8698811,54.2694715 64.8303516,49.0016797 L64.5185432,49.2785154 C64.6217228,49.1857698 64.7250601,49.0931917 64.8285547,49.0007813 C68.8310937,46.8777734 76.3510156,48.0304688 90.1177734,30.9287109 C90.3414762,30.6490748 90.5626216,30.370121 90.781262,30.0919051 C92.8016022,27.5154524 94.6118072,25.0027302 96.2508432,22.5981511 L96.5028669,22.2275882 C105.052639,9.58238289 108.828956,0 113.950625,0 L113.994,0.001 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
3
scripts/assets/postgres.svg
Normal file
After Width: | Height: | Size: 6.0 KiB |
3
scripts/assets/ruby.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" height="1em" width="1em">
|
||||
<path d="M26.875.109c4.043.703 5.193 3.464 5.104 6.36L32 6.426l-1.817 23.855-23.641 1.62c-1.963-.084-6.344-.261-6.541-6.38l2.193-4 3.76 8.781.672 1.561 3.739-12.192-.041.011.021-.043 12.339 3.944-1.86-7.245-1.317-5.199 11.755-.76-.817-.677-8.443-6.885 4.88-2.719zM0 25.453v.031-.036zM6.839 6.765c4.749-4.713 10.875-7.495 13.229-5.12 2.348 2.371-.141 8.141-4.896 12.844-4.751 4.713-10.803 7.647-13.151 5.276-2.355-2.364.057-8.287 4.817-13z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 557 B |
3
scripts/assets/rust.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 32 32">
|
||||
<path d="M15 3.77a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0M3.654 12.38a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m22.692.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0M6.406 13.73a.87.87 0 0 0 .441-1.146l-.422-.954h1.66v7.48H4.736a11.71 11.71 0 0 1-.379-4.47zm6.942.184v-2.205H17.3c.204 0 1.44.236 1.44 1.16 0 .768-.95 1.044-1.73 1.044zM7.952 25.785a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m14.093.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0m.294-2.157a.867.867 0 0 0-1.03.667l-.477 2.228a11.71 11.71 0 0 1-9.765-.047l-.477-2.228a.865.865 0 0 0-1.03-.667l-1.967.422a11.71 11.71 0 0 1-1.017-1.199h9.57c.108 0 .18-.02.18-.118v-3.385c0-.1-.072-.118-.18-.118h-2.8v-2.146h3.027c.276 0 1.477.08 1.862 1.614l.565 2.5c.18.55.913 1.653 1.693 1.653h4.94a11.71 11.71 0 0 1-1.085 1.255zm5.314-8.938a11.71 11.71 0 0 1 .025 2.033h-1.2c-.12 0-.17.08-.17.197v.552c0 1.3-.732 1.58-1.374 1.653-.61.07-1.29-.256-1.372-.63-.36-2.028-.96-2.46-1.9-3.21 1.177-.748 2.402-1.85 2.402-3.327 0-1.594-1.093-2.598-1.838-3.09-1.045-.69-2.202-.827-2.514-.827H7.277a11.71 11.71 0 0 1 6.551-3.697l1.465 1.537c.33.347.88.36 1.226.028l1.64-1.567a11.71 11.71 0 0 1 8.017 5.709l-1.122 2.534a.87.87 0 0 0 .441 1.146zm2.798.04-.038-.392 1.156-1.078c.235-.22.147-.66-.153-.772l-1.477-.552-.116-.38.92-1.28c.188-.26.015-.675-.3-.727l-1.558-.253-.187-.35.655-1.437c.134-.293-.115-.667-.437-.655l-1.58.055-.25-.303.363-1.54c.073-.313-.244-.63-.557-.557l-1.54.363-.304-.25.055-1.58c.012-.32-.362-.57-.654-.437l-1.436.655-.35-.188-.254-1.558c-.05-.316-.467-.488-.727-.3l-1.28.92-.38-.115L19.47.586c-.112-.3-.553-.388-.772-.154L17.62 1.588l-.392-.038-.832-1.345c-.168-.272-.62-.272-.787 0l-.832 1.345-.392.038L13.305.43c-.22-.234-.66-.147-.772.154l-.552 1.477-.38.115-1.28-.92c-.26-.188-.676-.015-.727.3L9.34 3.114l-.35.188-1.436-.655c-.292-.133-.667.117-.654.437l.055 1.58-.304.25-1.54-.363c-.313-.073-.63.244-.557.557l.363 1.54-.25.303-1.58-.055c-.32-.01-.57.362-.437.655l.655 1.437-.188.35-1.558.253c-.316.05-.488.467-.3.727l.92 1.28-.116.38-1.477.552c-.3.112-.388.553-.153.772l1.156 1.078-.038.392-1.345.832c-.272.168-.272.62 0 .787l1.345.832.038.392L.43 18.697c-.234.22-.147.66.153.772l1.477.552.116.38-.92 1.28c-.187.26-.015.676.3.727l1.557.253.188.35-.655 1.436c-.133.292.118.667.437.655l1.58-.055.25.304-.363 1.54c-.073.312.244.63.557.556l1.54-.363.304.25-.055 1.58c-.012.32.362.57.654.437l1.436-.655.35.188.254 1.557c.05.317.467.488.727.302l1.28-.922.38.116.552 1.477c.112.3.553.388.772.153l1.078-1.156.392.04.832 1.345c.168.27.618.272.787 0l.832-1.345.392-.04 1.078 1.156c.22.235.66.147.772-.153l.552-1.477.38-.116 1.28.922c.26.187.676.015.727-.302l.254-1.557.35-.188 1.436.655c.292.133.666-.116.654-.437l-.055-1.58.303-.25 1.54.363c.313.073.63-.244.557-.556l-.363-1.54.25-.304 1.58.055c.32.013.57-.363.437-.655l-.655-1.436.187-.35 1.558-.253c.317-.05.49-.466.3-.727l-.92-1.28.116-.38 1.477-.552c.3-.113.388-.553.153-.772l-1.156-1.078.038-.392 1.345-.832c.272-.168.273-.618 0-.787z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
2
scripts/assets/systemd.svg
Normal file
@@ -0,0 +1,2 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 86 26">
|
||||
<path d="M10,0 L10,4 L4,4 L4,22 L10,22 L10,26 L0,26 L0,0 L10,0 Z M86,0 L86,26 L76,26 L76,22 L82,22 L82,4 L76,4 L76,0 L86,0 Z M63,3 L63,23 L45,13 L63,3 Z M30,4 C34.9705627,4 39,8.02943725 39,13 C39,17.9705627 34.9705627,22 30,22 C25.0294373,22 21,17.9705627 21,13 C21,8.02943725 25.0294373,4 30,4 Z"/></svg>
|
After Width: | Height: | Size: 412 B |
3
scripts/assets/tmux.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.5 1h-12l-.5.5v13l.5.5h12l.5-.5v-13l-.5-.5zM7 7.5V13H2V2h5v5.5zm6 5.5H8V8h5v5zm0-6H8V2h5v5z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 262 B |