Compare commits
118 Commits
Author | SHA1 | Date | |
---|---|---|---|
ae633b43e8 | |||
cc6e992a4b | |||
2d994f8597 | |||
ad5accdeff | |||
3a7af1eef3 | |||
9ef65a9f3d | |||
6c220d88ae | |||
01da713410 | |||
768bcb96d9 | |||
fc11b2f0dc | |||
dda6efdc7c | |||
019b4d51ec | |||
f40b56ebb8 | |||
bb533b9081 | |||
6ca7d88a48 | |||
a2cfd4e785 | |||
b08cc85e41 | |||
3f84fe66d3 | |||
5cde10b118 | |||
db7a9aa6f9 | |||
9879fabc78 | |||
a2a2ae55ca | |||
19f919f532 | |||
cabda9b9c9 | |||
ce12b2a329 | |||
5e3d42d1ad | |||
bf962194da | |||
f5e2ad2c31 | |||
ff0cc58c1d | |||
b42883e3de | |||
931850d916 | |||
f4d2c99007 | |||
112a53c101 | |||
9e525009c9 | |||
f78562b95e | |||
63d846b35d | |||
afd924a928 | |||
fb19cda5bb | |||
c9834110cd | |||
98edffbca0 | |||
b3d206d981 | |||
9ec7595b83 | |||
ef823de9a5 | |||
da22b78d8f | |||
06978b1601 | |||
b768bd4e9b | |||
a143e30d93 | |||
7ac675e34c | |||
8e3307272c | |||
0c9fb086ee | |||
f1200c67e1 | |||
cc20a31a47 | |||
1f34ea3bc3 | |||
61b3b5deec | |||
3fed079194 | |||
c481bcdb7b | |||
96e752e809 | |||
01d238eaab | |||
07aaae0e2b | |||
247cd4d4e6 | |||
9945c1b16f | |||
8b151f891c | |||
9dd378128e | |||
6b286b6eb6 | |||
d280013c31 | |||
bdf0dc17cd | |||
4995e6f500 | |||
822e08a6de | |||
88f392c532 | |||
72766dfabe | |||
bfe5551acf | |||
c5792b7c7e | |||
81548feeef | |||
5e284e6f14 | |||
3c4540d248 | |||
e8ccba5cbb | |||
e6d2a48410 | |||
a82f7b948e | |||
7c17fe1222 | |||
e781a3b20e | |||
0f18fbac08 | |||
17c188861e | |||
1a1bf6cd66 | |||
ab795d65aa | |||
150a9bc943 | |||
89fddf6b6f | |||
a8ba4c4e7a | |||
45908c8d90 | |||
f626e21702 | |||
83d9bda16e | |||
470ccb5311 | |||
3964c0c301 | |||
3d0d2947a0 | |||
df8e3a8099 | |||
88b8c8f1c2 | |||
f123f31449 | |||
c0641d2898 | |||
a442108e0f | |||
2af557fa28 | |||
cb9af579f0 | |||
9a2cbcd359 | |||
0c81d4815b | |||
d3e880b6d2 | |||
8b2c227f73 | |||
545e702138 | |||
6f61fab73d | |||
95a03cef33 | |||
c56a018d9b | |||
a40568cc85 | |||
768fb34db9 | |||
b13bb0d6b9 | |||
7348140ae1 | |||
403838287e | |||
b07df71f57 | |||
5e88df2994 | |||
58f486a9fb | |||
665b7d8ce3 | |||
0af1de43c7 |
33
.github/workflows/ci.yml
vendored
@ -48,8 +48,29 @@ jobs:
|
||||
- name: gh-pages README.md
|
||||
working-directory: dist
|
||||
run: |
|
||||
cat > README.md << EOF
|
||||
cat << "EOF" > README.md
|
||||
Website: https://jaywcjlove.github.io/reference
|
||||
## Docker
|
||||
|
||||
[](https://hub.docker.com/r/wcjiang/reference) [](https://hub.docker.com/r/wcjiang/reference) [](https://hub.docker.com/r/wcjiang/reference)
|
||||
|
||||
轻松通过 `docker` 部署 `Quick Reference` 网站。
|
||||
|
||||
```bash
|
||||
docker pull wcjiang/reference
|
||||
```
|
||||
|
||||
```bash
|
||||
docker run --name reference --rm -d -p 9667:3000 wcjiang/reference:latest
|
||||
# Or
|
||||
docker run --name reference -itd -p 9667:3000 wcjiang/reference:latest
|
||||
```
|
||||
|
||||
在浏览器中访问以下 URL
|
||||
|
||||
```bash
|
||||
http://localhost:9667/
|
||||
```
|
||||
EOF
|
||||
|
||||
- name: Deploy
|
||||
@ -101,6 +122,8 @@ jobs:
|
||||
```
|
||||
|
||||
# Create Docker Image
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Docker Hub
|
||||
@ -114,7 +137,7 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v7
|
||||
tags: ${{ secrets.DOCKER_USER }}/reference:latest
|
||||
|
||||
- name: Build and push image:tags
|
||||
@ -123,7 +146,7 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v7
|
||||
tags: ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
|
||||
|
||||
# Create Docker Image in Github
|
||||
@ -139,7 +162,7 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v7
|
||||
tags: ghcr.io/jaywcjlove/reference:latest
|
||||
|
||||
- name: Build and push image:tags
|
||||
@ -148,7 +171,7 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v7
|
||||
tags: ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
|
||||
|
||||
# # Create Docker Image in Github
|
||||
|
135
CONTRIBUTING.md
@ -132,15 +132,81 @@ REF_LABEL=网站首页
|
||||
|
||||
由于中国国内访问,时常打不开,你可以访问下面镜像网站。
|
||||
|
||||
- [quickref.cn](https://quickref.cn)
|
||||
- [ecdata.cn](http://ref.ecdata.cn)
|
||||
- [mofe.io](http://quickref.mofe.io)
|
||||
- [aibk.cn](https://quickref.aibk.cn)
|
||||
- [jgeek.cn](http://reference.jgeek.cn/)
|
||||
- [laoleng.vip](http://bbs.laoleng.vip/reference/)
|
||||
- [liujiapeng.com](https://www.liujiapeng.com/)
|
||||
- [dbyun.net](https://www.dbyun.net/reference/index.html)
|
||||
- [dc6.fun](https://dc6.fun/reference/)
|
||||
- [if010.com](https://quickref.if010.com/)
|
||||
- [pipecraft.net](https://quickref.pipecraft.net/)
|
||||
- [isteed.cc](https://ref.isteed.cc/)
|
||||
- [1han.wiki](https://code.1han.wiki/)
|
||||
- [linzhe.top](https://linzhe.top/)
|
||||
- [xushanxiang.com](https://xushanxiang.com/ref/)
|
||||
- [winnerzr01.github.io](https://winnerzr01.github.io/Quick-Reference/index.html)
|
||||
- [isteed.cc](https://ref.isteed.cc/)
|
||||
- [hestudio.org](https://quickref.hestudio.org)
|
||||
- [surcode.cn](https://ref.surcode.cn)
|
||||
- [cms.im](https://quickref.cms.im/)
|
||||
- [nuomiphp.com](https://reference.tool.nuomiphp.com/)
|
||||
- [eryajf.net](https://ref.eryajf.net/)
|
||||
- [kjchmc.cn](https://ref.kjchmc.cn/)
|
||||
- [likeadmin.cn](https://www.likeadmin.cn/quickref/)
|
||||
- [qiubit.cc](http://ref.qiubit.cc)
|
||||
- [aoh.cc](https://aoh.cc/)
|
||||
- [reference.code05.com](https://reference.code05.com/)
|
||||
- [kyoma.top](https://reference.kyoma.top/)
|
||||
- [quickreference.pages.dev](https://quickreference.pages.dev/)
|
||||
- [code05.com](https://reference.code05.com/)
|
||||
- [xhfun.cn](https://ref.xhfun.cn/)
|
||||
|
||||
感谢🙏
|
||||
|
||||
## 利用 Github Actions 定时任务来完成自动更新
|
||||
|
||||
在仓库添加 `.github/workflows/update-ref.yml` 文件 Github Actions 配置,感谢 @eryajf https://github.com/jaywcjlove/reference/issues/102#issuecomment-1368158419 提供方法
|
||||
|
||||
```yml
|
||||
name: 每8个小时更新一次reference
|
||||
on:
|
||||
schedule:
|
||||
- cron: '21 */8 * * *' # 定时任务
|
||||
workflow_dispatch: # 手动运行
|
||||
|
||||
env: # 设置环境变量
|
||||
TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间)
|
||||
|
||||
jobs:
|
||||
build: # 自定义名称
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🚜 拉取最新代码
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 'main'
|
||||
repository: 'jaywcjlove/reference'
|
||||
|
||||
- name: ♻️ 编译静态文件
|
||||
run: |
|
||||
echo -e 'REF_URL=https://refs.xxx.net/\nREF_LABEL=网站首页' > .env
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
- name: 🚁 部署到服务器
|
||||
uses: wlixcc/SFTP-Deploy-Action@v1.0
|
||||
with:
|
||||
username: 'root' #ssh user name
|
||||
port: '22' # 远程服务器ssh端口,默认22
|
||||
server: 'prod.refs.xxx.net' # 远程服务器IP
|
||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} # 认证服务器秘钥对的私钥
|
||||
local_path: './dist/*' # 对应我们项目打包后的静态文件路径
|
||||
remote_path: '/data/www/refs.xxx.net' # 服务器上的路径
|
||||
delete_remote_files: true
|
||||
```
|
||||
|
||||
## 贡献
|
||||
|
||||
请参阅[贡献指南](./CONTRIBUTING.md)了解如何开始。一如既往,感谢我们出色的贡献者!
|
||||
@ -154,42 +220,57 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/mofelee" title="mofelee">
|
||||
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
|
||||
</a>
|
||||
<a href="https://github.com/Alex-Programer" title="Alex">
|
||||
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
|
||||
</a>
|
||||
<a href="https://github.com/JeffersonHuang" title="Jefferson">
|
||||
<img src="https://avatars.githubusercontent.com/u/47512530?v=4" width="42;" alt="Jefferson"/>
|
||||
</a>
|
||||
<a href="https://github.com/Alex-Programer" title="Alex">
|
||||
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
|
||||
</a>
|
||||
<a href="https://github.com/expoli" title="expoli">
|
||||
<img src="https://avatars.githubusercontent.com/u/31023767?v=4" width="42;" alt="expoli"/>
|
||||
</a>
|
||||
<a href="https://github.com/LiuYuan-SHU" title="Liuyuan">
|
||||
<img src="https://avatars.githubusercontent.com/u/96400967?v=4" width="42;" alt="Liuyuan"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/sjh42" title="42:p">
|
||||
<img src="https://avatars.githubusercontent.com/u/34529275?v=4" width="42;" alt="42:p"/>
|
||||
</a>
|
||||
<a href="https://github.com/LufsX" title="LufsX">
|
||||
<img src="https://avatars.githubusercontent.com/u/33221883?v=4" width="42;" alt="LufsX"/>
|
||||
</a>
|
||||
<a href="https://github.com/1834423612" title="kjch">
|
||||
<img src="https://avatars.githubusercontent.com/u/49981661?v=4" width="42;" alt="kjch"/>
|
||||
</a>
|
||||
<a href="https://github.com/pangxiaoli" title="pangxiaoli">
|
||||
<img src="https://avatars.githubusercontent.com/u/54620953?v=4" width="42;" alt="pangxiaoli"/>
|
||||
</a>
|
||||
<a href="https://github.com/partoneplay" title="partoneplay">
|
||||
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
|
||||
</a>
|
||||
<a href="https://github.com/ryanhex53" title="ryanhex53">
|
||||
<img src="https://avatars.githubusercontent.com/u/360426?v=4" width="42;" alt="ryanhex53"/>
|
||||
</a>
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/catcto" title="喵仙人">
|
||||
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/13812700839" title="花殇">
|
||||
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇"/>
|
||||
</a>
|
||||
<a href="https://github.com/Smartdousha" title="Anko">
|
||||
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
|
||||
<a href="https://github.com/dousha0w0" title="dousha0w0">
|
||||
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="dousha0w0"/>
|
||||
</a>
|
||||
<a href="https://github.com/Brid9e" title="Brid9e">
|
||||
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Brid9e"/>
|
||||
</a>
|
||||
<a href="https://github.com/ch3nnn" title="Ch3nnn">
|
||||
<img src="https://avatars.githubusercontent.com/u/40114564?v=4" width="42;" alt="Ch3nnn"/>
|
||||
</a>
|
||||
<a href="https://github.com/CharlotteZeng" title="hanchZ">
|
||||
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="hanchZ"/>
|
||||
</a>
|
||||
@ -202,21 +283,39 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/eeeeeio" title="EEEEE">
|
||||
<img src="https://avatars.githubusercontent.com/u/20723545?v=4" width="42;" alt="EEEEE"/>
|
||||
</a>
|
||||
<a href="https://github.com/Ding-Kyoma" title="HooinKyoma">
|
||||
<img src="https://avatars.githubusercontent.com/u/44542198?v=4" width="42;" alt="HooinKyoma"/>
|
||||
</a>
|
||||
<a href="https://github.com/jasnzhuang" title="Jason Zhuang">
|
||||
<img src="https://avatars.githubusercontent.com/u/16612921?v=4" width="42;" alt="Jason Zhuang"/>
|
||||
</a>
|
||||
<a href="https://github.com/JetSquirrel" title="JetSquirrel">
|
||||
<img src="https://avatars.githubusercontent.com/u/20291255?v=4" width="42;" alt="JetSquirrel"/>
|
||||
</a>
|
||||
<a href="https://github.com/LightQuanta" title="Light_Quanta">
|
||||
<img src="https://avatars.githubusercontent.com/u/18213217?v=4" width="42;" alt="Light_Quanta"/>
|
||||
</a>
|
||||
<a href="https://github.com/Lihuagreek" title="Lihuagreek">
|
||||
<img src="https://avatars.githubusercontent.com/u/51040740?v=4" width="42;" alt="Lihuagreek"/>
|
||||
</a>
|
||||
<a href="https://github.com/likeshop-github" title="LikeShop技术社区">
|
||||
<img src="https://avatars.githubusercontent.com/u/77180968?v=4" width="42;" alt="LikeShop技术社区"/>
|
||||
</a>
|
||||
<a href="https://github.com/mariuszmichalowski" title="Mariusz Michalowski">
|
||||
<img src="https://avatars.githubusercontent.com/u/92091891?v=4" width="42;" alt="Mariusz Michalowski"/>
|
||||
</a>
|
||||
<a href="https://github.com/HanaNoryu" title="Noryu">
|
||||
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
|
||||
</a>
|
||||
<a href="https://github.com/PipecraftNet" title="Pipecraft">
|
||||
<img src="https://avatars.githubusercontent.com/u/88728670?v=4" width="42;" alt="Pipecraft"/>
|
||||
</a>
|
||||
<a href="https://github.com/QDelta" title="QDelta">
|
||||
<img src="https://avatars.githubusercontent.com/u/60222316?v=4" width="42;" alt="QDelta"/>
|
||||
</a>
|
||||
<a href="https://github.com/qinxiongzhou" title="Ryan Zhou">
|
||||
<img src="https://avatars.githubusercontent.com/u/33239096?v=4" width="42;" alt="Ryan Zhou"/>
|
||||
</a>
|
||||
<a href="https://github.com/whb1998a" title="WHB">
|
||||
<img src="https://avatars.githubusercontent.com/u/44045064?v=4" width="42;" alt="WHB"/>
|
||||
</a>
|
||||
@ -235,6 +334,12 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/cool9203" title="cool9203">
|
||||
<img src="https://avatars.githubusercontent.com/u/29609607?v=4" width="42;" alt="cool9203"/>
|
||||
</a>
|
||||
<a href="https://github.com/fjqz177" title="fjqz177">
|
||||
<img src="https://avatars.githubusercontent.com/u/83070583?v=4" width="42;" alt="fjqz177"/>
|
||||
</a>
|
||||
<a href="https://github.com/gi-b716" title="gi-b716">
|
||||
<img src="https://avatars.githubusercontent.com/u/78394473?v=4" width="42;" alt="gi-b716"/>
|
||||
</a>
|
||||
<a href="https://github.com/godotc" title="godotc">
|
||||
<img src="https://avatars.githubusercontent.com/u/79260851?v=4" width="42;" alt="godotc"/>
|
||||
</a>
|
||||
@ -247,6 +352,9 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/hweining" title="hweining">
|
||||
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
|
||||
</a>
|
||||
<a href="https://github.com/joyfully-W" title="joyfully-W">
|
||||
<img src="https://avatars.githubusercontent.com/u/32212924?v=4" width="42;" alt="joyfully-W"/>
|
||||
</a>
|
||||
<a href="https://github.com/k983551019" title="k983551019">
|
||||
<img src="https://avatars.githubusercontent.com/u/48147837?v=4" width="42;" alt="k983551019"/>
|
||||
</a>
|
||||
@ -268,9 +376,15 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/mancuoj" title="mancuoj">
|
||||
<img src="https://avatars.githubusercontent.com/u/45707684?v=4" width="42;" alt="mancuoj"/>
|
||||
</a>
|
||||
<a href="https://github.com/miclon-dev" title="miclon-dev">
|
||||
<img src="https://avatars.githubusercontent.com/u/111753685?v=4" width="42;" alt="miclon-dev"/>
|
||||
</a>
|
||||
<a href="https://github.com/onewesong" title="onewesong">
|
||||
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>
|
||||
</a>
|
||||
<a href="https://github.com/phygerr" title="phygerr">
|
||||
<img src="https://avatars.githubusercontent.com/u/42068889?v=4" width="42;" alt="phygerr"/>
|
||||
</a>
|
||||
<a href="https://github.com/Mowmowj" title="shelton">
|
||||
<img src="https://avatars.githubusercontent.com/u/24759562?v=4" width="42;" alt="shelton"/>
|
||||
</a>
|
||||
@ -283,9 +397,6 @@ REF_LABEL=网站首页
|
||||
<a href="https://github.com/zxx-457" title="zxx-457">
|
||||
<img src="https://avatars.githubusercontent.com/u/114141362?v=4" width="42;" alt="zxx-457"/>
|
||||
</a>
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/lvzhenbo" title="吕振波">
|
||||
<img src="https://avatars.githubusercontent.com/u/32427677?v=4" width="42;" alt="吕振波"/>
|
||||
</a>
|
||||
|
98
README.md
@ -24,6 +24,7 @@ Quick Reference
|
||||
[C#](./docs/cs.md)<!--rehype:style=background: rgb(6 147 13);&class=contributing-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51);&class=contributing tag&data-lang=Python-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9);&class=contributing-->
|
||||
[Flask](./docs/flask.md)<!--rehype:style=background: rgb(210 168 255);&class=contributing tag&data-lang=Python-->
|
||||
[Flutter](./docs/flutter.md)<!--rehype:style=background: rgb(150 220 254);&class=contributing tag&data-lang=Dart-->
|
||||
[Gitlab CI/CD](./docs/gitlab-ci.md)<!--rehype:style=background: rgb(226 67 41);&class=contributing-->
|
||||
[LaTeX](./docs/latex.md)<!--rehype:style=background: rgb(0 128 128);&class=contributing-->
|
||||
@ -44,15 +45,17 @@ Quick Reference
|
||||
[Dart](./docs/dart.md)<!--rehype:style=background: rgb(64 196 255);-->
|
||||
[Docker](./docs/docker.md)<!--rehype:style=background: rgb(72 143 223);-->
|
||||
[Dockerfile](./docs/dockerfile.md)<!--rehype:style=background: rgb(0 72 153);&class=tag&data-lang=Docker-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51);&class=contributing tag&data-lang=Python-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51);&class=contributing tag&data-lang=Python-->
|
||||
[Flask](./docs/flask.md)<!--rehype:style=background: rgb(210 168 255);&class=contributing tag&data-lang=Python-->
|
||||
[Flutter](./docs/flutter.md)<!--rehype:style=background: rgb(150 220 254);&class=contributing tag&data-lang=Dart-->
|
||||
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193);-->
|
||||
[GraphQL](./docs/graphql.md)<!--rehype:style=background: rgb(214 66 146);-->
|
||||
[INI](./docs/ini.md)<!--rehype:style=background: rgb(57 59 60);-->
|
||||
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60);-->
|
||||
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49);&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Julia](./docs/julia.md)<!--rehype:style=background: rgb(211 55 49);&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Julia](./docs/julia.md)<!--rehype:style=background: rgb(26 188 156);&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Kotlin](./docs/kotlin.md)<!--rehype:style=background: rgb(211 55 49);&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Kubernetes](./docs/kubernetes.md)<!--rehype:style=background: rgb(51 113 227);&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[LaTeX](./docs/latex.md)<!--rehype:style=background: rgb(0 128 128);&class=contributing-->
|
||||
[Laravel 8](./docs/laravel.md)<!--rehype:style=background: rgb(249 50 44);&class=contributing tag&data-lang=PHP-->
|
||||
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156);-->
|
||||
@ -71,6 +74,7 @@ Quick Reference
|
||||
|
||||
## 前端
|
||||
|
||||
[前端导航](./docs/feds.md)<!--rehype:style=background: rgb(35 115 205);&class=tag&data-lang=导航-->
|
||||
[CSS 3](./docs/css.md)<!--rehype:style=background: rgb(35 115 205);&class=tag&data-lang=CSS-->
|
||||
[Electron](./docs/electron.md)<!--rehype:style=background: rgb(0 72 153);-->
|
||||
[Emmet](./docs/emmet.md)<!--rehype:style=background: rgb(122 203 23);-->
|
||||
@ -80,12 +84,15 @@ Quick Reference
|
||||
[Sass](./docs/sass.md)<!--rehype:style=background: rgb(207 100 154);&class=tag&data-lang=CSS-->
|
||||
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39);-->
|
||||
[JavaScript](./docs/javascript.md)<!--rehype:style=background: rgb(203 183 31);-->
|
||||
[jQuery](./docs/jquery.md)<!--rehype:style=background: rgb(203 183 31);-->
|
||||
[Less.js](./docs/lessjs.md)<!--rehype:style=background: rgb(29 54 93);&class=tag&data-lang=CSS-->
|
||||
[Next.js](./docs/nextjs.md)<!--rehype:style=background: rgb(0 0 0);&class=tag&data-lang=React-->
|
||||
[React](./docs/react.md)<!--rehype:style=background: rgb(34 143 173);-->
|
||||
[React Router](./docs/reactrouter.md)<!--rehype:style=background: rgb(244 66 79);&class=tag&data-lang=React-->
|
||||
[React Native](./docs/react-native.md)<!--rehype:style=background: rgb(34 143 173);&class=tag&data-lang=React-->
|
||||
[RegEx 正则表达式](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155);-->
|
||||
[TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198);-->
|
||||
[Tailwind CSS](./docs/tailwindcss.md)<!--rehype:style=background: rgb(49 120 198);-->
|
||||
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131);-->
|
||||
[Vue 3](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131);&class=contributing-->
|
||||
[</> htmx](./docs/htmx.md)<!--rehype:style=background: rgb(52 101 164);&class=contributing-->
|
||||
@ -116,6 +123,7 @@ Quick Reference
|
||||
|
||||
## 命令
|
||||
|
||||
[ADB, Android Debug Bridge](./docs/adb.md)<!--rehype:style=background: rgb(238 0 0);&class=contributing tag&data-lang=Android&data-info=👆看看还缺点儿什么?-->
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(238 0 0);&class=contributing tag&data-lang=RedHat&data-info=👆看看还缺点儿什么?-->
|
||||
[Awk](./docs/awk.md)<!--rehype:style=background: rgb(16 185 129);-->
|
||||
[Conan](./docs/conan.md)<!--rehype:style=background: rgb(0 193 9);&class=tag&data-lang=C/C++-->
|
||||
@ -140,6 +148,7 @@ Quick Reference
|
||||
[Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135);-->
|
||||
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129);-->
|
||||
[OpenSSL](./docs/openssl.md)<!--rehype:style=background: rgb(114 20 18);-->
|
||||
[ps](./docs/ps.md)<!--rehype:style=background: rgb(99 99 99);-->
|
||||
[Systemd](./docs/systemd.md)<!--rehype:style=background: rgb(16 185 129);-->
|
||||
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99);-->
|
||||
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99);-->
|
||||
@ -154,6 +163,7 @@ Quick Reference
|
||||
## 数据库
|
||||
|
||||
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(1 117 143);&class=tag&data-lang=SQL-->
|
||||
[MongoDB](./docs/mongodb.md)<!--rehype:style=background: rgb(0 237 100);-->
|
||||
[Oracle](./docs/oracle.md)<!--rehype:style=background: rgb(255 0 0);&class=tag&data-lang=SQL-->
|
||||
[PostgreSQL](./docs/postgres.md)<!--rehype:style=background: rgb(43 109 163);&class=tag&data-lang=SQL-->
|
||||
[Redis](./docs/redis.md)<!--rehype:style=background: rgb(198 47 44);-->
|
||||
@ -169,6 +179,8 @@ Quick Reference
|
||||
[Gmail](./docs/gmail.md)<!--rehype:style=background: rgb(234 67 54);-->
|
||||
[Gitlab](./docs/gitlab.md)<!--rehype:style=background: rgb(226 67 41);-->
|
||||
[Google Chrome](./docs/google-chrome.md)<!--rehype:style=background: rgb(29 116 232);-->
|
||||
[IntelliJ IDEA](./docs/intelli-j-idea.md)<!--rehype:style=background: rgb(223 148 0);&class=tag&data-lang=Java-->
|
||||
[PyCharm](./docs/pycharm.md)<!--rehype:style=background: rgb(36 215 137);&class=tag&data-lang=Python-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0);&class=tag&data-lang=macOS-->
|
||||
[Sublime Text](./docs/sublime-text.md)<!--rehype:style=background: rgb(223 148 0);-->
|
||||
[VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230);-->
|
||||
@ -215,42 +227,57 @@ Quick Reference
|
||||
<a href="https://github.com/mofelee" title="mofelee">
|
||||
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
|
||||
</a>
|
||||
<a href="https://github.com/Alex-Programer" title="Alex">
|
||||
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
|
||||
</a>
|
||||
<a href="https://github.com/JeffersonHuang" title="Jefferson">
|
||||
<img src="https://avatars.githubusercontent.com/u/47512530?v=4" width="42;" alt="Jefferson"/>
|
||||
</a>
|
||||
<a href="https://github.com/Alex-Programer" title="Alex">
|
||||
<img src="https://avatars.githubusercontent.com/u/115539090?v=4" width="42;" alt="Alex"/>
|
||||
</a>
|
||||
<a href="https://github.com/expoli" title="expoli">
|
||||
<img src="https://avatars.githubusercontent.com/u/31023767?v=4" width="42;" alt="expoli"/>
|
||||
</a>
|
||||
<a href="https://github.com/LiuYuan-SHU" title="Liuyuan">
|
||||
<img src="https://avatars.githubusercontent.com/u/96400967?v=4" width="42;" alt="Liuyuan"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/sjh42" title="42:p">
|
||||
<img src="https://avatars.githubusercontent.com/u/34529275?v=4" width="42;" alt="42:p"/>
|
||||
</a>
|
||||
<a href="https://github.com/LufsX" title="LufsX">
|
||||
<img src="https://avatars.githubusercontent.com/u/33221883?v=4" width="42;" alt="LufsX"/>
|
||||
</a>
|
||||
<a href="https://github.com/1834423612" title="kjch">
|
||||
<img src="https://avatars.githubusercontent.com/u/49981661?v=4" width="42;" alt="kjch"/>
|
||||
</a>
|
||||
<a href="https://github.com/pangxiaoli" title="pangxiaoli">
|
||||
<img src="https://avatars.githubusercontent.com/u/54620953?v=4" width="42;" alt="pangxiaoli"/>
|
||||
</a>
|
||||
<a href="https://github.com/partoneplay" title="partoneplay">
|
||||
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
|
||||
</a>
|
||||
<a href="https://github.com/ryanhex53" title="ryanhex53">
|
||||
<img src="https://avatars.githubusercontent.com/u/360426?v=4" width="42;" alt="ryanhex53"/>
|
||||
</a>
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/catcto" title="喵仙人">
|
||||
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/13812700839" title="花殇">
|
||||
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇"/>
|
||||
</a>
|
||||
<a href="https://github.com/Smartdousha" title="Anko">
|
||||
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
|
||||
<a href="https://github.com/dousha0w0" title="dousha0w0">
|
||||
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="dousha0w0"/>
|
||||
</a>
|
||||
<a href="https://github.com/Brid9e" title="Brid9e">
|
||||
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Brid9e"/>
|
||||
</a>
|
||||
<a href="https://github.com/ch3nnn" title="Ch3nnn">
|
||||
<img src="https://avatars.githubusercontent.com/u/40114564?v=4" width="42;" alt="Ch3nnn"/>
|
||||
</a>
|
||||
<a href="https://github.com/CharlotteZeng" title="hanchZ">
|
||||
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="hanchZ"/>
|
||||
</a>
|
||||
@ -263,21 +290,39 @@ Quick Reference
|
||||
<a href="https://github.com/eeeeeio" title="EEEEE">
|
||||
<img src="https://avatars.githubusercontent.com/u/20723545?v=4" width="42;" alt="EEEEE"/>
|
||||
</a>
|
||||
<a href="https://github.com/Ding-Kyoma" title="HooinKyoma">
|
||||
<img src="https://avatars.githubusercontent.com/u/44542198?v=4" width="42;" alt="HooinKyoma"/>
|
||||
</a>
|
||||
<a href="https://github.com/jasnzhuang" title="Jason Zhuang">
|
||||
<img src="https://avatars.githubusercontent.com/u/16612921?v=4" width="42;" alt="Jason Zhuang"/>
|
||||
</a>
|
||||
<a href="https://github.com/JetSquirrel" title="JetSquirrel">
|
||||
<img src="https://avatars.githubusercontent.com/u/20291255?v=4" width="42;" alt="JetSquirrel"/>
|
||||
</a>
|
||||
<a href="https://github.com/LightQuanta" title="Light_Quanta">
|
||||
<img src="https://avatars.githubusercontent.com/u/18213217?v=4" width="42;" alt="Light_Quanta"/>
|
||||
</a>
|
||||
<a href="https://github.com/Lihuagreek" title="Lihuagreek">
|
||||
<img src="https://avatars.githubusercontent.com/u/51040740?v=4" width="42;" alt="Lihuagreek"/>
|
||||
</a>
|
||||
<a href="https://github.com/likeshop-github" title="LikeShop技术社区">
|
||||
<img src="https://avatars.githubusercontent.com/u/77180968?v=4" width="42;" alt="LikeShop技术社区"/>
|
||||
</a>
|
||||
<a href="https://github.com/mariuszmichalowski" title="Mariusz Michalowski">
|
||||
<img src="https://avatars.githubusercontent.com/u/92091891?v=4" width="42;" alt="Mariusz Michalowski"/>
|
||||
</a>
|
||||
<a href="https://github.com/HanaNoryu" title="Noryu">
|
||||
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
|
||||
</a>
|
||||
<a href="https://github.com/PipecraftNet" title="Pipecraft">
|
||||
<img src="https://avatars.githubusercontent.com/u/88728670?v=4" width="42;" alt="Pipecraft"/>
|
||||
</a>
|
||||
<a href="https://github.com/QDelta" title="QDelta">
|
||||
<img src="https://avatars.githubusercontent.com/u/60222316?v=4" width="42;" alt="QDelta"/>
|
||||
</a>
|
||||
<a href="https://github.com/qinxiongzhou" title="Ryan Zhou">
|
||||
<img src="https://avatars.githubusercontent.com/u/33239096?v=4" width="42;" alt="Ryan Zhou"/>
|
||||
</a>
|
||||
<a href="https://github.com/whb1998a" title="WHB">
|
||||
<img src="https://avatars.githubusercontent.com/u/44045064?v=4" width="42;" alt="WHB"/>
|
||||
</a>
|
||||
@ -296,6 +341,12 @@ Quick Reference
|
||||
<a href="https://github.com/cool9203" title="cool9203">
|
||||
<img src="https://avatars.githubusercontent.com/u/29609607?v=4" width="42;" alt="cool9203"/>
|
||||
</a>
|
||||
<a href="https://github.com/fjqz177" title="fjqz177">
|
||||
<img src="https://avatars.githubusercontent.com/u/83070583?v=4" width="42;" alt="fjqz177"/>
|
||||
</a>
|
||||
<a href="https://github.com/gi-b716" title="gi-b716">
|
||||
<img src="https://avatars.githubusercontent.com/u/78394473?v=4" width="42;" alt="gi-b716"/>
|
||||
</a>
|
||||
<a href="https://github.com/godotc" title="godotc">
|
||||
<img src="https://avatars.githubusercontent.com/u/79260851?v=4" width="42;" alt="godotc"/>
|
||||
</a>
|
||||
@ -308,6 +359,9 @@ Quick Reference
|
||||
<a href="https://github.com/hweining" title="hweining">
|
||||
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
|
||||
</a>
|
||||
<a href="https://github.com/joyfully-W" title="joyfully-W">
|
||||
<img src="https://avatars.githubusercontent.com/u/32212924?v=4" width="42;" alt="joyfully-W"/>
|
||||
</a>
|
||||
<a href="https://github.com/k983551019" title="k983551019">
|
||||
<img src="https://avatars.githubusercontent.com/u/48147837?v=4" width="42;" alt="k983551019"/>
|
||||
</a>
|
||||
@ -329,9 +383,15 @@ Quick Reference
|
||||
<a href="https://github.com/mancuoj" title="mancuoj">
|
||||
<img src="https://avatars.githubusercontent.com/u/45707684?v=4" width="42;" alt="mancuoj"/>
|
||||
</a>
|
||||
<a href="https://github.com/miclon-dev" title="miclon-dev">
|
||||
<img src="https://avatars.githubusercontent.com/u/111753685?v=4" width="42;" alt="miclon-dev"/>
|
||||
</a>
|
||||
<a href="https://github.com/onewesong" title="onewesong">
|
||||
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>
|
||||
</a>
|
||||
<a href="https://github.com/phygerr" title="phygerr">
|
||||
<img src="https://avatars.githubusercontent.com/u/42068889?v=4" width="42;" alt="phygerr"/>
|
||||
</a>
|
||||
<a href="https://github.com/Mowmowj" title="shelton">
|
||||
<img src="https://avatars.githubusercontent.com/u/24759562?v=4" width="42;" alt="shelton"/>
|
||||
</a>
|
||||
@ -344,9 +404,6 @@ Quick Reference
|
||||
<a href="https://github.com/zxx-457" title="zxx-457">
|
||||
<img src="https://avatars.githubusercontent.com/u/114141362?v=4" width="42;" alt="zxx-457"/>
|
||||
</a>
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/lvzhenbo" title="吕振波">
|
||||
<img src="https://avatars.githubusercontent.com/u/32427677?v=4" width="42;" alt="吕振波"/>
|
||||
</a>
|
||||
@ -376,18 +433,25 @@ Quick Reference
|
||||
[if010.com](https://quickref.if010.com/)<!--rehype:target=_blank-->
|
||||
[pipecraft.net](https://quickref.pipecraft.net/)<!--rehype:target=_blank&class=contributing&data-info=👆需要梯子-->
|
||||
[isteed.cc](https://ref.isteed.cc/)<!--rehype:target=_blank-->
|
||||
[cas-air.cn](https://www.ccommunity.cas-air.cn/index.html)<!--rehype:target=_blank&class=contributing&data-info=👆非镜像,另起炉灶-->
|
||||
[1han.wiki](https://code.1han.wiki/)<!--rehype:target=_blank-->
|
||||
[linzhe.top](https://linzhe.top/)<!--rehype:target=_blank-->
|
||||
[xushanxiang.com](https://xushanxiang.com/ref/)<!--rehype:target=_blank-->
|
||||
[winnerzr01.github.io](https://winnerzr01.github.io/Quick-Reference/index.html)<!--rehype:target=_blank&class=contributing&data-info=👆需要梯子-->
|
||||
[isteed.cc](https://ref.isteed.cc/)<!--rehype:target=_blank-->
|
||||
[hestudio.org](https://quickref.hestudio.org)<!--rehype:target=_blank-->
|
||||
[hestudio.org](https://quickref.hestudio.org)<!--rehype:target=_blank&class=contributing&data-info=👆整点自动同步-->
|
||||
[surcode.cn](https://ref.surcode.cn)<!--rehype:target=_blank-->
|
||||
[hestudio.org](https://quickref.hestudio.org)<!--rehype:target=_blank-->
|
||||
[cms.im](https://quickref.cms.im/)<!--rehype:target=_blank-->
|
||||
[nuomiphp.com](https://reference.tool.nuomiphp.com/)<!--rehype:target=_blank-->
|
||||
[eryajf.net](https://ref.eryajf.net/)<!--rehype:target=_blank-->
|
||||
[eryajf.net](https://ref.eryajf.net/)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
[kjchmc.cn](https://ref.kjchmc.cn/)<!--rehype:target=_blank&class=contributing&data-info=👆实时同步,多线路-->
|
||||
[likeadmin.cn](https://www.likeadmin.cn/quickref/)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
[qiubit.cc](http://ref.qiubit.cc)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
[aoh.cc](https://aoh.cc/)<!--rehype:target=_blank-->
|
||||
[reference.code05.com](https://reference.code05.com/)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
[kyoma.top](https://reference.kyoma.top/)<!--rehype:target=_blank&class=contributing&data-info=👆实时同步-->
|
||||
[quickreference.pages.dev](https://quickreference.pages.dev/)<!--rehype:target=_blank-->
|
||||
[code05.com](https://reference.code05.com/)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
[xhfun.cn](https://ref.xhfun.cn/)<!--rehype:target=_blank&class=contributing&data-info=👆每天自动同步-->
|
||||
<!--rehype:class=home-card home-links-->
|
||||
|
||||
如果你有资源,可以很方便部署 web 版,这非常简单,只需要克隆 [gh-pages](https://github.com/jaywcjlove/reference/tree/gh-pages) 分支代码到你的静态服务就可以了,还可以使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版。
|
||||
|
3
assets/adb.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16" height="1em" width="1em">
|
||||
<path d="m10.213 1.471.691-1.26c.046-.083.03-.147-.048-.192-.085-.038-.15-.019-.195.058l-.7 1.27A4.832 4.832 0 0 0 8.005.941c-.688 0-1.34.135-1.956.404l-.7-1.27C5.303 0 5.239-.018 5.154.02c-.078.046-.094.11-.049.193l.691 1.259a4.25 4.25 0 0 0-1.673 1.476A3.697 3.697 0 0 0 3.5 5.02h9c0-.75-.208-1.44-.623-2.072a4.266 4.266 0 0 0-1.664-1.476ZM6.22 3.303a.367.367 0 0 1-.267.11.35.35 0 0 1-.263-.11.366.366 0 0 1-.107-.264.37.37 0 0 1 .107-.265.351.351 0 0 1 .263-.11c.103 0 .193.037.267.11a.36.36 0 0 1 .112.265.36.36 0 0 1-.112.264Zm4.101 0a.351.351 0 0 1-.262.11.366.366 0 0 1-.268-.11.358.358 0 0 1-.112-.264c0-.103.037-.191.112-.265a.367.367 0 0 1 .268-.11c.104 0 .19.037.262.11a.367.367 0 0 1 .107.265c0 .102-.035.19-.107.264ZM3.5 11.77c0 .294.104.544.311.75.208.204.46.307.76.307h.758l.01 2.182c0 .276.097.51.292.703a.961.961 0 0 0 .7.288.973.973 0 0 0 .71-.288.95.95 0 0 0 .292-.703v-2.182h1.343v2.182c0 .276.097.51.292.703a.972.972 0 0 0 .71.288.973.973 0 0 0 .71-.288.95.95 0 0 0 .292-.703v-2.182h.76c.291 0 .54-.103.749-.308.207-.205.311-.455.311-.75V5.365h-9v6.404Zm10.495-6.587a.983.983 0 0 0-.702.278.91.91 0 0 0-.293.685v4.063c0 .271.098.501.293.69a.97.97 0 0 0 .702.284c.28 0 .517-.095.712-.284a.924.924 0 0 0 .293-.69V6.146a.91.91 0 0 0-.293-.685.995.995 0 0 0-.712-.278Zm-12.702.283a.985.985 0 0 1 .712-.283c.273 0 .507.094.702.283a.913.913 0 0 1 .293.68v4.063a.932.932 0 0 1-.288.69.97.97 0 0 1-.707.284.986.986 0 0 1-.712-.284.924.924 0 0 1-.293-.69V6.146c0-.264.098-.491.293-.68Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
8
assets/flask.svg
Normal file
After Width: | Height: | Size: 7.2 KiB |
3
assets/intelli-j-idea.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 32 32" height="1em" width="1em">
|
||||
<path d="M0 0v32h32V0zm4.964 4.145h6.667v2.448H9.776v8.371h1.855v2.443H4.964v-2.443h1.927V6.593H4.964zm14.739 0h2.964v8.667c0 .819-.073 1.485-.297 2.079a4.002 4.002 0 0 1-.963 1.479c-.371.371-.885.745-1.48.891a5.192 5.192 0 0 1-1.927.371c-1.036 0-1.927-.224-2.593-.595a6.403 6.403 0 0 1-1.704-1.405l1.855-2.073c.369.443.74.74 1.109.964.369.219.812.369 1.26.369.521 0 .959-.151 1.333-.521.292-.369.443-.891.443-1.703zM2.964 26h12v2h-12z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 554 B |
3
assets/jquery.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
|
||||
<path d="M1.525 5.87c-2.126 3.054-1.862 7.026-.237 10.269.037.079.078.154.118.229.023.052.049.1.077.15.013.027.031.056.047.082.026.052.054.102.081.152l.157.266c.03.049.057.097.09.146.056.094.12.187.178.281.026.04.05.078.079.117a6.368 6.368 0 0 0 .31.445c.078.107.156.211.24.315.027.038.058.076.086.115l.22.269c.028.03.055.067.084.099.098.118.202.233.306.35l.005.006a3.134 3.134 0 0 0 .425.44c.08.083.16.165.245.245l.101.097c.111.105.223.209.34.309.002 0 .003.002.005.003l.057.05c.102.089.205.178.31.26l.125.105c.085.068.174.133.26.2l.137.105c.093.07.192.139.287.207.035.025.07.05.106.073l.03.023.28.185.12.08c.148.094.294.184.44.272.041.02.084.044.123.068.108.062.22.125.329.183.06.034.122.063.184.094.075.042.153.083.234.125a.324.324 0 0 1 .056.023c.033.015.064.031.096.047.12.06.245.118.375.175.024.01.05.02.076.034.144.063.289.123.438.182.034.01.07.027.105.04.135.051.274.103.411.152l.05.018c.154.052.305.102.46.15.036.01.073.023.111.033.16.048.314.105.474.137 10.273 1.872 13.258-6.177 13.258-6.177-2.508 3.266-6.958 4.127-11.174 3.169-.156-.036-.312-.086-.47-.132a13.539 13.539 0 0 1-.567-.182l-.062-.024c-.136-.046-.267-.097-.4-.148a1.615 1.615 0 0 0-.11-.04c-.148-.06-.29-.121-.433-.184-.031-.01-.057-.024-.088-.036a23.44 23.44 0 0 1-.362-.17 1.485 1.485 0 0 1-.106-.052c-.094-.044-.188-.095-.28-.143a3.947 3.947 0 0 1-.187-.096c-.114-.06-.227-.125-.34-.187-.034-.024-.073-.044-.112-.066a15.922 15.922 0 0 1-.439-.27 2.107 2.107 0 0 1-.118-.078 6.01 6.01 0 0 1-.312-.207c-.035-.023-.067-.048-.103-.073a9.553 9.553 0 0 1-.295-.212c-.042-.034-.087-.066-.132-.1-.088-.07-.177-.135-.265-.208l-.118-.095a10.593 10.593 0 0 1-.335-.28.258.258 0 0 0-.037-.031l-.347-.316-.1-.094c-.082-.084-.166-.164-.25-.246l-.098-.1a9.081 9.081 0 0 1-.309-.323l-.015-.016c-.106-.116-.21-.235-.313-.355-.027-.03-.053-.064-.08-.097l-.227-.277a21.275 21.275 0 0 1-.34-.449C2.152 11.79 1.306 7.384 3.177 3.771m4.943-.473c-1.54 2.211-1.454 5.169-.254 7.508a9.111 9.111 0 0 0 .678 1.133c.23.33.484.721.793.988.107.122.223.24.344.36l.09.09c.114.11.232.217.35.325l.016.013a9.867 9.867 0 0 0 .414.342c.034.023.063.05.096.073.14.108.282.212.428.316l.015.009c.062.045.128.086.198.13.028.018.06.042.09.06.106.068.21.132.318.197.017.007.032.016.048.023.09.055.188.108.282.157.033.02.065.035.1.054.066.033.132.068.197.102l.032.014c.135.067.273.129.408.19.034.014.063.025.092.039.111.048.224.094.336.137.05.017.097.037.144.052.102.038.21.073.31.108l.14.045c.147.045.295.104.449.13C22.164 17.206 24 11.098 24 11.098c-1.653 2.38-4.852 3.513-8.261 2.628a8.04 8.04 0 0 1-.449-.13c-.048-.014-.09-.029-.136-.043-.104-.036-.211-.07-.312-.109l-.144-.054c-.113-.045-.227-.087-.336-.135-.034-.015-.065-.025-.091-.04-.14-.063-.281-.125-.418-.192l-.206-.107-.119-.06a5.673 5.673 0 0 1-.265-.15.62.62 0 0 1-.062-.035c-.106-.066-.217-.13-.318-.198-.034-.019-.065-.042-.097-.062l-.208-.136c-.144-.1-.285-.208-.428-.313-.032-.029-.063-.053-.094-.079-1.499-1.178-2.681-2.79-3.242-4.613-.59-1.897-.46-4.023.56-5.75m4.292-.147c-.909 1.334-.996 2.99-.37 4.46.665 1.563 2.024 2.79 3.608 3.37.065.025.128.046.196.07l.088.027c.092.03.185.063.28.084 4.381.845 5.567-2.25 5.886-2.704-1.043 1.498-2.792 1.857-4.938 1.335a4.85 4.85 0 0 1-.516-.16 6.352 6.352 0 0 1-.618-.254 6.53 6.53 0 0 1-1.082-.66c-1.922-1.457-3.113-4.236-1.859-6.5"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
5
assets/kubernetes.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" height="1em" width="1em">
|
||||
<path d="m10.013 13.738-2.254.387a4.475 4.475 0 0 0 1.753 2.231l.865-2.095a.27.27 0 0 0 .022-.228c-.022-.18-.204-.295-.386-.295zm.865-2.914c.205 0 .387-.159.387-.364l.114-2.277-.456.091a4.516 4.516 0 0 0-2.118 1.162l1.89 1.343c.069.022.115.045.183.045zm-1.002 1.48a.366.366 0 0 0-.045-.524l-1.685-1.503a4.797 4.797 0 0 0-.661 2.778l2.209-.637c.091-.023.137-.046.182-.114zm1.457.797.616.296.614-.296.16-.661-.433-.546h-.683l-.433.546zm1.344-2.436c.114.159.341.182.5.091l1.867-1.32a4.286 4.286 0 0 0-2.573-1.23l.137 2.3a.215.215 0 0 0 .069.159z"/>
|
||||
<path d="m21.944 14.103-1.73-7.446c-.113-.364-.387-.66-.729-.842L12.541 2.49c-.182-.091-.387-.114-.569-.114s-.387 0-.569.045L4.457 5.769a1.22 1.22 0 0 0-.683.842l-1.708 7.492c-.068.387.023.774.25 1.093l4.805 5.943c.273.273.66.456 1.047.479h7.651c.41.045.797-.137 1.048-.479l4.805-5.943c.227-.319.318-.706.272-1.093zm-2.845.501c-.046 0-.068 0-.114-.023-.022-.023-.022-.023-.045-.023-.046 0-.068-.022-.092-.022-.091-.023-.159-.068-.25-.114a.32.32 0 0 1-.137-.045h-.022a3.91 3.91 0 0 0-.729-.205h-.022a.26.26 0 0 0-.182.068s0 .023-.023.023l-.183-.024a5.628 5.628 0 0 1-2.46 3.097l.068.182s-.022 0-.022.022a.264.264 0 0 0-.022.228c.091.228.205.455.364.66v.045a.396.396 0 0 1 .091.114.81.81 0 0 1 .159.228c.023.022.046.045.046.068 0 0 .022 0 .022.022a.582.582 0 0 1 .023.342.38.38 0 0 1-.205.25c-.068.022-.114.045-.183.045a.511.511 0 0 1-.433-.273c-.022 0-.022-.022-.022-.022-.022-.023-.022-.045-.046-.068-.045-.068-.068-.159-.091-.25l-.046-.137v-.022a3.816 3.816 0 0 0-.296-.706.353.353 0 0 0-.182-.137c0-.023 0-.023-.023-.023l-.091-.159c-.228.068-.479.159-.729.205-.41.114-.82.159-1.229.159a5.368 5.368 0 0 1-1.981-.364l-.091.182c0 .023 0 .023-.023.023a.35.35 0 0 0-.182.137c-.114.228-.228.455-.296.706l-.045.137c-.023.091-.068.159-.091.25-.022.023-.045.045-.045.068-.023 0-.023.022-.023.022a.508.508 0 0 1-.433.273.434.434 0 0 1-.159-.045.469.469 0 0 1-.182-.615c.023 0 .023-.023.023-.023.022-.023.022-.045.045-.068.068-.091.114-.182.159-.228s.068-.068.091-.114v-.023a3.73 3.73 0 0 0 .364-.66.268.268 0 0 0-.023-.228s-.022 0-.022-.022l.114-.16a3.578 3.578 0 0 1-.615-.41 5.493 5.493 0 0 1-1.867-2.664l-.205.022s0-.022-.023-.022a.256.256 0 0 0-.182-.068h-.022a4.015 4.015 0 0 0-.751.205h-.024c-.045 0-.091.023-.137.046-.068.022-.159.068-.25.091-.022 0-.091-.022-.091 0 0 .023 0 .023-.023.023-.045.023-.068.023-.114.023a.424.424 0 0 1-.456-.319.445.445 0 0 1 .364-.524c.023-.023.023-.023.046-.023.045 0 .068-.022.091-.022.091 0 .182-.023.273-.023.045-.022.091-.022.137-.022a4.2 4.2 0 0 0 .774-.137c.068-.046.137-.091.16-.16 0 0 .022 0 .022-.022l.182-.046c-.205-1.298.091-2.618.797-3.734.022-.045.045-.068.068-.114l-.131-.132a.106.106 0 0 1-.004.019v-.023l.004.004c.01-.065-.031-.145-.072-.186-.182-.182-.41-.319-.638-.455l-.136-.069a2.587 2.587 0 0 1-.251-.136c-.022 0-.068-.045-.068-.045s0-.023-.022-.023a.49.49 0 0 1-.092-.639c.068-.114.182-.159.319-.159a.54.54 0 0 1 .319.114l.023.023c.022.022.045.022.068.045.068.069.114.137.182.205.023.022.068.045.091.091.159.182.364.364.569.524.045.022.091.045.137.045.045 0 .068-.023.091-.023h.023l.137.091a5.426 5.426 0 0 1 2.801-1.594c.273-.046.523-.091.774-.114l.023-.182v-.045c.068-.045.091-.114.114-.182 0-.273 0-.524-.045-.774v-.023c0-.045 0-.091-.023-.137a1.129 1.129 0 0 1-.045-.273v-.113c0-.114.045-.228.137-.319.114-.114.25-.182.387-.159a.45.45 0 0 1 .387.478v.137c-.023.091-.023.182-.045.273 0 .045-.023.091-.023.136v.023c-.048.273-.048.524-.048.774.023.068.045.136.114.182v-.023l.023.182a5.84 5.84 0 0 1 2.96 1.184c.183.182.387.364.569.546l.183-.114h.022c.022.023.068.023.091.023.046 0 .091-.023.137-.045.205-.137.41-.319.569-.501.022-.023.068-.046.091-.091.046-.068.114-.137.183-.205.022 0 .045-.022.068-.045l.022-.023a.546.546 0 0 1 .318-.114c.114 0 .251.068.319.16.159.205.113.478-.091.637 0 .023.022.023 0 .046-.023.022-.046.022-.068.045-.092.045-.16.091-.251.137l-.137.068a4.104 4.104 0 0 0-.638.455c-.045.046-.068.137-.068.205v.023l-.136.137c.364.569.638 1.207.797 1.867.137.66.182 1.343.091 2.003l.182.046a.278.278 0 0 0 .16.159c.25.068.523.114.773.137h.023a.297.297 0 0 0 .137.022c.091 0 .182 0 .272.023.046 0 .092 0 .092.023 0 .022.022.022.045.022a.537.537 0 0 1 .41.479.49.49 0 0 1-.453.32z"/>
|
||||
<path d="M12.085 14.718a.352.352 0 0 0-.455.091l-1.116 2.027c.456.136.957.228 1.435.228.341 0 .66-.045.979-.114.159-.045.296-.068.433-.091l-1.093-1.981c-.069-.069-.115-.115-.183-.16zm3.644-4.441-1.708 1.548a.36.36 0 0 0-.091.16c-.046.205.068.41.273.455l2.163.615a4.375 4.375 0 0 0-.092-1.435 4.63 4.63 0 0 0-.545-1.343zm-2.073 3.484a.371.371 0 0 0-.205.433l.889 2.141a4.366 4.366 0 0 0 1.366-1.366c.182-.25.318-.547.433-.865l-2.277-.387a.634.634 0 0 0-.206.044z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
3
assets/mongodb.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 120 257" fill="none" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="M82.323 28.644C71.537 15.847 62.249 2.85 60.35.15c-.2-.2-.5-.2-.7 0-1.897 2.7-11.185 15.697-21.971 28.494C-54.902 146.721 52.26 226.406 52.26 226.406l.9.6C53.958 239.303 55.955 257 55.955 257h7.99s1.998-17.597 2.797-29.994l.899-.7c.1.1 107.263-79.585 14.68-197.662ZM59.95 224.606s-4.793-4.099-6.092-6.198v-.201l5.793-128.574c0-.4.6-.4.6 0l5.792 128.574v.201c-1.299 2.099-6.093 6.198-6.093 6.198Z" fill="currentColor"/>
|
||||
</svg>
|
After Width: | Height: | Size: 537 B |
3
assets/pycharm.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
|
||||
<path d="M7.833 6.666v-.055c0-1-.667-1.5-1.778-1.5H4.389v3.055h1.723c1.111 0 1.721-.666 1.721-1.5zM0 0v24h24V0H0zm2.223 3.167h4c2.389 0 3.833 1.389 3.833 3.445v.055c0 2.278-1.778 3.5-4.001 3.5H4.389v2.945H2.223V3.167zM11.277 21h-9v-1.5h9V21zm4.779-7.777c-2.944.055-5.111-2.223-5.111-5.057C10.944 5.333 13.056 3 16.111 3c1.889 0 3 .611 3.944 1.556l-1.389 1.61c-.778-.722-1.556-1.111-2.556-1.111-1.658 0-2.873 1.375-2.887 3.084.014 1.709 1.174 3.083 2.887 3.083 1.111 0 1.833-.445 2.61-1.167l1.39 1.389c-.999 1.112-2.166 1.779-4.054 1.779z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 656 B |
4
assets/reactrouter.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg viewBox="0 0 256 140" fill="currentColor" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid" height="1em" width="1em">
|
||||
<path d="M78.066 92.588c12.818 0 23.209-10.391 23.209-23.21 0-12.817-10.391-23.208-23.21-23.208-12.817 0-23.208 10.39-23.208 23.209 0 12.818 10.391 23.209 23.209 23.209Zm-54.857 46.417c12.818 0 23.209-10.39 23.209-23.209 0-12.817-10.391-23.208-23.21-23.208C10.392 92.588 0 102.978 0 115.796c0 12.818 10.39 23.21 23.209 23.21Zm209.582 0c12.818 0 23.209-10.39 23.209-23.209 0-12.817-10.39-23.208-23.209-23.208-12.818 0-23.209 10.39-23.209 23.208 0 12.818 10.391 23.21 23.21 23.21Z"/>
|
||||
<path d="M156.565 70.357c-.742-7.754-1.12-14.208-7.06-18.744-7.522-5.744-16.044-2.017-26.54-5.806C112.65 43.312 105 34.155 105 23.24 105 10.405 115.578 0 128.626 0c9.665 0 17.974 5.707 21.634 13.883 5.601 10.64 1.96 21.467 8.998 26.921 8.333 6.458 19.568 1.729 32.104 7.848a23.614 23.614 0 0 1 9.84 8.425A22.858 22.858 0 0 1 205 69.718c0 10.915-7.65 20.073-17.964 22.568-10.497 3.789-19.019.062-26.541 5.806-8.46 6.46-3.931 17.267-10.826 28.682-3.913 7.518-11.867 12.663-21.043 12.663-13.048 0-23.626-10.405-23.626-23.24 0-9.323 5.582-17.364 13.638-21.066 12.536-6.12 23.77-1.39 32.104-7.848 4.807-3.726 5.823-9.473 5.823-16.926Z" fill="currentColor"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
3
assets/tailwindcss.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="M7.5 2.5c-1.026 0-1.908.277-2.6.87-.688.59-1.137 1.447-1.387 2.516a.5.5 0 0 0 .897.4c.316-.452.632-.723.936-.863.294-.135.611-.162.975-.065.366.098.65.386 1.095.87l.015.016c.336.365.745.81 1.305 1.156.582.359 1.305.6 2.264.6 1.026 0 1.908-.277 2.6-.87.688-.59 1.138-1.447 1.387-2.516a.5.5 0 0 0-.897-.4c-.316.452-.632.723-.936.863-.294.135-.611.162-.975.065-.366-.098-.65-.386-1.095-.87l-.015-.016c-.336-.365-.745-.81-1.305-1.156-.582-.359-1.305-.6-2.264-.6ZM4 7c-1.026 0-1.908.277-2.6.87C.712 8.46.263 9.317.013 10.386a.5.5 0 0 0 .897.4c.316-.452.632-.723.936-.863.294-.135.611-.162.975-.065.366.098.65.386 1.095.87l.015.016c.336.365.745.81 1.305 1.156.582.359 1.305.6 2.264.6 1.026 0 1.908-.277 2.6-.87.688-.59 1.138-1.447 1.387-2.516a.5.5 0 0 0-.897-.4c-.316.452-.632.723-.936.863-.294.135-.611.162-.975.065-.366-.098-.65-.386-1.095-.87l-.015-.016c-.335-.365-.745-.81-1.305-1.156C5.682 7.24 4.959 7 4 7Z" fill="currentColor"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
381
docs/adb.md
Normal file
@ -0,0 +1,381 @@
|
||||
Android ADB 备忘清单
|
||||
===
|
||||
|
||||
[ADB](https://developer.android.com/studio/command-line/adb.html),Android Debug Bridge,包含在 Google 的 Android SDK 中,可用于从计算机控制您的 Android 设备。以下是您可以与 [ADB](https://developer.android.com/studio/command-line/adb.html) 一起使用的一些最常见的命令及其用法
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
### 设备基础
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb devices` | 列出连接的设备
|
||||
`adb devices -l` | 列出连接的设备和种类
|
||||
`adb root` | 以 `root` 权限重新启动 `adbd`
|
||||
`adb start-server` | 启动 `adb` 服务器
|
||||
`adb kill-server` | 杀死 `adb` 服务器
|
||||
`adb remount` | 重新挂载具有读/写访问权限的文件系统
|
||||
`adb reboot` | 重启设备
|
||||
`adb reboot bootloader` | 将设备重新启动到快速启动
|
||||
`adb disable-verity` | 将设备重新启动到快速启动
|
||||
<!--rehype:className=left-align code-nowrap-->
|
||||
|
||||
---
|
||||
|
||||
- `wait-for-device` 可以在 `adb` 之后指定,以确保该命令在设备连接后运行
|
||||
- `-s` 可用于在多个连接时将命令发送到特定设备
|
||||
|
||||
#### 示例
|
||||
|
||||
```bash
|
||||
$ adb wait-for-device devices
|
||||
List of devices attached
|
||||
somedevice-1234 device
|
||||
someotherdevice-1234 device
|
||||
```
|
||||
|
||||
```bash
|
||||
$ adb -s somedevice-1234 root
|
||||
```
|
||||
|
||||
### Logcat
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb logcat` | 开始将日志消息打印到标准输出
|
||||
`adb logcat -g` | 显示当前日志缓冲区大小
|
||||
`adb logcat -G <size>` | 设置缓冲区大小(K 或 M)
|
||||
`adb logcat -c` | 清除日志缓冲区
|
||||
`adb logcat *:V` | 启用所有日志消息(详细)
|
||||
`adb logcat -f <filename>` | 转储到指定文件
|
||||
<!--rehype:className=left-align code-nowrap-->
|
||||
|
||||
#### 示例
|
||||
|
||||
```bash
|
||||
$ adb logcat -G 16M
|
||||
$ adb logcat *:V > output.log
|
||||
```
|
||||
|
||||
#### 过滤日志输出
|
||||
|
||||
- `V` 详细(最低优先级)
|
||||
- `D` 调试
|
||||
- `I` 信息
|
||||
- `W` 警告
|
||||
- `E` 错误
|
||||
- `F` 严重错误
|
||||
- `S` 静默(最高优先级)
|
||||
<!--rehype:className=cols-2 shortcuts style-none-->
|
||||
|
||||
过滤器表达式显示了优先级不低于 `警告` 的所有标记的所有日志消息:
|
||||
|
||||
```bash
|
||||
$ adb logcat *:W
|
||||
```
|
||||
|
||||
### 文件管理
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb push <local> <remote>` | 将本地复制到远程设备
|
||||
`adb pull <remote> <local>` | 将远程设备从设备复制到本地
|
||||
<!--rehype:className=left-align code-nowrap-->
|
||||
|
||||
#### 示例
|
||||
|
||||
```bash
|
||||
$ echo "This is a test" > test.txt
|
||||
$ adb push test.txt /sdcard/test.txt
|
||||
$ adb pull /sdcard/test.txt pulledTest.txt
|
||||
```
|
||||
|
||||
### 远程 Shell
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb shell <command>` | 在设备上运行指定的命令(大多数 unix 命令在这里工作)
|
||||
`adb shell wm size` | 显示当前屏幕分辨率
|
||||
`adb shell wm size WxH` | 将分辨率设置为 WxH
|
||||
`adb shell pm list packages` | 列出所有已安装的包
|
||||
`adb shell pm list packages -3` | 列出所有已安装的 3rd 方包
|
||||
`adb shell monkey -p app.package.name` | 启动指定包
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### 包安装
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb shell install <apk>` | 安装应用程序
|
||||
`adb shell install <path>` | 手机路径安装应用
|
||||
`adb shell install -r <path>` | 手机路径安装应用
|
||||
`adb shell uninstall <name>` | 删除应用程序
|
||||
<!--rehype:className=left-align code-nowrap-->
|
||||
|
||||
### Paths
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`/data/data/<package>/databases` | 应用程序数据库
|
||||
`/data/data/<package>/shared_prefs/` | 共享偏好
|
||||
`/data/app` | 用户安装的apk
|
||||
`/system/app` | 预装的 APK 文件
|
||||
`/mmt/asec` | 加密的应用程序\|App2SD
|
||||
`/mmt/emmc` | 内部 SD 卡
|
||||
`/mmt/adcard` | 外部/内部 SD 卡
|
||||
`/mmt/adcard/external_sd` | 外置 SD 卡
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
---
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb shell ls` | 列出目录内容
|
||||
`adb shell ls -s` | 每个文件的打印尺寸
|
||||
`adb shell ls -R` | 递归列出子目录
|
||||
<!--rehype:className=left-align code-nowrap-->
|
||||
|
||||
### 手机信息
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb get-statе` | 打印设备状态
|
||||
`adb get-serialno` | 获取序列号
|
||||
`adb shell dumpsys iphonesybinfo` | 获取 IMEI
|
||||
`adb shell netstat` | 列出 TCP 连接
|
||||
`adb shell pwd` | 打印当前工作目录
|
||||
`adb shell dumpsys battery` | 电池状态
|
||||
`adb shell pm list features` | 列出电话功能
|
||||
`adb shell service list` | 列出所有服务
|
||||
`adb shell dumpsys activity <package>/<activity>` | 活动信息
|
||||
`adb shell ps` | 打印进程状态
|
||||
`adb shell wm size` | 显示当前屏幕分辨率
|
||||
`dumpsys window windows` \| `grep -E 'mCurrentFocus\|mFocusedApp'` | 打印当前应用程序的打开活动
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### 包信息
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb shell list packages` | 列出包名称
|
||||
`adb shell list packages -r` | 列出包名 + apks 的路径
|
||||
`adb shell list packages -3` | 列出第三方包名称
|
||||
`adb shell list packages -s` | 仅列出系统包
|
||||
`adb shell list packages -u` | 列出包名称 + 已卸载
|
||||
`adb shell dumpsys package packages` | 列出所有应用程序的信息
|
||||
`adb shell dump <name>` | 列出一个包裹的信息
|
||||
`adb shell path <package>` | apk文件的路径
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### 设备相关命令
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb reboot-recovery` | 重启设备进入恢复模式
|
||||
`adb reboot fastboot` | 重启设备进入恢复模式
|
||||
`adb shell screencap -p "/path/to/screenshot.png"` | 截图
|
||||
`adb shell screenrecord "/path/to/record.mp4"` | 录制设备屏幕
|
||||
`adb backup -apk -all -f backup.ab` | 备份设置和应用程序
|
||||
`adb backup -apk -shared -all -f backup.ab` | 备份设置、应用程序和共享存储
|
||||
`adb backup -apk -nosystem -all -f backup.ab` | 仅备份非系统应用程序
|
||||
`adb restore backup.ab` | 恢复以前的备份
|
||||
`adb shell am start -a android.intent.action.VIEW -d URL` | 打开网址
|
||||
`adb shell am start -t image/* -a android.intent.action.VIEW` | 打开画廊
|
||||
<!--rehype:className=code-nowrap left-align-->
|
||||
|
||||
### 权限
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb shell permissions groups` | 列出权限组定义
|
||||
`adb shell list permissions -g -r` | 列出权限详细信息
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### Logs
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`adb logcat [options] [filter] [filter]` | 查看设备日志
|
||||
`adb bugreport` | 打印错误报告
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
常见的 ADB 命令
|
||||
---
|
||||
|
||||
### 将文件推送到 Android 设备的下载文件夹
|
||||
|
||||
```bash
|
||||
$ adb push example.apk /mnt/Download/
|
||||
```
|
||||
|
||||
### 列出所有已安装的包并获取完整路径
|
||||
|
||||
```bash
|
||||
$ adb shell pm list packages -f
|
||||
```
|
||||
|
||||
### 从安卓设备中提取文件
|
||||
|
||||
```bash
|
||||
$ adb pull /mnt/Download/example.apk
|
||||
```
|
||||
|
||||
### 从主机安装 apk 到 Android 设备
|
||||
|
||||
```bash
|
||||
$ adb shell install example.apk
|
||||
```
|
||||
|
||||
### 从 Android 设备存储安装 apk
|
||||
|
||||
```bash
|
||||
$ adb shell install /mnt/Download/example.apk
|
||||
```
|
||||
|
||||
### 设置网络代理
|
||||
|
||||
```bash
|
||||
$ adb shell settings put global http_proxy <address>:<port>
|
||||
```
|
||||
|
||||
### 禁用网络代理
|
||||
|
||||
```bash
|
||||
$ adb shell settings put global http_proxy :0
|
||||
```
|
||||
|
||||
### 显示连接的设备并选择一个设备和外壳
|
||||
|
||||
```bash
|
||||
$ adb devices
|
||||
$ adb -s 7f1c864e shell
|
||||
```
|
||||
|
||||
`7f1c864e` 是设备 `ID`
|
||||
|
||||
### 通过 ip 地址无线连接到设备
|
||||
|
||||
```bash
|
||||
$ adb connect 192.168.56.101:5555
|
||||
```
|
||||
|
||||
### adb 通过 wifi
|
||||
<!--rehype:wrap-class=row-span-5-->
|
||||
|
||||
我们可以通过 `wifi` 或专门使用 `tcp` 连接使用 `adb`。 要通过 `wifi` 使用 `adb`,首先通过 `usb` 连接手机并启用 `usb` 调试。然后列出所有设备:
|
||||
|
||||
```bash
|
||||
$ adb devices
|
||||
# 这应该给出这样的输出:
|
||||
# device_id device
|
||||
```
|
||||
|
||||
现在检查 `android` 设备的 `ip`:
|
||||
|
||||
```bash
|
||||
$ adb shell ifconfig
|
||||
# 输出:
|
||||
|
||||
wlan0 Link encap:UNSPEC Driver icnss
|
||||
inet addr:XXX.XXX.X.XX Bcast:XXX.XXX.X.XXX
|
||||
```
|
||||
|
||||
记下 `inet addr` 后面的 `ip` 地址。我们稍后会需要它。现在在某个端口重新启动 `tcpip`:
|
||||
|
||||
```bash
|
||||
$ adb tcpip $port
|
||||
```
|
||||
|
||||
例如 5555:
|
||||
|
||||
```bash
|
||||
$ adb tcpip 5555
|
||||
```
|
||||
|
||||
您现在可以断开使用。 现在连接到设备只需给出以下命令:
|
||||
|
||||
```bash
|
||||
$ adb connect $ip:$port
|
||||
```
|
||||
|
||||
like:
|
||||
|
||||
```bash
|
||||
$ adb connect 192.168.1.4:5555
|
||||
```
|
||||
|
||||
### 从计算机上的 apk 文件安装应用程序
|
||||
|
||||
```bash
|
||||
$ adb install /Users/dev/projects/myapp.apk
|
||||
```
|
||||
|
||||
### 查找应用的 apk 路径
|
||||
|
||||
```bash
|
||||
$ adb shell pm path com.example.myapp
|
||||
```
|
||||
|
||||
将 `com.example.myapp` 替换为您自己的应用程序包名称
|
||||
|
||||
### 按名称查找应用的包名
|
||||
|
||||
```bash
|
||||
$ adb shell pm list package | grep app_name
|
||||
```
|
||||
|
||||
### 将 apk 从设备提取到您的计算机
|
||||
|
||||
```bash
|
||||
$ adb pull /data/app/com.example.myapp.apk ./
|
||||
```
|
||||
|
||||
### 将文件从计算机复制到设备
|
||||
|
||||
```bash
|
||||
$ adb push path/to/local/file /sdcard/foo.txt
|
||||
```
|
||||
|
||||
### 滚动屏幕
|
||||
|
||||
```bash
|
||||
$ adb shell input swipe 300 300 500 1000 # 上
|
||||
$ adb shell input swipe 500 1000 300 300 # 下
|
||||
```
|
||||
|
||||
### 发文本
|
||||
|
||||
使用虚拟键盘发送文本:
|
||||
|
||||
```bash
|
||||
$ adb shell input text "Hello World"
|
||||
```
|
||||
|
||||
### 发送按键事件
|
||||
|
||||
```bash
|
||||
$ adb shell input keyevent 66
|
||||
# 66 是回车键码
|
||||
```
|
||||
|
||||
### 发送点击
|
||||
|
||||
点击又名点击屏幕:
|
||||
|
||||
```bash
|
||||
$ adb shell input tap x y
|
||||
```
|
||||
|
||||
### 查看包的日志
|
||||
|
||||
```bash
|
||||
$ adb shell 'logcat --pid=$(pidof -s <package_name>)'
|
||||
```
|
||||
|
||||
查看特定包的日志
|
79
docs/bash.md
@ -4,7 +4,7 @@ Bash 备忘清单
|
||||
这是开始使用 linux bash shell 脚本的快速参考备忘单。
|
||||
|
||||
入门
|
||||
---------------
|
||||
-----
|
||||
|
||||
### hello.sh
|
||||
|
||||
@ -837,7 +837,6 @@ if [[ "$1" == '--' ]]; then shift; fi
|
||||
```
|
||||
|
||||
### 检查命令的结果
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
if ping -c 1 google.com; then
|
||||
@ -845,6 +844,73 @@ if ping -c 1 google.com; then
|
||||
fi
|
||||
```
|
||||
|
||||
### grep 检查
|
||||
|
||||
```bash
|
||||
if grep -q 'foo' ~/.bash_history; then
|
||||
echo "您过去似乎输入过“foo”"
|
||||
fi
|
||||
```
|
||||
|
||||
### 写入文件
|
||||
<!--rehype:wrap-class=row-span-6-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`cat` | 用于显示文本文件内容,全部输出
|
||||
`EOF` | `end of file`,表示文本结束符
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
cat > output.txt <<EOF
|
||||
this is test eof
|
||||
this is test eof2
|
||||
EOF
|
||||
```
|
||||
|
||||
输出 `cat output.txt`
|
||||
|
||||
```
|
||||
this is test eof
|
||||
this is test eof2
|
||||
```
|
||||
|
||||
追加内容
|
||||
|
||||
```bash
|
||||
cat >>2.txt <<EOF
|
||||
456
|
||||
789
|
||||
EOF
|
||||
```
|
||||
|
||||
`$` 等特殊字符时,须利用转义字符 `\`
|
||||
|
||||
```bash
|
||||
cat > file <<EOF
|
||||
export ORACLE_SID=yqpt
|
||||
export PATH=\$PATH:\$ORACLE_HOME/bin
|
||||
EOF
|
||||
```
|
||||
|
||||
取消变量替换,`EOF` 被加上双引号或者单引号,即可取消变量的替换
|
||||
|
||||
```bash
|
||||
cat << "EOF" > output.sh
|
||||
echo "This is output"
|
||||
echo $1
|
||||
EOF
|
||||
```
|
||||
|
||||
所有TAB键将全部忽略[不能是空格]
|
||||
|
||||
```bash
|
||||
cat << -EOF
|
||||
echo "This is output"
|
||||
EOF
|
||||
```
|
||||
|
||||
### 特殊变量
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
@ -857,15 +923,6 @@ fi
|
||||
|
||||
见[特殊参数](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables)。
|
||||
|
||||
### grep 检查
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
if grep -q 'foo' ~/.bash_history; then
|
||||
echo "您过去似乎输入过“foo”"
|
||||
fi
|
||||
```
|
||||
|
||||
### 反斜杠转义
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
|
410
docs/cpp.md
@ -545,6 +545,416 @@ int main() {
|
||||
}
|
||||
```
|
||||
|
||||
### Lambda 表达式
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
Lambda 表达式可以在函数内定义,可以理解为在函数内定义的临时函数。格式:
|
||||
|
||||
```cpp
|
||||
auto func = []() -> return_type { };
|
||||
```
|
||||
|
||||
- `[]`为捕获列表,能够捕获其所在函数的局部变量
|
||||
- 一个空的捕获列表代表Lambda表达式不捕获任何的变量
|
||||
- 对于值捕获,直接在中括号中填写要捕获的变量即可:
|
||||
|
||||
```cpp
|
||||
int val = 5;
|
||||
auto func = [val]() -> return_type { };
|
||||
```
|
||||
|
||||
- 对于引用捕获,需要在捕获的变量前添加`&`:
|
||||
|
||||
```cpp
|
||||
string str("hello world!");
|
||||
auto func = [&str]() -> return_type { };
|
||||
```
|
||||
|
||||
- 如果变量太多,需要编译器根据我们编写的代码自动捕获,可以采用隐式捕获的方式。
|
||||
|
||||
- 全部值捕获:
|
||||
|
||||
```cpp
|
||||
int val1, val2;
|
||||
auto func = [=]() -> int
|
||||
{
|
||||
return val1 + val2;
|
||||
};
|
||||
```
|
||||
|
||||
- 全部引用捕获:
|
||||
|
||||
```cpp
|
||||
string str1("hello"), str2("word!");
|
||||
auto func = [&]() -> string
|
||||
{
|
||||
return str1 + str2;
|
||||
};
|
||||
```
|
||||
|
||||
- 混合隐式捕获:
|
||||
|
||||
如果希望对一部分变量采用值捕获,对其他变量采用引用捕获,可以混合使用:
|
||||
|
||||
```cpp
|
||||
int val1 = 123, val2 = 456;
|
||||
string str1("123"), str2(456);
|
||||
|
||||
auto func1 = [=, &str1]() -> int
|
||||
{
|
||||
return val1 == std::stoi(str1)
|
||||
? val1 : val2;
|
||||
};
|
||||
|
||||
auto func2 = [&, val1]() -> int
|
||||
{
|
||||
return str1 == std::to_string(val1)
|
||||
? str1 : str2;
|
||||
};
|
||||
```
|
||||
|
||||
- `()` 是参数列表,我们只需要按照普通函数的使用方法来使用即可
|
||||
- `return_type` 是函数的返回类型,`-> return_type` 可以不写,编译器会自动推导
|
||||
- `{}` 中的内容就是函数体,依照普通函数的使用方法使用即可
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
此处给出一个 Lambda 表达式的实际使用例子(当然可以使用 `str::copy`):
|
||||
|
||||
```cpp
|
||||
// vec中包含1, 2, 3, 4, 5
|
||||
std::vector<int> vec({1, 2, 3, 4, 5});
|
||||
std::for_each(vec.begin(), vec.end(),
|
||||
[](int& ele) -> void
|
||||
{
|
||||
std::cout << ele
|
||||
<< " ";
|
||||
});
|
||||
```
|
||||
|
||||
## C++多线程
|
||||
|
||||
### 多线程介绍
|
||||
|
||||
g++编译选项:`-std=c++11`。包含头文件:
|
||||
|
||||
- `#include <thread>`:C++多线程库
|
||||
- `#include <mutex>`:C++互斥量库
|
||||
- `#include <future>`:C++异步库
|
||||
|
||||
### 线程的创建
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
以普通函数作为线程入口函数:
|
||||
|
||||
```cpp
|
||||
void entry_1() { }
|
||||
void entry_2(int val) { }
|
||||
|
||||
std::thread my_thread_1(entry_1);
|
||||
std::thread my_thread_2(entry_2, 5);
|
||||
```
|
||||
|
||||
以类对象作为线程入口函数:
|
||||
|
||||
```cpp
|
||||
class Entry
|
||||
{
|
||||
void operator()() { }
|
||||
void entry_function() { }
|
||||
};
|
||||
|
||||
Entry entry;
|
||||
// 调用operator()()
|
||||
std::thread my_thread_1(entry);
|
||||
// 调用Entry::entry_function
|
||||
std::thread my_thread_2(&Entry::entry_function, &entry);
|
||||
```
|
||||
|
||||
以lambda表达式作为线程入口函数:
|
||||
|
||||
```cpp
|
||||
std::thread my_thread([]() -> void
|
||||
{
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
### 线程的销毁
|
||||
|
||||
```cpp
|
||||
thread my_thread;
|
||||
// 阻塞
|
||||
my_thread.join();
|
||||
// 非阻塞
|
||||
my_thread.detach();
|
||||
```
|
||||
|
||||
### `this_thread`
|
||||
|
||||
```cpp
|
||||
// 获取当前线程ID
|
||||
std::this_thread::get_id();
|
||||
// 使当前线程休眠一段指定时间
|
||||
std::this_thread::sleep_for();
|
||||
// 使当前线程休眠到指定时间
|
||||
std::this_thread::sleep_until();
|
||||
// 暂停当前线程的执行,让别的线程执行
|
||||
std::this_thread::yield();
|
||||
```
|
||||
|
||||
### 锁
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
> `#include <mutex>`
|
||||
|
||||
#### 锁的基本操作
|
||||
|
||||
创建锁
|
||||
|
||||
```cpp
|
||||
std::mutex m;
|
||||
```
|
||||
|
||||
上锁
|
||||
|
||||
```cpp
|
||||
m.lock();
|
||||
```
|
||||
|
||||
解锁
|
||||
|
||||
```cpp
|
||||
m.unlock();
|
||||
```
|
||||
|
||||
尝试上锁:成功返回`true`,失败返回`false`
|
||||
|
||||
```cpp
|
||||
m.try_lock();
|
||||
```
|
||||
|
||||
解锁
|
||||
|
||||
```cpp
|
||||
m.unlock();
|
||||
```
|
||||
|
||||
#### 更简单的锁 —— `std::lock_guard<Mutex>`
|
||||
|
||||
构造时上锁,析构时解锁
|
||||
|
||||
```cpp
|
||||
std::mutex m;
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
```
|
||||
|
||||
额外参数:`std::adopt_lock`:只需解锁,无需上锁
|
||||
|
||||
```cpp
|
||||
// 手动上锁
|
||||
m.lock();
|
||||
std::lock_guard<mutex> lock(m,
|
||||
std::adopt_lock);
|
||||
```
|
||||
|
||||
#### `unique_lock<Mutex>`
|
||||
|
||||
构造上锁,析构解锁
|
||||
|
||||
```cpp
|
||||
std::mutex m;
|
||||
std::unique_lock<mutex> lock(m);
|
||||
```
|
||||
|
||||
##### `std::adopt_lock`
|
||||
|
||||
只需解锁,无需上锁
|
||||
|
||||
```cpp
|
||||
// 手动上锁
|
||||
m.lock();
|
||||
std::unique_lock<mutex> lock(m,
|
||||
std::adopt_lock);
|
||||
```
|
||||
|
||||
##### `std::try_to_lock`
|
||||
|
||||
尝试上锁,可以通过`std::unique_lock<Mutex>::owns_lock()`查看状态
|
||||
|
||||
```cpp
|
||||
std::unique_lock<mutex> lock(m,
|
||||
std::try_to_lock);
|
||||
if (lock.owns_lock())
|
||||
{
|
||||
// 拿到了锁
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有
|
||||
}
|
||||
```
|
||||
|
||||
##### `std::defer_lock`
|
||||
|
||||
绑定锁,但不上锁
|
||||
|
||||
```cpp
|
||||
std::unique_lock<mutex> lock(m,
|
||||
std::defer_lock);
|
||||
lock.lock();
|
||||
lock.unlock();
|
||||
```
|
||||
|
||||
##### `std::unique_lock<Mutex>::release`
|
||||
|
||||
返回所管理的`mutex`对象指针,**释放所有权。**一旦释放了所有权,那么如果原来互斥量处于互斥状态,程序员有责任手动解锁。
|
||||
|
||||
#### `std::call_once`
|
||||
|
||||
当多个线程通过这个函数调用一个可调用对象时,只会有一个线程成功调用。
|
||||
|
||||
```cpp
|
||||
std::once_flag flag;
|
||||
|
||||
void foo() { }
|
||||
|
||||
std::call_once(flag, foo);
|
||||
```
|
||||
|
||||
### `std::condition_variable`
|
||||
|
||||
#### 创建条件变量
|
||||
|
||||
```cpp
|
||||
std::condition_variable cond;
|
||||
```
|
||||
|
||||
#### 等待条件变量被通知
|
||||
|
||||
```cpp
|
||||
std::unique_lock<std::mutex>
|
||||
lock;
|
||||
extern bool predicate();
|
||||
|
||||
// 调用方式 1
|
||||
cond.wait(lock);
|
||||
// 调用方式 2
|
||||
cond.wait(lock, predicate);
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `wait`不断地尝试重新获取并加锁该互斥量,如果获取不到,它就卡在这里并反复尝试重新获取,如果获取到了,执行流程就继续往下走
|
||||
- `wait`在获取到互斥量并加锁了互斥量之后:
|
||||
- 如果`wait`被提供了可调用对象,那么就执行这个可调用对象:
|
||||
- 如果返回值为`false`,那么`wait`继续加锁,直到再次被 notified
|
||||
- 如果返回值为`true`,那么`wait`返回,继续执行流程
|
||||
- 如果`wait`没有第二个参数,那么直接返回,继续执行
|
||||
|
||||
#### `std::condition_variable::notify_one`
|
||||
|
||||
`notify_one` 唤醒一个调用 `wait` 的线程。注意在唤醒之前要解锁,否则调用 `wait` 的线程也会因为无法加锁而阻塞。
|
||||
|
||||
#### `std::condition_variable::notify_all`
|
||||
|
||||
唤醒所有调用 `wait` 的线程。
|
||||
|
||||
### 获取线程的运行结果
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
> `#include <future>`
|
||||
|
||||
#### 创建异步任务
|
||||
|
||||
```cpp
|
||||
double func(int val);
|
||||
|
||||
// 使用std::async创建异步任务
|
||||
// 使用std::future获取结果
|
||||
// future模板中存放返回值类型
|
||||
std::future<double> result =
|
||||
std::async(func, 5);
|
||||
```
|
||||
|
||||
#### 获取异步任务的返回值
|
||||
|
||||
等待异步任务结束,但是不获取返回值:
|
||||
|
||||
```cpp
|
||||
result.wait();
|
||||
```
|
||||
|
||||
获取异步任务的返回值:
|
||||
|
||||
```cpp
|
||||
int val = result.get();
|
||||
```
|
||||
|
||||
注:
|
||||
|
||||
- `get()`返回右值,因此只可调用一次
|
||||
- 只要调用上述任意函数,线程就会一直阻塞到返回值可用(入口函数运行结束)
|
||||
|
||||
#### `std::async` 的额外参数
|
||||
|
||||
额外参数可以被放在 `std::async` 的第一个参数位置,用于设定 `std::async` 的行为:
|
||||
|
||||
- `std::launch::deferred`:入口函数的运行会被推迟到`std::future<T>::get()`或者`std::future<T>::wait()`被调用时。此时调用线程会直接运行线程入口函数,换言之,**不会创建子线程**
|
||||
- `std::launch::async`:立即创建子线程,并运行线程入口函数
|
||||
- `std::launch::deferred | std::launch::async`:默认值,由系统自行决定
|
||||
|
||||
#### 返回值的状态
|
||||
|
||||
让当前线程等待一段时间(等待到指定时间点),以期待返回值准备好:
|
||||
|
||||
```cpp
|
||||
extern double foo(int val) {}
|
||||
|
||||
std::future<double> result =
|
||||
async(foo, 5);
|
||||
|
||||
//返回值类型
|
||||
std::future_status status;
|
||||
// 等待一段时间
|
||||
status = result.wait_for(
|
||||
std::chrono::seconds(1)
|
||||
);
|
||||
// 等待到某一时间点
|
||||
status = result.wait_for(
|
||||
std::chrono::now() +
|
||||
std::chrono::seconds(1)
|
||||
);
|
||||
```
|
||||
|
||||
在指定的时间过去后,可以获取等待的结果:
|
||||
|
||||
```cpp
|
||||
// 返回值已经准备好
|
||||
if (status ==
|
||||
std::future_status::ready)
|
||||
{
|
||||
|
||||
}
|
||||
// 超时:尚未准备好
|
||||
else if (status ==
|
||||
std::future_status::timeout)
|
||||
{ }
|
||||
// 尚未启动: std::launch::deferred
|
||||
else if (status ==
|
||||
std::future_status::deferred)
|
||||
{ }
|
||||
```
|
||||
|
||||
#### 多个返回值
|
||||
|
||||
```cpp
|
||||
std::shared_future<T> result;
|
||||
```
|
||||
|
||||
如果要多次获取结果,可以使用`std::shared_future`,其会返回结果的一个**拷贝**。
|
||||
|
||||
对于不可拷贝对象,可以在`std::shared_future`中存储对象的指针,而非指针本身。
|
||||
|
||||
C++ 预处理器
|
||||
------------
|
||||
|
||||
|
163
docs/css.md
@ -13,8 +13,6 @@ CSS 功能丰富,不仅仅是布局页面
|
||||
|
||||
#### 外部样式表 `<link>`
|
||||
|
||||
`
|
||||
|
||||
```html
|
||||
<link
|
||||
href="./path/to/stylesheet/style.css"
|
||||
@ -1521,6 +1519,43 @@ html {
|
||||
|
||||
上面示例设置了当前卡片灰色
|
||||
|
||||
### 使用 unset 而不是重置所有属性
|
||||
|
||||
使用 `all` 速记来指定元素的所有属性。将值设置为 `unset` 会将元素的属性更改为其初始值:
|
||||
|
||||
```css
|
||||
button {
|
||||
all: unset;
|
||||
}
|
||||
```
|
||||
|
||||
注意:`IE11` 不支持 `all` 和 `unset` 速记
|
||||
|
||||
### 超出显示省略号
|
||||
|
||||
```css
|
||||
p {
|
||||
overflow: hidden;/*超出部分隐藏*/
|
||||
/* 超出部分显示省略号 */
|
||||
text-overflow:ellipsis;
|
||||
/* 规定段落中的文本不进行换行 */
|
||||
white-space: nowrap;
|
||||
width: 250px;/*需要配合宽度来使用*/
|
||||
}
|
||||
```
|
||||
|
||||
### 给正文添加行高
|
||||
|
||||
您不需要为每个 `<p>`、`<h*>` 等添加行高。相反,将其添加到正文:
|
||||
|
||||
```css
|
||||
body {
|
||||
line-height: 1.5;
|
||||
}
|
||||
```
|
||||
|
||||
这样文本元素可以很容易地从 `body` 继承
|
||||
|
||||
### 使用图像作为光标
|
||||
|
||||
```css
|
||||
@ -1652,6 +1687,130 @@ div {
|
||||
|
||||
属性 [aspect-ratio](https://developer.mozilla.org/zh-CN/docs/Web/CSS/aspect-ratio) 可以非常容易的定义一个容器的长宽比
|
||||
|
||||
### 等宽表格单元格
|
||||
|
||||
尝试使用 `table-layout: fixed` 以保持单元格宽度相等:
|
||||
|
||||
```css
|
||||
table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
```
|
||||
|
||||
### 利用属性选择器来选择空链接
|
||||
|
||||
当 `<a>` 元素没有文本内容,但有 `href` 属性的时候,显示它的 `href` 属性:
|
||||
|
||||
```css
|
||||
a[href^="http"]:empty::before {
|
||||
content: attr(href);
|
||||
}
|
||||
```
|
||||
|
||||
### 给 “默认” 链接定义样式
|
||||
|
||||
给 “默认” 链接定义样式:
|
||||
|
||||
```css
|
||||
a[href]:not([class]) {
|
||||
color: #008000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
```
|
||||
|
||||
通常没有 `class` 属性,以上样式可以甄别它们,而且不会影响其它样式
|
||||
|
||||
### 用 rem 调整全局大小;用 em 调整局部大小
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
在根元素设置基本字体大小后 (`html { font-size: 100%; }`), 使用 em 设置文本元素的字体大小:
|
||||
|
||||
```css
|
||||
h2 {
|
||||
font-size: 2em;
|
||||
}
|
||||
p {
|
||||
font-size: 1em;
|
||||
}
|
||||
```
|
||||
|
||||
然后设置模块的字体大小为 rem:
|
||||
|
||||
```css
|
||||
article {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
aside .module {
|
||||
font-size: .9rem;
|
||||
}
|
||||
```
|
||||
|
||||
现在,每个模块变得独立,更容易、灵活的样式便于维护
|
||||
|
||||
### 隐藏没有静音、自动播放的影片
|
||||
|
||||
这是一个自定义用户样式表的不错的技巧。避免在加载页面时自动播放。如果没有静音,则不显示视频:
|
||||
|
||||
```css
|
||||
video[autoplay]:not([muted]) {
|
||||
display: none;
|
||||
}
|
||||
```
|
||||
|
||||
再次,我们利用了 `:not()` 的优点
|
||||
|
||||
### 为更好的移动体验,为表单元素设置字体大小
|
||||
|
||||
当触发 `<select>` 的下拉列表时,为了避免表单元素在移动浏览器(iOS Safari 和其它)上的缩放,加上font-size:
|
||||
|
||||
```css
|
||||
input[type="text"],
|
||||
input[type="number"],
|
||||
select,
|
||||
textarea {
|
||||
font-size: 16px;
|
||||
}
|
||||
```
|
||||
|
||||
### 使用指针事件来控制鼠标事件
|
||||
|
||||
指针事件允许您指定鼠标如何与其触摸的元素进行交互。要禁用按钮上的默认指针事件,例如:
|
||||
|
||||
```css
|
||||
button:disabled {
|
||||
opacity: .5;
|
||||
pointer-events: none;
|
||||
}
|
||||
```
|
||||
|
||||
就这么简单
|
||||
|
||||
### 在用作间距的换行符上设置 `display: none`
|
||||
|
||||
用户使用额外的换行符
|
||||
|
||||
```css
|
||||
br + br {
|
||||
display: none;
|
||||
}
|
||||
```
|
||||
|
||||
### 子元素选中父元素
|
||||
|
||||
```css
|
||||
div:has(img) {
|
||||
background: black;
|
||||
}
|
||||
```
|
||||
|
||||
设置包含子元素 `img` 的 `div` 元素样式,还可以嵌套:
|
||||
|
||||
```css
|
||||
div:has(h2):has(ul) {
|
||||
background: black;
|
||||
}
|
||||
```
|
||||
|
||||
另见
|
||||
---------
|
||||
|
||||
|
@ -281,7 +281,7 @@ $ docker push eon01/nginx localhost:5000/myadmin/nginx
|
||||
|---------|---------|
|
||||
`docker stop -f $(docker ps -a -q)` | 停止所有容器
|
||||
`docker rm -f $(docker ps -a -q)` | 删除所有容器
|
||||
`docker rmi -f $(docker images -q)` | 删除所有图像
|
||||
`docker rmi -f $(docker images -q)` | 删除所有镜像
|
||||
|
||||
### 卷 volume
|
||||
|
||||
@ -307,10 +307,10 @@ $ docker volume prune
|
||||
`docker-compose down` | 停止和删除容器、网络、映像和卷
|
||||
`docker-compose logs` | 查看容器的输出
|
||||
`docker-compose restart` | 重启所有服务
|
||||
`docker-compose pull` | 拉取所有图片服务
|
||||
`docker-compose build` | 构建所有图像服务
|
||||
`docker-compose pull` | 拉取所有服务的镜像
|
||||
`docker-compose build` | 构建所有服务的镜像
|
||||
`docker-compose config` | 验证并查看 Compose 文件
|
||||
`docker-compose scale <service_name>=<replica>` | 规模特殊服务
|
||||
`docker-compose scale <service_name>=<replica>` | 为服务指定容器个数
|
||||
`docker-compose top` | 显示正在运行的进程
|
||||
`docker-compose run -rm -p 2022:22 web bash` | 启动 Web 服务并运行 bash 作为其命令,删除旧容器。
|
||||
|
||||
@ -361,35 +361,35 @@ $ docker volume prune
|
||||
:- | :-
|
||||
`attach` | 将本地标准输入、输出和错误流附加到正在运行的容器
|
||||
`build` | 从 Dockerfile 构建镜像
|
||||
`commit` | 从容器的更改创建新图像
|
||||
`commit` | 从容器的更改创建新镜像
|
||||
`cp` | 在容器和本地文件系统之间复制文件/文件夹
|
||||
`create` | 创建一个新容器
|
||||
`diff` | 检查容器文件系统上文件或目录的更改
|
||||
`events` | 从服务器获取实时事件
|
||||
`exec` | 在正在运行的容器中运行命令
|
||||
`export` | 将容器的文件系统导出为 tar 存档
|
||||
`history` | 显示图像的历史
|
||||
`images` | 列出图像
|
||||
`history` | 显示镜像的历史
|
||||
`images` | 列出镜像
|
||||
`import` | 从 tarball 导入内容以创建文件系统映像
|
||||
`info` | 显示系统范围的信息
|
||||
`inspect` | 返回有关 Docker 对象的低级信息
|
||||
`kill` | 杀死一个或多个正在运行的容器
|
||||
`load` | 从 tar 存档或 STDIN 加载图像
|
||||
`load` | 从 tar 存档或 STDIN 加载镜像
|
||||
`login` | 登录到 Docker 注册表
|
||||
`logout` | 从 Docker 注册表中注销
|
||||
`logs` | 获取容器的日志
|
||||
`pause` | 暂停一个或多个容器内的所有进程
|
||||
`port` | 列出容器的端口映射或特定映射
|
||||
`ps` | 列出容器
|
||||
`pull` | 从注册表中提取图像或存储库
|
||||
`push` | 将图像或存储库推送到注册表
|
||||
`pull` | 从注册表中提取镜像或存储库
|
||||
`push` | 将镜像或存储库推送到注册表
|
||||
`rename` | 重命名容器
|
||||
`restart` | 重启一个或多个容器
|
||||
`rm` | 移除一个或多个容器
|
||||
`rmi` | 移除一张或多张图片
|
||||
`rmi` | 移除一张或多张镜像
|
||||
`run` | 在新容器中运行命令
|
||||
`save` | 将一个或多个图像保存到 tar 存档(默认流式传输到 STDOUT)
|
||||
`search` | 在 `Docker Hub` 中搜索图像
|
||||
`save` | 将一个或多个镜像保存到 tar 存档(默认流式传输到 STDOUT)
|
||||
`search` | 在 `Docker Hub` 中搜索镜像
|
||||
`start` | 启动一个或多个停止的容器
|
||||
`stats` | 显示容器资源使用统计的实时流
|
||||
`stop` | 停止一个或多个正在运行的容器
|
||||
@ -431,12 +431,12 @@ $ docker volume prune
|
||||
--device-read-iops list # 限制设备的读取速率(每秒 IO)(默认 [])
|
||||
--device-write-bps list # 限制设备的写入速率(每秒字节数)(默认 [])
|
||||
--device-write-iops list # 限制设备的写入速率(每秒 IO)(默认 [])
|
||||
--disable-content-trust # 跳过图像验证(默认为 true)
|
||||
--disable-content-trust # 跳过镜像验证(默认为 true)
|
||||
--dns list # 设置自定义 DNS 服务器
|
||||
--dns-option list # 设置 DNS 选项
|
||||
--dns-search list # 设置自定义 DNS 搜索域
|
||||
--domainname string # 容器 NIS 域名
|
||||
--entrypoint string # 覆盖图像的默认入口点
|
||||
--entrypoint string # 覆盖镜像的默认入口点
|
||||
-e, --env list # 设置环境变量
|
||||
--env-file list # 读入环境变量文件
|
||||
--expose list # 公开一个端口或一系列端口
|
||||
@ -480,7 +480,7 @@ $ docker volume prune
|
||||
--privileged # 授予此容器扩展权限
|
||||
-p, --publish list # 将容器的端口发布到主机
|
||||
-P, --publish-all # 将所有暴露的端口发布到随机端口
|
||||
--pull string # 创建前拉取图像("always"|"missing"|"never")(默认"missing")
|
||||
--pull string # 创建前拉取镜像("always"|"missing"|"never")(默认"missing")
|
||||
--read-only # 将容器的根文件系统挂载为只读
|
||||
--restart string # 容器退出时应用的重启策略(默认“否”)
|
||||
--rm # 容器退出时自动移除
|
||||
@ -533,7 +533,7 @@ $ docker volume prune
|
||||
`docker config` | 管理 Docker 配置
|
||||
`docker container` | 管理容器
|
||||
`docker context` | 管理上下文
|
||||
`docker image` | 管理图像
|
||||
`docker image` | 管理镜像
|
||||
`docker manifest` | 管理 Docker 镜像清单和清单列表
|
||||
`docker network` | 管理网络
|
||||
`docker node` | 管理 Swarm 节点
|
||||
@ -550,12 +550,12 @@ $ docker volume prune
|
||||
### docker images
|
||||
|
||||
```bash
|
||||
-a, --all 显示所有图像(默认隐藏中间图像)
|
||||
-a, --all 显示所有镜像(默认隐藏中间镜像)
|
||||
--digests 显示摘要
|
||||
-f, --filter filter 根据提供的条件过滤输出
|
||||
--format string 使用 Go 模板打印漂亮的图像
|
||||
--format string 使用 Go 模板打印漂亮的镜像
|
||||
--no-trunc 不要截断输出
|
||||
-q, --quiet 仅显示图像 ID
|
||||
-q, --quiet 仅显示镜像 ID
|
||||
```
|
||||
|
||||
Docker 示例
|
||||
|
@ -215,7 +215,7 @@ Dockerfile 示例
|
||||
|
||||
```dockerfile
|
||||
FROM lipanski/docker-static-website:latest
|
||||
# 使用 .dockerignore 文件来控制图像中的内容!
|
||||
# 使用 .dockerignore 文件来控制镜像中的内容!
|
||||
# 复制当前目录内容,到容器中
|
||||
COPY ./ .
|
||||
```
|
||||
|
156
docs/feds.md
Normal file
@ -0,0 +1,156 @@
|
||||
FED 前端导航
|
||||
===
|
||||
|
||||
前端开发导航快速参考备忘单展示了前端的一些工具
|
||||
|
||||
社区
|
||||
---
|
||||
|
||||
[CSDN](https://www.csdn.net/)<!--rehype:target=_blank&style=background: rgb(252 85 49/var(\-\-bg\-opacity));-->
|
||||
[GitHub](https://github.com/)<!--rehype:target=_blank&style=background: rgb(0 0 0/var(\-\-bg\-opacity));-->
|
||||
[InfoQ](http://www.infoq.com/cn)<!--rehype:target=_blank&style=background: rgb(66 133 244/var(\-\-bg\-opacity));-->
|
||||
[Medium](https://medium.com/topic/technology)<!--rehype:target=_blank-->
|
||||
[SegmentFault](https://segmentfault.com/)<!--rehype:target=_blank&style=background: rgb(0 150 94/var(\-\-bg\-opacity));-->
|
||||
[Stack Overflow](https://stackoverflow.com/)<!--rehype:target=_blank&style=background: rgb(244 130 37/var(\-\-bg\-opacity));-->
|
||||
[V2EX](https://www.v2ex.com/?tab=tech)<!--rehype:target=_blank&style=background: rgb(0 0 0/var(\-\-bg\-opacity));-->
|
||||
[博客园](https://www.cnblogs.com/)<!--rehype:target=_blank&style=background: rgb(46 122 203/var(\-\-bg\-opacity));-->
|
||||
[开源中国](https://www.oschina.net/)<!--rehype:target=_blank&style=background: rgb(43 179 81/var(\-\-bg\-opacity));-->
|
||||
[稀土掘金](https://juejin.im/)<!--rehype:target=_blank&style=background: rgb(30 128 255/var(\-\-bg\-opacity));-->
|
||||
[W3cplus](https://www.w3cplus.com/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
构建工具
|
||||
---
|
||||
|
||||
[Webpack](http://webpack.github.io/)<!--rehype:target=_blank&style=background: rgb(107 148 216/var(\-\-bg\-opacity));-->
|
||||
[NPM](https://www.npmjs.com/)<!--rehype:target=_blank&style=background: rgb(203 8 1/var(\-\-bg\-opacity));-->
|
||||
[Yarn](https://yarnpkg.com/zh-Hans/)<!--rehype:target=_blank&style=background: rgb(33 136 182/var(\-\-bg\-opacity));-->
|
||||
[pnpm](https://pnpm.io/)<!--rehype:target=_blank&style=background: rgb(246 146 32/var(\-\-bg\-opacity));-->
|
||||
[Lerna](https://lerna.js.org/)<!--rehype:target=_blank&style=background: rgb(147 51 234/var(\-\-bg\-opacity));-->
|
||||
[Vitejs](https://cn.vitejs.dev/)<!--rehype:target=_blank&style=background: rgb(188 52 254/var(\-\-bg\-opacity));-->
|
||||
[Gulp](https://gulpjs.com/)<!--rehype:target=_blank&style=background: rgb(207 70 71/var(\-\-bg\-opacity));-->
|
||||
[Parcel](https://en.parceljs.org/)<!--rehype:target=_blank&style=background: rgb(192 145 99/var(\-\-bg\-opacity));-->
|
||||
[Rollup](https://rollupjs.org/guide/en/)<!--rehype:target=_blank&style=background: rgb(239 51 53/var(\-\-bg\-opacity));-->
|
||||
[Turbopack](https://turbo.build/)<!--rehype:target=_blank&style=background: rgb(248 30 87/var(\-\-bg\-opacity));-->
|
||||
[Create React App](https://create-react-app.dev/)<!--rehype:target=_blank&style=background: rgb(60 106 146/var(\-\-bg\-opacity));-->
|
||||
[Browserify](http://browserify.org/)<!--rehype:target=_blank&style=background: rgb(60 106 146/var(\-\-bg\-opacity));-->
|
||||
[Yeoman](http://yeoman.io/)<!--rehype:target=_blank-->
|
||||
[Grunt](https://gruntjs.com/)<!--rehype:target=_blank-->
|
||||
[Babel](https://babeljs.io/)<!--rehype:target=_blank&style=background: rgb(245 218 85/var(\-\-bg\-opacity));-->
|
||||
[FIS3](https://fex-team.github.io/fis3/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
教程文档
|
||||
---
|
||||
|
||||
[MDN Web Docs](https://developer.mozilla.org/zh-CN/)<!--rehype:target=_blank&style=background: rgb(140 181 255/var(\-\-bg\-opacity));-->
|
||||
[ECMAScript 6 入门](https://es6.ruanyifeng.com/)<!--rehype:target=_blank-->
|
||||
[W3C 标准](http://w3help.org/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
JavaScript 工具
|
||||
---
|
||||
|
||||
[Chrome Dev Tools](https://www.google.cn/chrome/)<!--rehype:target=_blank-->
|
||||
[CoffeeScript](https://coffeescript.org/)<!--rehype:target=_blank-->
|
||||
[Firefox Developer Tools](https://www.mozilla.org/zh-CN/firefox/new/)<!--rehype:target=_blank-->
|
||||
[flow](https://flow.org/)<!--rehype:target=_blank&style=background: rgb(232 189 54/var(\-\-bg\-opacity));-->
|
||||
[TypeScript](https://www.typescriptlang.org/)<!--rehype:target=_blank&style=background: rgb(49 120 197/var(\-\-bg\-opacity));-->
|
||||
[JS 压缩,格式化](https://www.css-js.com/)<!--rehype:target=_blank-->
|
||||
[JSDoc](https://jsdoc.app/)<!--rehype:target=_blank&style=background: rgb(197 149 199/var(\-\-bg\-opacity));-->
|
||||
[UglifyJS](http://lisperator.net/uglifyjs/transform)<!--rehype:target=_blank-->
|
||||
[Prettier](https://prettier.io/)<!--rehype:target=_blank&style=background: rgb(197 149 199/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
JavaScript 测试工具
|
||||
---
|
||||
|
||||
[Chai](http://chaijs.com/)<!--rehype:target=_blank&style=background: rgb(164 8 1/var(\-\-bg\-opacity));-->
|
||||
[ESLint](https://eslint.org/)<!--rehype:target=_blank&style=background: rgb(76 50 195/var(\-\-bg\-opacity));-->
|
||||
[JSHint](http://jshint.com/)<!--rehype:target=_blank-->
|
||||
[Jasmine](https://jasmine.github.io/)<!--rehype:target=_blank&style=background: rgb(138 65 130/var(\-\-bg\-opacity));-->
|
||||
[Jest](https://jestjs.io/)<!--rehype:target=_blank&style=background: rgb(158 79 101/var(\-\-bg\-opacity));-->
|
||||
[Mochajs](https://mochajs.org/)<!--rehype:target=_blank&style=background: rgb(141 103 72/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
CSS 工具
|
||||
---
|
||||
|
||||
[30秒CSS](https://atomiks.github.io/30-seconds-of-css/)<!--rehype:target=_blank-->
|
||||
[Autoprefixer](https://github.com/postcss/autoprefixer)<!--rehype:target=_blank-->
|
||||
[ColorZilla](http://www.colorzilla.com/gradient-editor/)<!--rehype:target=_blank-->
|
||||
[CSS Protips](https://github.com/AllThingsSmitty/css-protips)<!--rehype:target=_blank-->
|
||||
[CSS3 Maker](http://www.css3maker.com/)<!--rehype:target=_blank-->
|
||||
[cssnano](http://cssnano.co/)<!--rehype:target=_blank-->
|
||||
[CSSPIN](https://webkul.github.io/csspin/)<!--rehype:target=_blank-->
|
||||
[CSSreference](https://cssreference.io/)<!--rehype:target=_blank-->
|
||||
[CSSTree](https://github.com/csstree/csstree)<!--rehype:target=_blank-->
|
||||
[CSS美化压缩](http://tool.css-js.com/)<!--rehype:target=_blank-->
|
||||
[Easing Functions Cheat Sheet](http://easings.net/zh-cn)<!--rehype:target=_blank-->
|
||||
[Emmet](https://www.emmet.io/)<!--rehype:target=_blank-->
|
||||
[est](http://ecomfe.github.io/est/)<!--rehype:target=_blank-->
|
||||
[Flex Layout Attribute](https://github.com/StefanKovac/flex-layout-attribute)<!--rehype:target=_blank-->
|
||||
[Grid.Guide](http://grid.guide/)<!--rehype:target=_blank-->
|
||||
[minireset.css](http://lesscss.org/)<!--rehype:target=_blank-->
|
||||
[Normalize.css](http://necolas.github.io/normalize.css/)<!--rehype:target=_blank-->
|
||||
[PostCSS](http://postcss.org/)<!--rehype:target=_blank-->
|
||||
[purifycss](https://github.com/purifycss/purifycss)<!--rehype:target=_blank-->
|
||||
[Less](https://lesscss.org/)<!--rehype:target=_blank&style=background: rgb(36 74 121/var(\-\-bg\-opacity));-->
|
||||
[SASS](http://sass-lang.com/)<!--rehype:target=_blank&style=background: rgb(191 64 128/var(\-\-bg\-opacity));-->
|
||||
[Sprite Cow](http://www.spritecow.com/)<!--rehype:target=_blank-->
|
||||
[Stylus](http://stylus-lang.com/)<!--rehype:target=_blank&style=background: rgb(126 194 66/var(\-\-bg\-opacity));-->
|
||||
[Stylelint](https://stylelint.io/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
框架类库
|
||||
---
|
||||
|
||||
[React](https://facebook.github.io/react/)<!--rehype:target=_blank&style=background: rgb(97 218 251/var(\-\-bg\-opacity));-->
|
||||
[Vue 中文](https://cn.vuejs.org/)<!--rehype:target=_blank&style=background: rgb(66 184 131/var(\-\-bg\-opacity));-->
|
||||
[Angular](https://angular.io/)<!--rehype:target=_blank&style=background: rgb(195 8 47/var(\-\-bg\-opacity));-->
|
||||
[jQuery](http://www.jquery123.com/)<!--rehype:target=_blank-->
|
||||
[Bootstrap](https://getbootstrap.com/)<!--rehype:target=_blank&style=background: rgb(113 44 249/var(\-\-bg\-opacity));-->
|
||||
[React Native 中文](https://reactnative.cn/)<!--rehype:target=_blank&style=background: rgb(36 120 194/var(\-\-bg\-opacity));-->
|
||||
[Flutter](https://flutter.dev/)<!--rehype:target=_blank&style=background: rgb(35 104 215/var(\-\-bg\-opacity));-->
|
||||
[RxJs](http://reactivex.io/rxjs/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
在线代码编辑器工具
|
||||
---
|
||||
|
||||
[CodePen](https://codepen.io/)<!--rehype:target=_blank-->
|
||||
[CodeSandbox](https://codesandbox.io/)<!--rehype:target=_blank-->
|
||||
[StackBlitz](https://stackblitz.com/)<!--rehype:target=_blank-->
|
||||
[esbuild](https://esbuild.github.io/)<!--rehype:target=_blank-->
|
||||
[JSFiddle](https://jsfiddle.net/)<!--rehype:target=_blank-->
|
||||
[Replit](https://replit.com/)<!--rehype:target=_blank-->
|
||||
[JSRUN.NET](https://jsrun.net/)<!--rehype:target=_blank-->
|
||||
[WebComponents.dev](https://webcomponents.dev/)<!--rehype:target=_blank-->
|
||||
[JS Bin](https://jsbin.com/)<!--rehype:target=_blank-->
|
||||
[RunKit](https://runkit.com/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
兼容、性能测试
|
||||
---
|
||||
|
||||
[Browser Sandbox](https://turbo.net/browsers)<!--rehype:target=_blank-->
|
||||
[Browserdiet](https://browserdiet.com/zh/)<!--rehype:target=_blank-->
|
||||
[browsershots](http://browsershots.org/)<!--rehype:target=_blank-->
|
||||
[BrowserStack](https://www.browserstack.com/)<!--rehype:target=_blank-->
|
||||
[Can I use](http://caniuse.com/)<!--rehype:target=_blank-->
|
||||
[httpstatus](https://httpstatus.io/)<!--rehype:target=_blank-->
|
||||
[Observatory](https://observatory.mozilla.org/)<!--rehype:target=_blank-->
|
||||
[PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights/?hl=zh-CN)<!--rehype:target=_blank-->
|
||||
[Security Headers](https://securityheaders.com/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
CDN
|
||||
---
|
||||
|
||||
[cdnjs](https://cdnjs.com/)<!--rehype:target=_blank-->
|
||||
[jsDelivr](https://www.jsdelivr.com/)<!--rehype:target=_blank-->
|
||||
[前端静态资源库](https://cdn.baomitu.com/)<!--rehype:target=_blank-->
|
||||
[UNPKG](https://unpkg.com/)<!--rehype:target=_blank-->
|
||||
[Statically](https://statically.io/)<!--rehype:target=_blank-->
|
||||
[raw.githack.com](http://raw.githack.com/)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card-->
|
@ -581,6 +581,7 @@ $ ffmpeg -f concat -i mylist.txt -c:v copy -c:a flac -strict -2 output.mp4
|
||||
|
||||
视频过滤器
|
||||
---
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 格式
|
||||
|
||||
@ -631,7 +632,6 @@ 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 -->
|
||||
|
||||
### 创建缩略图
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
在 10 秒时创建一个缩略图
|
||||
|
||||
@ -686,6 +686,7 @@ $ ffmpeg -i 1.mp4 -i test.mp3 \
|
||||
|
||||
音频过滤器
|
||||
---
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 调节音量
|
||||
|
||||
@ -720,6 +721,7 @@ $ ffmpeg -i input.mp3 -af "channelmap=1-0|1-1" output.mp3
|
||||
|
||||
流处理
|
||||
---
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 拉流
|
||||
|
||||
@ -736,6 +738,7 @@ $ ffmpeg -re -i test.mp4 -f flv rtmp://127.0.0.1/test
|
||||
```
|
||||
|
||||
### 转发
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
# 拉取流并转发
|
||||
|
255
docs/flask.md
Normal file
@ -0,0 +1,255 @@
|
||||
Flask 备忘清单
|
||||
===
|
||||
|
||||
本清单对 Flask 的入门进行了简要的概述,以及其常用示例。需要有 `HTML` 和 `Python` 基础。
|
||||
|
||||
入门
|
||||
-----
|
||||
|
||||
### 相关链接
|
||||
|
||||
- [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) _(developer.mozilla.org)_
|
||||
- [Python](https://www.python.org/) _(python.org)_
|
||||
- [Flask](https://flask.palletsprojects.com/) _(flask.palletsprojects.com)_
|
||||
- [Python 备忘清单](./python.md) _(jaywcjlove.github.io)_
|
||||
|
||||
### Hello World
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### hello.py
|
||||
|
||||
```python
|
||||
# 导入 Flask 类
|
||||
from flask import Flask
|
||||
|
||||
# 创建应用实例
|
||||
app = Flask(__name__) # 'Flask' 参数是 应用程序模块 或 包 的名称
|
||||
# __name__是适用于大多数情况的便捷快捷方式
|
||||
|
||||
# 路由 (装饰器)
|
||||
@app.route('/') # route()装饰器告诉 Flask 什么路径触发下面的功能
|
||||
def hello():
|
||||
# 该函数返回我们想要在浏览器中显示的消息内容
|
||||
return 'Hello World!'
|
||||
# 默认类型 HTML, 因此字符串中的 HTML 将被浏览器渲染
|
||||
# 启动服务
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
```
|
||||
|
||||
### 运行 `hello.py` 程序
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```shell
|
||||
$ python hello.py
|
||||
* Serving Flask app 'hello'
|
||||
* Running on http://127.0.0.1:5000
|
||||
* Press CTRL+C to quit
|
||||
```
|
||||
|
||||
#### 或
|
||||
|
||||
```shell
|
||||
$ flask --app hello run
|
||||
* Serving Flask app 'hello'
|
||||
* Running on http://127.0.0.1:5000
|
||||
* Press CTRL+C to quit
|
||||
$ flask run --host=0.0.0.0
|
||||
```
|
||||
|
||||
启用调试模式,使用 `--debug` 选项
|
||||
|
||||
```bash
|
||||
$ flask --app hello --debug run
|
||||
```
|
||||
|
||||
### HTML 转义
|
||||
|
||||
```py
|
||||
from markupsafe import escape
|
||||
|
||||
@app.route("/<name>")
|
||||
def hello(name):
|
||||
return f"Hello, {escape(name)}!"
|
||||
```
|
||||
|
||||
### 路由
|
||||
|
||||
```py
|
||||
@app.route('/')
|
||||
def index():
|
||||
return 'Index Page'
|
||||
|
||||
@app.route('/hello')
|
||||
def hello():
|
||||
return 'Hello, World'
|
||||
```
|
||||
|
||||
### 变量规则
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```py
|
||||
from markupsafe import escape
|
||||
|
||||
@app.route('/user/<username>')
|
||||
def show_user_profile(username):
|
||||
# 显示该用户的用户个人资料
|
||||
return f'User {escape(username)}'
|
||||
|
||||
@app.route('/post/<int:post_id>')
|
||||
def show_post(post_id):
|
||||
# 显示给定id的帖子,id是一个整数
|
||||
return f'Post {post_id}'
|
||||
|
||||
@app.route('/path/<path:subpath>')
|
||||
def show_subpath(subpath):
|
||||
# 在 /path/ 之后显示子路径
|
||||
return f'Subpath {escape(subpath)}'
|
||||
```
|
||||
|
||||
转换器类型:
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`string` | (默认)接受任何没有斜杠的文本
|
||||
`int` | 接受正整数
|
||||
`float` | 接受正浮点值
|
||||
`path` | 像字符串但也接受斜线
|
||||
`uuid` | 接受 UUID 字符串
|
||||
|
||||
### 唯一 URL / 重定向行为
|
||||
|
||||
```py
|
||||
@app.route('/projects/')
|
||||
def projects():
|
||||
return 'The project page'
|
||||
|
||||
@app.route('/about')
|
||||
def about():
|
||||
return 'The about page'
|
||||
```
|
||||
|
||||
项目端点的规范 `URL` 有一个尾部斜杠。它类似于文件系统中的文件夹。如果您访问没有尾部斜杠 (`/projects`) 的 `URL`,`Flask` 会将您重定向到带有尾部斜杠 (`/projects/`) 的规范 `URL`
|
||||
|
||||
### URL 建设
|
||||
|
||||
```py
|
||||
from flask import url_for
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return 'index'
|
||||
|
||||
@app.route('/login')
|
||||
def login():
|
||||
return 'login'
|
||||
|
||||
@app.route('/user/<username>')
|
||||
def profile(username):
|
||||
return f'{username}\'s profile'
|
||||
|
||||
with app.test_request_context():
|
||||
print(url_for('index'))
|
||||
print(url_for('login'))
|
||||
print(url_for('login', next='/'))
|
||||
print(url_for('profile', username='John Doe'))
|
||||
```
|
||||
|
||||
### HTTP 方法
|
||||
|
||||
默认路由仅响应 `GET` 请求。可以使用 `route()` 装饰器的方法参数来处理不同的 `HTTP` 方法
|
||||
|
||||
```py
|
||||
from flask import request
|
||||
|
||||
@app.route('/login',methods=['GET','POST'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
return do_the_login()
|
||||
else:
|
||||
return show_the_login_form()
|
||||
```
|
||||
|
||||
您还可以将不同方法的视图分成不同的函数。 `Flask` 为每个常见的 `HTTP` 方法提供了一种快捷方式,用于使用 `get()`、`post()` 等来装饰此类路由
|
||||
|
||||
```py
|
||||
@app.get('/login')
|
||||
def login_get():
|
||||
return show_the_login_form()
|
||||
|
||||
@app.post('/login')
|
||||
def login_post():
|
||||
return do_the_login()
|
||||
```
|
||||
|
||||
### Blueprint
|
||||
|
||||
创建蓝图Bp1
|
||||
|
||||
```py
|
||||
from flask import Blueprint, abort, jsonify
|
||||
|
||||
# 定义Bp1,并定义url前缀为/img
|
||||
Bp1 = Blueprint('imgBlue', __name__, template_folder='templates', url_prefix='/img')
|
||||
|
||||
|
||||
@Bp1.route('/getimg')
|
||||
def getImg():
|
||||
try:
|
||||
return jsonify(name="img", size="100KB")
|
||||
except Exception as e:
|
||||
abort(e)
|
||||
```
|
||||
|
||||
创建蓝图Bp2
|
||||
|
||||
```py
|
||||
from flask import Blueprint, abort, jsonify
|
||||
|
||||
# 定义Bp2,并定义url前缀为/vedio
|
||||
Bp2 = Blueprint('vedioBlue', __name__, template_folder='templates', url_prefix='/vedio')
|
||||
|
||||
|
||||
@Bp2.route('/getvedio')
|
||||
def getVedio():
|
||||
try:
|
||||
return jsonify(name="vedio", size="100GB")
|
||||
except Exception as e:
|
||||
abort(e)
|
||||
```
|
||||
|
||||
在flask app中引用蓝图Bp1和Bp2
|
||||
|
||||
```py
|
||||
from flask import Flask, jsonify
|
||||
from lantu.img import Bp1
|
||||
from lantu.vedio import Bp2
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# 注册蓝图到app
|
||||
app.register_blueprint(Bp1)
|
||||
app.register_blueprint(Bp2)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return jsonify(name='phyger')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="127.0.0.1", debug=True)
|
||||
```
|
||||
|
||||
简单测试
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:5000/
|
||||
>> {"name":"phyger"}
|
||||
|
||||
curl http://127.0.0.1:5000/img/getimg
|
||||
>> {"name": "img", "size": "100KB"}
|
||||
|
||||
curl http://127.0.0.1:5000/vedio/getvedio
|
||||
>> {"name": "vedio", "size": "100GB"}
|
||||
```
|
160
docs/flutter.md
@ -729,6 +729,166 @@ Row(
|
||||
|
||||
例如,需要文本和图标位于一个行的两端,而中间留白时。就可以使用 `Spacer`
|
||||
|
||||
### ListView
|
||||
|
||||
`ListView` 是一个支持滚动的列表组件。该组件默认支持上下滑动。
|
||||
`ListView`的默认构造函数,会立即初始化`children`中的所有子`widget`,无法动态加载。
|
||||
|
||||
```dart
|
||||
ListView(
|
||||
children: [
|
||||
Text('1'),
|
||||
Text('2'),
|
||||
Text('3'),
|
||||
Text('4'),
|
||||
],
|
||||
),
|
||||
```
|
||||
|
||||
需要动态加载,则可以使用 `ListView.builder()`命名构函数。
|
||||
|
||||
```dart
|
||||
// 动态生成4个Text
|
||||
ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Text('$index');
|
||||
},
|
||||
itemCount: 4,
|
||||
),
|
||||
```
|
||||
|
||||
需要在对`ListView`中的`Item`添加分割线,则可以借助`ListView.separated()`。
|
||||
|
||||
```dart
|
||||
// separatorBuilder 函数用于在元素之间插入分割线。
|
||||
// 也可以返回其他widget。该widget会被插入各个元素之间。
|
||||
ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Text('$index');
|
||||
},
|
||||
itemCount: 4,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
// 使用Divider widget 画一条粗为5,颜色为红色的线
|
||||
return const Divider(
|
||||
height: 5,
|
||||
thickness: 5,
|
||||
color: Colors.red,
|
||||
);
|
||||
},
|
||||
),
|
||||
```
|
||||
|
||||
### GridView
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
`GridView`可将元素显示为二维网格状的列表组件,并支持主轴方向滚动。
|
||||
使用GridView() 构造函数,需要传入gridDelegate和children。Flutter中已经提供了两种实现方式,分别是:
|
||||
|
||||
- `SliverGridDelegateWithFixedCrossAxisCount()` 用于交叉轴方向固定数。
|
||||
- `SliverGridDelegateWithMaxCrossAxisExtent()` 用于交叉轴方向限制最大长度。
|
||||
|
||||
```dart
|
||||
// 使用SliverGridDelegateWithFixedCrossAxisCount
|
||||
GridView(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
children: List.generate(
|
||||
8,
|
||||
(index) => Container(
|
||||
color: Colors.red[index % 8 * 100],
|
||||
child: Text("index $index"),
|
||||
)),
|
||||
),
|
||||
|
||||
// 使用SliverGridDelegateWithMaxCrossAxisExtent
|
||||
GridView(
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: 200),
|
||||
children: List.generate(
|
||||
8,
|
||||
(index) => Container(
|
||||
color: Colors.red[index % 8 * 100],
|
||||
child: Text("index $index"),
|
||||
),
|
||||
),
|
||||
),
|
||||
```
|
||||
|
||||
`GridView.builder()`命名构造可以实现元素的动态加载,与`ListView.builder()`类似
|
||||
|
||||
```dart
|
||||
GridView.builder(
|
||||
itemCount: 8,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4),
|
||||
itemBuilder: (context, index) => Container(
|
||||
color: Colors.red[index % 8 * 100],
|
||||
child: Text("index $index"),
|
||||
),
|
||||
),
|
||||
```
|
||||
|
||||
`Gridview.count()` 一个简单的构造函数,只需要传入`crossAxisCount`(交叉轴元素的个数)和`children`即可。
|
||||
|
||||
```dart
|
||||
GridView.count(
|
||||
crossAxisCount: 4, // 每行固定为4个
|
||||
children: List.generate(
|
||||
8,
|
||||
(index) => Container(
|
||||
color: Colors.red[index % 8 * 100],
|
||||
child: Text("index $index"),
|
||||
)),
|
||||
),
|
||||
```
|
||||
|
||||
`GridView.extent()` 用于设定每个元素在交叉轴方向的最大尺寸。当程序运行在较大屏幕时通常能看到更多的元素,而不是少量元素的放大版。通过传入`maxCrossAxisExtent`,`Gridview`会根据屏幕尺寸自动选择合适的行数量。
|
||||
|
||||
```dart
|
||||
GridView.extent(
|
||||
maxCrossAxisExtent: 200,
|
||||
children: List.generate(
|
||||
8,
|
||||
(index) => Container(
|
||||
color: Colors.red[index % 8 * 100],
|
||||
child: Text("index $index"),
|
||||
)),
|
||||
),
|
||||
```
|
||||
|
||||
`GridView.count()`和GridView.extent()`可以看作GridView的语法糖。
|
||||
|
||||
### PageView
|
||||
|
||||
使用`PageView`可以实现整屏页面滚动,默认为水平方向翻页。与`ListView`类似。
|
||||
|
||||
- `pageSnapping`参数可以设置滑动时`Page`停留在任意位置。
|
||||
- `scrollDirection`参数设置滚动方向(默认为水平方向)。
|
||||
|
||||
```dart
|
||||
PageView(
|
||||
pageSnapping: false, // 取消页面固定
|
||||
scrollDirection: Axis.vertical, // 设置为垂直方向滚动
|
||||
children: [
|
||||
for (int i = 0; i < 4; i++)
|
||||
Container(
|
||||
color: Colors.red[i % 4 * 100],
|
||||
)
|
||||
],
|
||||
),
|
||||
```
|
||||
|
||||
使用`PageView.builder()`命名构造,可以动态加载页面。与`ListView.builder()`类似。
|
||||
|
||||
```dart
|
||||
PageView.builder(
|
||||
pageSnapping: false,
|
||||
scrollDirection: Axis.vertical,
|
||||
itemBuilder: (BuildContext context, int index) => Container(
|
||||
color: Colors.red[index % 4 * 100],
|
||||
),
|
||||
),
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
37
docs/git.md
@ -395,7 +395,7 @@ $ git log --stat -M
|
||||
```bash
|
||||
$ cat ~/.ssh/config
|
||||
Host gitlab.com
|
||||
# 直接使用 shadowsocks 提供的 socks5 代理端口
|
||||
# 直接使用 sh**socks 提供的 socks5 代理端口
|
||||
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
|
||||
|
||||
Host github.com
|
||||
@ -960,6 +960,41 @@ Host github.com
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
git 代码统计
|
||||
---
|
||||
|
||||
### 查看 git 上的个人代码量
|
||||
|
||||
- `username` 需要改成自己的
|
||||
|
||||
```bash
|
||||
git log --author="username" --pretty=tformat: --numstat | awk \
|
||||
'{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
|
||||
```
|
||||
|
||||
### 统计每个人增删行数
|
||||
|
||||
```bash
|
||||
git log --format='%aN' | sort -u |\
|
||||
while read name; do echo -en "$name\t";\
|
||||
git log --author="$name" --pretty=tformat: --numstat | awk \
|
||||
'{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
|
||||
```
|
||||
|
||||
### 查看仓库提交者排名
|
||||
|
||||
这里是排名前十,也可以更改排名
|
||||
|
||||
```bash
|
||||
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 10
|
||||
```
|
||||
|
||||
### 提交数统计
|
||||
|
||||
```bash
|
||||
git log --oneline | wc -l
|
||||
```
|
||||
|
||||
Conventional Commmits
|
||||
----
|
||||
|
||||
|
@ -70,7 +70,7 @@ func say(message string) {
|
||||
多行注释 */
|
||||
```
|
||||
|
||||
### 如果语句
|
||||
### if 语句
|
||||
|
||||
```go
|
||||
if true {
|
||||
@ -431,7 +431,7 @@ for {
|
||||
}
|
||||
```
|
||||
|
||||
Golang 结构和映射
|
||||
Golang 结构和Maps
|
||||
--------
|
||||
|
||||
### 定义
|
||||
@ -467,7 +467,7 @@ v := Vertex{X: 1}
|
||||
|
||||
您还可以输入字段名
|
||||
|
||||
### 映射
|
||||
### Maps
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
@ -511,7 +511,7 @@ fmt.Println(plus(1, 2))
|
||||
fmt.Println(plusPlus(1, 2, 3))
|
||||
```
|
||||
|
||||
### 多次返回
|
||||
### 多返回值
|
||||
|
||||
```go
|
||||
func vals() (int, int) {
|
||||
@ -533,7 +533,7 @@ r1, r2 := func() (string, string) {
|
||||
fmt.Println(r1, r2)
|
||||
```
|
||||
|
||||
### 命名返回
|
||||
### 命名返回值
|
||||
|
||||
```go
|
||||
func split(sum int) (x, y int) {
|
||||
@ -546,7 +546,7 @@ fmt.Println(x) // => 7
|
||||
fmt.Println(y) // => 10
|
||||
```
|
||||
|
||||
### 变量函数
|
||||
### 可变参数函数
|
||||
|
||||
```go
|
||||
func sum(nums ...int) {
|
||||
@ -557,7 +557,7 @@ func sum(nums ...int) {
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
sum(1, 2) //=> [1 2] 3
|
||||
sum(1, 2) // => [1 2] 3
|
||||
sum(1, 2, 3) // => [1 2 3] 6
|
||||
nums := []int{1, 2, 3, 4}
|
||||
sum(nums...) // => [1 2 3 4] 10
|
||||
@ -987,7 +987,7 @@ Go 命令
|
||||
`GOOS` | 编译系统
|
||||
`GOARCH` | 编译arch
|
||||
`GO111MODULE` | gomod开关
|
||||
`GOPROXY` | go代理 <https://goproxy.io> <https://goproxy.cn>
|
||||
`GOPROXY` | go代理 <https://goproxy.io> <https://goproxy.cn> <https://mirrors.aliyun.com/goproxy/>
|
||||
`GOSSAFUNC` | 生成 `SSA.html` 文件,展示代码优化的每一步 `GOSSAFUNC=func_name go build`
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
|
26
docs/htmx.md
@ -17,9 +17,15 @@
|
||||
[htmx](https://htmx.org/) 是 [intercooler.js](http://intercoolerjs.org/) 的继承者
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/htmx.org@1.8.4"></script>
|
||||
<script
|
||||
src="https://unpkg.com/htmx.org@1.8.4"
|
||||
>
|
||||
</script>
|
||||
<!-- 有一个按钮POST,通过AJAX点击 -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
<button
|
||||
hx-post="/clicked"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
点击我
|
||||
</button>
|
||||
```
|
||||
@ -79,7 +85,7 @@ import 'htmx.org';
|
||||
表单按照通常的 `REST-ful` 模式将 `PUT` 发回 `/contacts/1`
|
||||
|
||||
### 删除行
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```html
|
||||
<table class="table delete-row-example">
|
||||
@ -141,6 +147,20 @@ img {
|
||||
}
|
||||
```
|
||||
|
||||
### hx-swap
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`innerHTML` | 默认,替换目标元素的内部 `html`
|
||||
`outerHTML` | 用响应替换整个目标元素
|
||||
`beforebegin` | 在目标元素之前插入响应
|
||||
`afterbegin` | 目标元素的第一个子元素之前插入响应
|
||||
`beforeend` | 目标元素的最后一个子元素之后插入响应
|
||||
`afterend` | 在目标元素之后插入响应
|
||||
`delete` | 无论响应如何,都删除目标元素
|
||||
`none` | 不附加来自响应的内容 <br />_(带外项目仍将被处理)_
|
||||
<!--rehype:className=left-align-->
|
||||
|
||||
API 参考
|
||||
---
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
195
docs/intelli-j-idea.md
Normal file
@ -0,0 +1,195 @@
|
||||
IntelliJ IDEA 键盘快捷键
|
||||
===
|
||||
|
||||
IntelliJ IDEA 是一款非常优秀的 Java IDE,它的大部分命令都有快捷键,让你的手不离开键盘
|
||||
|
||||
IDEA Windows 和 Linux 键盘映射
|
||||
---
|
||||
|
||||
### 编辑
|
||||
<!--rehype:wrap-class=row-span-5-->
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Ctrl` `Space`| 基本代码完成
|
||||
`Ctrl` `Shift` `Space`| 智能代码完成
|
||||
`Ctrl` `Shift` `Enter`| 完整声明
|
||||
`Ctrl` `P`| 参数信息
|
||||
`Ctrl` `Q`| 快速文档查找
|
||||
`Shift` `F1`| 外部文档
|
||||
`Ctrl` `hover`| 简介
|
||||
`Ctrl` `F1`| 插入符号处的错误或警告
|
||||
`Alt` `Insert`| 生成代码
|
||||
`Ctrl` `O`| 覆盖方法
|
||||
`Ctrl` `I`| 实现方法
|
||||
`Ctrl` `Alt` `T`| 环绕着
|
||||
`Ctrl` `/`| 注释或取消注释行
|
||||
`Ctrl` `Shift` `/`| 评论或取消评论块
|
||||
`Ctrl` `W`| 选择连续递增的代码块
|
||||
`Ctrl` `Shift` `W`| 将当前选择减少到以前的状态
|
||||
`Alt` `Q`| 上下文信息
|
||||
`Alt` `Enter`| 显示意图操作和快速修复
|
||||
`Ctrl` `Alt` `L`| 重新格式化代码
|
||||
`Ctrl` `Alt` `O`| 优化导入
|
||||
`Ctrl` `Alt` `I`| 自动缩进行
|
||||
`Tab`| 缩进所选行
|
||||
`Shift` `Tab`| 取消缩进所选行
|
||||
`Ctrl` `X`| 将当前行或选定的块剪切到剪贴板
|
||||
`Ctrl` `C`| 将当前行或选定的块复制到剪贴板
|
||||
`Ctrl` `V`| 从剪贴板粘贴
|
||||
`Ctrl` `Shift` `V`| 从最近的缓冲区粘贴
|
||||
`Ctrl` `D`| 复制当前行或选定的块
|
||||
`Ctrl` `Y`| 删除插入符处的行
|
||||
`Ctrl` `Shift` `J`| 智能线路加入
|
||||
`Ctrl` `Enter`| 智能分线
|
||||
`Shift` `Enter`| 开始新行
|
||||
`Ctrl` `Shift` `U`| 在插入符号或选定块处切换单词的大小写
|
||||
`Ctrl` `Shift` `]` _/_ `[`| 选择直到代码块结束/开始
|
||||
`Ctrl` `Backspace`| 删除到词尾/开头
|
||||
`Ctrl` `+` _/_ `-`| 展开/折叠代码块
|
||||
`Ctrl` `Shift` `+`| 展开全部
|
||||
`Ctrl` `Shift` `-`| 全部收缩
|
||||
`Ctrl` `F4`| 关闭活动编辑器选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 使用搜索
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Alt` `F7` _/_ `Ctrl` `F7`| 查找用法/在文件中查找用法
|
||||
`Ctrl` `Shift` `F7`| 突出显示文件中的用法
|
||||
`Ctrl` `Alt` `F7`| 显示用法
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 导航
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Ctrl` `N`| 去 class
|
||||
`Ctrl` `Shift` `N`| 转到文件
|
||||
`Ctrl` `Alt` `Shift` `N`| 转到符号
|
||||
`Alt` `Right` _/_ `Left`| 转到下一个/上一个编辑器选项卡
|
||||
`F12`| 返回上一个工具窗口
|
||||
`Esc`| 转到编辑器
|
||||
`Shift` `Esc`| 隐藏活动或最后一个活动窗口
|
||||
`Ctrl` `Shift` `F4`| 关闭活动运行,消息...
|
||||
`Ctrl` `G`| 去线
|
||||
`Ctrl` `E`| 最近的文件弹出窗口
|
||||
`Ctrl` `Alt` `Left` _/_ `Right`| 向后/向前导航
|
||||
`Ctrl` `Shift` `Backspace`| 导航到上次编辑位置
|
||||
`Alt` `F1`| 在任何视图中选择当前文件或符号
|
||||
`Ctrl` `B` _/_ `Ctrl` `Click`| 去申报
|
||||
`Ctrl` `Alt` `B`| 转到实施
|
||||
`Ctrl` `Shift` `I`| 打开快速定义查找
|
||||
`Ctrl` `Shift` `B`| 转到类型声明
|
||||
`Ctrl` `U`| 转到超方法/超类
|
||||
`Alt` `Up` _/_ `Down`| 转到上一个/下一个方法
|
||||
`Ctrl` `]/[`| 移动到代码块结束/开始
|
||||
`Ctrl` `F12`| 文件结构弹出窗口
|
||||
`Ctrl` `H`| 类型层次结构
|
||||
`Ctrl` `Shift` `H`| 方法层次
|
||||
`Ctrl` `Alt` `H`| 调用层级
|
||||
`F2` _/_ `Shift` `F2`| 下一个/上一个突出显示的错误
|
||||
`F4` _/_ `Ctrl` `Enter`| 编辑源/查看源
|
||||
`Alt` `Home`| 显示导航栏
|
||||
`F11`| 切换书签
|
||||
`Ctrl` `F11`| 使用助记符切换书签
|
||||
`Ctrl` `0...9`| 转到编号书签
|
||||
`Shift` `F11`| 显示书签
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 搜索/替换
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Double Shift`| 到处搜索
|
||||
`Ctrl` `F`| 寻找
|
||||
`F3` `Shift` `F3`| 查找下一个/查找上一个
|
||||
`Ctrl` `R`| 代替
|
||||
`Ctrl` `Shift` `F`| 在路径中查找
|
||||
`Ctrl` `Shift` `R`| 在路径中替换
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 实时模板
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Ctrl` `Alt` `J` | 用实时模板环绕
|
||||
`Ctrl` `J` | 插入实时模板
|
||||
`iter` | 按照Java SDK 1.5风格迭代
|
||||
`inst` | 使用 instanceof 检查对象类型并将其向下转换
|
||||
`itco` | 迭代 java.util.Collection 的元素
|
||||
`itit` | 迭代 java.util.Iterator 的元素
|
||||
`itli` | 迭代 java.util.List 的元素
|
||||
`psf` | 公共静态决赛
|
||||
`thr` | 扔新的
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 重构
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`F5` | 复制
|
||||
`F6` | 移动
|
||||
`Alt` `Delete` | 安全删除
|
||||
`Shift` `F6` | 改名
|
||||
`Ctrl` `F6` | 更改签名
|
||||
`Ctrl` `Alt` `N` | 排队
|
||||
`Ctrl` `Alt` `M` | 提取方法
|
||||
`Ctrl` `Alt` `V` | 提取变量
|
||||
`Ctrl` `Alt` `F` | 提取字段
|
||||
`Ctrl` `Alt` `C` | 提取常量
|
||||
`Ctrl` `Alt` `P` | 提取参数
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调试
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`F8/F7` | 跨过/进入
|
||||
`Shift` `F7` _/_ `Shift` `F8` | 智能步入/走出
|
||||
`Alt` `F9` | 运行到光标处
|
||||
`Alt` `F8` | 评估表达
|
||||
`F9` | 恢复程序
|
||||
`Ctrl` `F8` | 切换断点
|
||||
`Ctrl` `Shift` `F8` | 查看断点
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 编译运行
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Ctrl` `F9` | 做项目
|
||||
`Ctrl` `Shift` `F9` | 编译选定的文件、包或模块
|
||||
`Alt` `Shift` `F10` _/_ `F9` | 选择配置并运行/和调试
|
||||
`Shift` `F10` _/_ `F9` | 运行/调试
|
||||
`Ctrl` `Shift` `F10` | 从编辑器运行上下文配置
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### VCS/本地历史
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Ctrl` `K` | 提交项目到 VCS
|
||||
`Ctrl` `T` | 从 VCS 更新
|
||||
`Alt` `Shift` `C` | 查看最近的更改
|
||||
`Alt` <kbd>\`</kbd> | VCS 操作弹出窗口
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 一般的
|
||||
|
||||
快捷键 | 说明
|
||||
:-- | --
|
||||
`Alt` `0...9` | 打开相应的工具窗口
|
||||
`Ctrl` `S` | 保存全部
|
||||
`Ctrl` `Alt` `Y` | 同步
|
||||
`Ctrl` `Shift` `F12` | 切换最大化编辑器
|
||||
`Alt` `Shift` `F` | 添加到收藏夹
|
||||
`Alt` `Shift` `I` | 检查当前文件
|
||||
`Ctrl` <kbd>\`</kbd> | 快速切换电流方案
|
||||
`Ctrl` `Alt` `S` | 打开设置对话框
|
||||
`Ctrl` `Alt` `Shift` `S` | 打开项目结构对话框
|
||||
`Ctrl` `Shift` `A` | 寻找行动
|
||||
`Ctrl` `Tab` | 在工具和选项卡之间切换
|
||||
<!--rehype:className=shortcuts-->
|
@ -1,7 +1,7 @@
|
||||
iptables 备忘清单
|
||||
====
|
||||
|
||||
iptables 是一个配置 Linux 内核 防火墙(opens new window)的命令行工具,是 [netfilter](https://en.wikipedia.org/wiki/Netfilter)(opens new window)项目的一部分。这个快速参考备忘单显示了它的常用命令使用清单
|
||||
iptables 是一个配置 Linux 内核防火墙的命令行工具,是 [netfilter](https://en.wikipedia.org/wiki/Netfilter) 项目的一部分。这个快速参考备忘单显示了它的常用命令使用清单
|
||||
|
||||
入门
|
||||
---
|
||||
|
36
docs/java.md
@ -89,7 +89,7 @@ boolean[] answers = {true, false};
|
||||
|
||||
查看: [Arrays](#java-数组)
|
||||
|
||||
### Swap
|
||||
### 交换变量 Swap
|
||||
|
||||
```java
|
||||
int a = 1;
|
||||
@ -101,7 +101,7 @@ b = temp;
|
||||
System.out.println(a + " " + b); // 2 1
|
||||
```
|
||||
|
||||
### Type Casting
|
||||
### 类型转换 Type Casting
|
||||
|
||||
```java
|
||||
// Widening
|
||||
@ -344,7 +344,7 @@ for (int a: arr) {
|
||||
// 输出: a b c
|
||||
```
|
||||
|
||||
### Multidimensional Arrays
|
||||
### 二维数组 Multidimensional Arrays
|
||||
|
||||
```java
|
||||
int[][] matrix = { {1, 2, 3}, {4, 5} };
|
||||
@ -359,7 +359,7 @@ for (int i = 0; i < a.length; ++i) {
|
||||
// 输出: 1 2 3 4 5 6 7
|
||||
```
|
||||
|
||||
### Sort
|
||||
### 排序 Sort
|
||||
|
||||
```java
|
||||
char[] chars = {'b', 'a', 'c'};
|
||||
@ -547,10 +547,10 @@ for (int i = 0; i < 5; i++) {
|
||||
Java 框架搜集
|
||||
--------------------
|
||||
|
||||
### Java 搜集
|
||||
### Java 集合
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
搜集 | Interface | 有序 | 已排序 | 线程安全 | 复制 | Nullable
|
||||
集合 | Interface | 有序 | 已排序 | 线程安全 | 复制 | Nullable
|
||||
:-|:-|:-|:-|:-|:-|:-
|
||||
[ArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html) | List | Y | _N_ | _N_ | Y | Y
|
||||
[Vector](https://docs.oracle.com/javase/8/docs/api/java/util/Vector.html) | List | Y | _N_ | Y | Y | Y
|
||||
@ -615,6 +615,25 @@ m.forEach((key, value) -> {
|
||||
});
|
||||
```
|
||||
|
||||
### ConcurrentHashMap
|
||||
|
||||
```java
|
||||
ConcurrentHashMap<Integer, String> m
|
||||
= new ConcurrentHashMap<>();
|
||||
m.put(100, "Hello");
|
||||
m.put(101, "Geeks");
|
||||
m.put(102, "Geeks");
|
||||
// 移除
|
||||
m.remove(101, "Geeks");
|
||||
|
||||
// 如果不存在,就添加,存在就不变更
|
||||
m.putIfAbsent(103, "Hello");
|
||||
|
||||
// 替换
|
||||
m.replace(101, "Hello", "For");
|
||||
System.out.println(m);
|
||||
```
|
||||
|
||||
### HashSet
|
||||
|
||||
```java
|
||||
@ -771,7 +790,7 @@ text.split(Pattern.quote("|"));
|
||||
`Math.toDegrees(rad)` | 以度为单位的角度弧度
|
||||
`Math.toRadians(deg)` | 以弧度为单位的角度度
|
||||
|
||||
### Try/Catch/Finally
|
||||
### 异常 Try/Catch/Finally
|
||||
|
||||
```java
|
||||
try {
|
||||
@ -816,6 +835,9 @@ method.invoke(classLoader, url);
|
||||
- `SecureRandom` 实例用于生成安全的伪随机数流
|
||||
- `UUID` 表示一个不可变的通用唯一标识符
|
||||
- `Vector` 实现了一个可增长的对象数组
|
||||
- `LocalDate` 表示没有时区的日期,只包含年月日,不可变并且线程安全的,java8 及以上版本可用
|
||||
- `LocalTime` 表示没有时区的时间,只包含时分秒,不可变并且线程安全的,java8 及以上版本可用
|
||||
- `LocalDateTime` 表示没有时区的日期时间,同时包含年月日时分秒,不可变并且线程安全的,java8 及以上版本可用
|
||||
|
||||
另见
|
||||
---
|
||||
|
@ -1190,6 +1190,99 @@ console.log(myCat.name);
|
||||
myCat.name = 'Yankee';
|
||||
```
|
||||
|
||||
### Proxy
|
||||
|
||||
Proxy 对象用于创建一个对象的代理,从而实现基本操作的拦截和自定义(如属性查找、赋值、枚举、函数调用等)。
|
||||
|
||||
```javascript
|
||||
// 用于拦截对象的读取属性操作。
|
||||
const handler = {
|
||||
get: function(obj, prop) {
|
||||
return prop in obj ? obj[prop] : 37;
|
||||
}
|
||||
};
|
||||
|
||||
const p = new Proxy({}, handler);
|
||||
p.a = 1;
|
||||
p.b = undefined;
|
||||
|
||||
console.log(p.a, p.b); // 1, undefined
|
||||
console.log('c' in p, p.c); // false, 37
|
||||
```
|
||||
|
||||
#### 语法
|
||||
|
||||
```javascript
|
||||
const p = new Proxy(target, handler)
|
||||
```
|
||||
|
||||
- target 要使用 Proxy 包装的目标对象(可以是任何类型的对象,包括原生数组,函数,甚至另一个代理)。
|
||||
- handler 一个通常以函数作为属性的对象,各属性中的函数分别定义了在执行各种操作时代理 p 的行为。
|
||||
|
||||
#### 方法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`Proxy.revocable()` | 创建一个可撤销的Proxy对象 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
|
||||
|
||||
#### handler 对象的方法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`handler.getPrototypeOf()` | Object.getPrototypeOf 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getPrototypeOf)
|
||||
`handler.setPrototypeOf()` | Object.setPrototypeOf 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/setPrototypeOf)
|
||||
`handler.isExtensible()` | Object.isExtensible 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/isExtensible)
|
||||
`handler.preventExtensions()` | Object.preventExtensions 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/preventExtensions)
|
||||
`handler.getOwnPropertyDescriptor()` | Object.getOwnPropertyDescriptor 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor)
|
||||
`handler.defineProperty()` | Object.defineProperty 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/defineProperty)
|
||||
`handler.has()` | in 操作符的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/has)
|
||||
`handler.get()` | 属性读取操作的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get)
|
||||
`handler.set()` | 属性设置操作的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/set)
|
||||
`handler.deleteProperty()` | delete 操作符的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/deleteProperty)
|
||||
`handler.ownKeys()` | Object.getOwnPropertyNames 方法和 Object.getOwnPropertySymbols 方法的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/ownKeys)
|
||||
`handler.apply()` | 函数调用操作的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/apply)
|
||||
`handler.construct()` | new 操作符的捕捉器 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/construct)
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### Reflect
|
||||
|
||||
Reflect 是一个内置的对象,它提供拦截 JavaScript 操作的方法。这些方法与proxy handlers (en-US)的方法相同。Reflect不是一个函数对象,因此它是不可构造的。
|
||||
|
||||
```javascript
|
||||
// 检测一个对象是否存在特定属性
|
||||
const duck = {
|
||||
name: 'Maurice',
|
||||
color: 'white',
|
||||
greeting: function() {
|
||||
console.log(`Quaaaack! My name is ${this.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reflect.has(duck, 'color');
|
||||
// true
|
||||
Reflect.has(duck, 'haircut');
|
||||
// false
|
||||
```
|
||||
|
||||
#### 静态方法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`Reflect.apply(target, thisArgument, argumentsList)` | 对一个函数进行调用操作,同时可以传入一个数组作为调用参数。和 Function.prototype.apply() 功能类似 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
|
||||
`Reflect.construct(target, argumentsList[, newTarget])` | 对构造函数进行 new 操作,相当于执行 new target(...args) [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
|
||||
`Reflect.defineProperty(target, propertyKey, attributes)` | 和 Object.defineProperty() 类似。如果设置成功就会返回 true [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
|
||||
`Reflect.deleteProperty(target, propertyKey)` | 作为函数的delete操作符,相当于执行 delete target[name] [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
|
||||
`Reflect.get(target, propertyKey[, receiver])` | 获取对象身上某个属性的值,类似于 target[name] [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
|
||||
`Reflect.getOwnPropertyDescriptor(target, propertyKey)` | 类似于 Object.getOwnPropertyDescriptor()。如果对象中存在该属性,则返回对应的属性描述符,否则返回 undefined [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
|
||||
`Reflect.getPrototypeOf(target)` | 类似于 Object.getPrototypeOf() [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
|
||||
`Reflect.has(target, propertyKey)` | 判断一个对象是否存在某个属性,和 in 运算符 的功能完全相同 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
|
||||
`Reflect.isExtensible(target)` | 类似于 Object.isExtensible() [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
|
||||
`Reflect.ownKeys(target)` | 返回一个包含所有自身属性(不包含继承属性)的数组。(类似于 Object.keys(), 但不会受enumerable 影响) [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
|
||||
`Reflect.preventExtensions(target)` | 类似于 Object.preventExtensions()。返回一个Boolean [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
|
||||
`Reflect.set(target, propertyKey, value[, receiver])` | 将值分配给属性的函数。返回一个Boolean,如果更新成功,则返回true [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
|
||||
`Reflect.setPrototypeOf(target, prototype)` | 设置对象原型的函数。返回一个 Boolean,如果更新成功,则返回 true [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
JavaScript this 绑定
|
||||
----
|
||||
|
||||
|
689
docs/jquery.md
Normal file
@ -0,0 +1,689 @@
|
||||
jQuery 备忘清单
|
||||
===
|
||||
|
||||
[jQuery](https://jquery.com/) 备忘单对于初学者和有经验的开发人员都是很好的参考
|
||||
|
||||
入门
|
||||
-----
|
||||
|
||||
### 引入 jQuery
|
||||
|
||||
```js
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
#### 官方 CDN
|
||||
|
||||
```js
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### jQuery 语法
|
||||
|
||||
```js
|
||||
$(selector).methodOrFunction();
|
||||
```
|
||||
|
||||
#### 例子
|
||||
|
||||
```js
|
||||
$('#menu').on('click', () =>{
|
||||
$(this).hide();
|
||||
});
|
||||
$("body").css("background", "red");
|
||||
```
|
||||
|
||||
### jQuery 文档准备就绪
|
||||
|
||||
```js
|
||||
$(document).ready(function() {
|
||||
// 在加载 DOM 后运行
|
||||
alert('DOM fully loaded!');
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
$(function(){
|
||||
// 在加载 DOM 后运行
|
||||
alert('DOM fully loaded!');
|
||||
});
|
||||
```
|
||||
|
||||
jQuery 选择器
|
||||
----------
|
||||
|
||||
### 例子
|
||||
|
||||
```js
|
||||
$("button").click(() => {
|
||||
$(":button").css("color", "red");
|
||||
});
|
||||
```
|
||||
|
||||
#### 组合选择器
|
||||
|
||||
```js
|
||||
$("selector1, selector2 ...selectorn")
|
||||
```
|
||||
|
||||
### 基本
|
||||
|
||||
- [*](https://api.jquery.com/all-selector/) _选择所有元素_<!--rehype:tooltips-->
|
||||
- [.class](https://api.jquery.com/class-selector/) _选择具有给定类的所有元素_<!--rehype:tooltips-->
|
||||
- [element](https://api.jquery.com/element-selector/) _选择具有给定标签名称的所有元素_<!--rehype:tooltips-->
|
||||
- [#id](https://api.jquery.com/id-selector/) _选择具有给定 id 属性的单个元素_<!--rehype:tooltips-->
|
||||
- [:hidden](https://api.jquery.com/hidden-selector/) _选择所有隐藏的元素_<!--rehype:tooltips-->
|
||||
- [:visible](https://api.jquery.com/visible-selector/) _选择所有可见的元素_<!--rehype:tooltips-->
|
||||
- [:contains()](https://api.jquery.com/contains-selector/) _选择包含指定文本的所有元素_<!--rehype:tooltips-->
|
||||
- [:empty](https://api.jquery.com/empty-selector/) _选择所有没有子元素的元素(包括文本节点)_<!--rehype:tooltips-->
|
||||
- [:has()](https://api.jquery.com/has-selector/) _选择至少包含一个与指定选择器匹配的元素的元素_<!--rehype:tooltips-->
|
||||
- [:parent](https://api.jquery.com/parent-selector/) _选择具有至少一个子节点(元素或文本)的所有元素_<!--rehype:tooltips-->
|
||||
- [parent > child](https://api.jquery.com/child-selector/) _选择由父元素指定的子元素指定的所有直接子元素_<!--rehype:tooltips-->
|
||||
- [ancestor descendant](https://api.jquery.com/descendant-selector/) _选择作为给定祖先的后代的所有元素_<!--rehype:tooltips-->
|
||||
- [prev + next](https://api.jquery.com/next-adjacent-Selector/) _选择所有与 next 匹配且紧接在其前面的同级 prev 的下一个元素_<!--rehype:tooltips-->
|
||||
- [prev ~ siblings](https://api.jquery.com/next-siblings-selector/) _选择 prev 元素之后的所有同级元素,具有相同的父元素,并匹配过滤同级选择器_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 基本过滤器
|
||||
|
||||
- [:animated](https://api.jquery.com/animated-selector/) _在运行选择器时选择动画进度中的所有元素_<!--rehype:tooltips-->
|
||||
- [:eq()](https://api.jquery.com/eq-selector/) _选择匹配集中索引 n 处的元素_<!--rehype:tooltips-->
|
||||
- [:even](https://api.jquery.com/even-selector/) _选择偶数元素,索引为零。 另见:奇数_<!--rehype:tooltips-->
|
||||
- [:first](https://api.jquery.com/first-selector/) _选择第一个匹配的 DOM 元素_<!--rehype:tooltips-->
|
||||
- [:gt()](https://api.jquery.com/gt-selector/) _选择匹配集中索引大于索引的所有元素_<!--rehype:tooltips-->
|
||||
- [:header](https://api.jquery.com/header-selector/) _选择所有标题元素,如 h1、h2、h3 等_<!--rehype:tooltips-->
|
||||
- [:lang()](https://api.jquery.com/lang-selector/) _选择指定语言的所有元素_<!--rehype:tooltips-->
|
||||
- [:last](https://api.jquery.com/last-selector/) _选择最后一个匹配的元素_<!--rehype:tooltips-->
|
||||
- [:lt()](https://api.jquery.com/lt-selector/) _选择匹配集中索引小于索引的所有元素_<!--rehype:tooltips-->
|
||||
- [:not()](https://api.jquery.com/not-selector/) _选择与给定选择器不匹配的所有元素_<!--rehype:tooltips-->
|
||||
- [:odd](https://api.jquery.com/odd-selector/) _选择奇数元素,索引为零。 另见:甚至_<!--rehype:tooltips-->
|
||||
- [:root](https://api.jquery.com/root-selector/) _选择作为文档根的元素_<!--rehype:tooltips-->
|
||||
- [:target](https://api.jquery.com/target-selector/) _选择由文档的 URI 的片段标识符指示的目标元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 属性
|
||||
|
||||
- [[name|="value"]](https://api.jquery.com/attribute-contains-prefix-selector/) _选择具有指定属性且值等于给定字符串或以该字符串开头后跟连字符 (-) 的元素_<!--rehype:tooltips-->
|
||||
- [[name*="value"]](https://api.jquery.com/attribute-contains-selector/) _选择具有指定属性且值包含给定子字符串的元素_<!--rehype:tooltips-->
|
||||
- [[name~="value"]](https://api.jquery.com/attribute-contains-word-selector/) _选择具有指定属性的元素,其值包含给定单词,由空格分隔_<!--rehype:tooltips-->
|
||||
- [[name$="value"]](https://api.jquery.com/attribute-ends-with-selector/) _选择具有指定属性且值恰好以给定字符串结尾的元素。 比较区分大小写_<!--rehype:tooltips-->
|
||||
- [[name="value"]](https://api.jquery.com/attribute-equals-selector/) _选择具有指定属性且值恰好等于特定值的元素_<!--rehype:tooltips-->
|
||||
- [[name!="value"]](https://api.jquery.com/attribute-not-equal-selector/) _选择不具有指定属性或具有指定属性但不具有特定值的元素_<!--rehype:tooltips-->
|
||||
- [[name^="value"]](https://api.jquery.com/attribute-starts-with-selector/) _选择具有指定属性且值恰好以给定字符串开头的元素_<!--rehype:tooltips-->
|
||||
- [[name]](https://api.jquery.com/has-attribute-selector/) _选择具有指定属性和任意值的元素_<!--rehype:tooltips-->
|
||||
- [[name="value"][name2="value2"]](https://api.jquery.com/multiple-attribute-selector/) _匹配匹配所有指定属性过滤器的元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 子过滤器
|
||||
|
||||
- [:first-child](https://api.jquery.com/first-child-selector/) _选择作为其父元素的第一个子元素的所有元素_<!--rehype:tooltips-->
|
||||
- [:first-of-type](https://api.jquery.com/first-of-type-selector/) _选择具有相同元素名称的兄弟姐妹中第一个的所有元素_<!--rehype:tooltips-->
|
||||
- [:last-child](https://api.jquery.com/last-child-selector/) _选择作为其父元素的最后一个子元素的所有元素_<!--rehype:tooltips-->
|
||||
- [:last-of-type](https://api.jquery.com/last-of-type-selector/) _选择具有相同元素名称的兄弟中最后一个的所有元素_<!--rehype:tooltips-->
|
||||
- [:nth-child()](https://api.jquery.com/nth-child-selector/) _选择作为其父元素的第 n 个子元素的所有元素_<!--rehype:tooltips-->
|
||||
- [:nth-last-child()](https://api.jquery.com/nth-last-child-selector/) _选择作为其父元素的第 n 个子元素的所有元素,从最后一个元素到第一个元素计数_<!--rehype:tooltips-->
|
||||
- [:nth-last-of-type()](https://api.jquery.com/nth-last-of-type-selector/) _选择所有元素,这些元素是其父元素的第 n 个子元素,相对于具有相同元素名称的兄弟元素,从最后一个元素到第一个元素计数_<!--rehype:tooltips-->
|
||||
- [:nth-of-type()](https://api.jquery.com/nth-of-type-selector/) _选择所有元素,这些元素是其父元素相对于具有相同元素名称的兄弟元素的第 n 个子元素_<!--rehype:tooltips-->
|
||||
- [:only-child](https://api.jquery.com/only-child-selector/) _选择作为其父元素的唯一子元素的所有元素_<!--rehype:tooltips-->
|
||||
- [:only-of-type()](https://api.jquery.com/only-of-type-selector/) _选择所有没有同名元素的元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### Forms
|
||||
|
||||
- [:button](https://api.jquery.com/button-selector/) _选择所有按钮元素和按钮类型的元素_<!--rehype:tooltips-->
|
||||
- [:checkbox](https://api.jquery.com/checkbox-selector/) _选择复选框类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:checked](https://api.jquery.com/checked-selector/) _匹配所有选中或选择的元素_<!--rehype:tooltips-->
|
||||
- [:disabled](https://api.jquery.com/disabled-selector/) _选择所有禁用的元素_<!--rehype:tooltips-->
|
||||
- [:enabled](https://api.jquery.com/enabled-selector/) _选择所有启用的元素_<!--rehype:tooltips-->
|
||||
- [:focus](https://api.jquery.com/focus-selector/) _如果当前获得焦点,则选择元素_<!--rehype:tooltips-->
|
||||
- [:file](https://api.jquery.com/file-selector/) _选择类型文件的所有元素_<!--rehype:tooltips-->
|
||||
- [:image](https://api.jquery.com/image-selector/) _选择图像类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:input](https://api.jquery.com/input-selector/) _选择所有输入、文本区域、选择和按钮元素_<!--rehype:tooltips-->
|
||||
- [:password](https://api.jquery.com/password-selector/) _选择密码类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:radio](https://api.jquery.com/radio-selector/) _选择无线电类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:reset](https://api.jquery.com/reset-selector/) _选择重置类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:selected](https://api.jquery.com/selected-selector/) _选择所有选中的元素_<!--rehype:tooltips-->
|
||||
- [:submit](https://api.jquery.com/submit-selector/) _选择提交类型的所有元素_<!--rehype:tooltips-->
|
||||
- [:text](https://api.jquery.com/text-selector/) _选择文本类型的所有输入元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
jQuery 属性
|
||||
-----
|
||||
|
||||
### 例子
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
$('h2').css({
|
||||
color: 'blue',
|
||||
backgroundColor: 'gray',
|
||||
fontSize: '24px'
|
||||
});
|
||||
```
|
||||
|
||||
#### jQuery 添加类
|
||||
|
||||
```js
|
||||
$('.button').addClass('active');
|
||||
```
|
||||
|
||||
#### jQuery 移除类
|
||||
|
||||
```js
|
||||
$('.button').on('mouseleave', evt => {
|
||||
let e = evt.currentTarget;
|
||||
$(e).removeClass('active');
|
||||
});
|
||||
```
|
||||
|
||||
#### jQuery 切换类
|
||||
|
||||
```js
|
||||
$('.choice').toggleClass('highlighted');
|
||||
```
|
||||
|
||||
### Attributes
|
||||
|
||||
- [.attr()](https://api.jquery.com/attr/) _获取匹配元素集中第一个元素的属性值_<!--rehype:tooltips-->
|
||||
- [.prop()](https://api.jquery.com/prop/) _获取匹配元素集中第一个元素的属性值_<!--rehype:tooltips-->
|
||||
- [.removeAttr()](https://api.jquery.com/removeAttr/) _从匹配元素集中的每个元素中删除一个属性_<!--rehype:tooltips-->
|
||||
- [.removeProp()](https://api.jquery.com/removeProp/) _删除匹配元素集的属性_<!--rehype:tooltips-->
|
||||
- [.val()](https://api.jquery.com/val/) _获取匹配元素集中第一个元素的当前值_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
#### Data
|
||||
|
||||
- [jQuery.data()](https://api.jquery.com/jQuery.data/) _存储与指定元素关联的任意数据。 返回设置的值_<!--rehype:tooltips-->
|
||||
- [.data()](https://api.jquery.com/data/) _存储与匹配元素关联的任意数据_<!--rehype:tooltips-->
|
||||
- [jQuery.hasData()](https://api.jquery.com/jQuery.hasData/) _确定一个元素是否有任何与之关联的 jQuery 数据_<!--rehype:tooltips-->
|
||||
- [jQuery.removeData()](https://api.jquery.com/jQuery.removeData/) _删除以前存储的数据_<!--rehype:tooltips-->
|
||||
- [.removeData()](https://api.jquery.com/removeData/) _删除以前存储的数据_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### CSS
|
||||
|
||||
- [.addClass()](https://api.jquery.com/addClass/) _将指定的类添加到匹配元素集中的每个元素_<!--rehype:tooltips-->
|
||||
- [.hasClass()](https://api.jquery.com/hasClass/) _确定是否有任何匹配的元素被分配给给定的类_<!--rehype:tooltips-->
|
||||
- [.removeClass()](https://api.jquery.com/removeClass/) _从匹配元素集中的每个元素中删除单个类、多个类或所有类_<!--rehype:tooltips-->
|
||||
- [.toggleClass()](https://api.jquery.com/toggleClass/) _根据类的存在或状态参数的值,从匹配元素集中的每个元素添加或删除一个或多个类_<!--rehype:tooltips-->
|
||||
- [.css()](https://api.jquery.com/css/) _获取匹配元素集中第一个元素的计算样式属性_<!--rehype:tooltips-->
|
||||
- [jQuery.cssHooks](https://api.jquery.com/jQuery.cssHooks/) _直接连接到 jQuery 以覆盖特定 CSS 属性的检索或设置方式、标准化 CSS 属性命名或创建自定义属性_<!--rehype:tooltips-->
|
||||
- [jQuery.cssNumber](https://api.jquery.com/jQuery.cssNumber/) _包含所有可以在没有单位的情况下使用的 CSS 属性的对象。`.css()` 方法使用此对象来查看它是否可以将 px 附加到无单位值_<!--rehype:tooltips-->
|
||||
- [jQuery.escapeSelector()](https://api.jquery.com/jQuery.escapeSelector/) _转义任何在 CSS 选择器中具有特殊含义的字符_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### Dimensions
|
||||
|
||||
- [.height()](https://api.jquery.com/height/) _获取匹配元素集中第一个元素的当前计算高度_<!--rehype:tooltips-->
|
||||
- [.innerHeight()](https://api.jquery.com/innerHeight/) _获取匹配元素集中第一个元素的当前计算高度,包括填充但不包括边框_<!--rehype:tooltips-->
|
||||
- [.innerWidth()](https://api.jquery.com/innerWidth/) _获取匹配元素集中第一个元素的当前计算内部宽度,包括填充但不包括边框_<!--rehype:tooltips-->
|
||||
- [.outerHeight()](https://api.jquery.com/outerHeight/) _获取匹配元素集中第一个元素的当前计算外部高度(包括填充、边框和可选的边距)_<!--rehype:tooltips-->
|
||||
- [.outerWidth()](https://api.jquery.com/outerWidth/) _获取匹配元素集中第一个元素的当前计算外部宽度(包括填充、边框和可选的边距)_<!--rehype:tooltips-->
|
||||
- [.width()](https://api.jquery.com/width/) _获取匹配元素集中第一个元素的当前计算宽度_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### Offset
|
||||
|
||||
- [.offset()](https://api.jquery.com/offset/) _获取匹配元素集中第一个元素相对于文档的当前坐标_<!--rehype:tooltips-->
|
||||
- [.offsetParent()](https://api.jquery.com/offsetParent/) _获取定位的最近的祖先元素_<!--rehype:tooltips-->
|
||||
- [.position()](https://api.jquery.com/position/) _获取匹配元素集中第一个元素相对于偏移父元素的当前坐标_<!--rehype:tooltips-->
|
||||
- [.scrollLeft()](https://api.jquery.com/scrollLeft/) _获取匹配元素集中第一个元素的滚动条的当前水平位置_<!--rehype:tooltips-->
|
||||
- [.scrollTop()](https://api.jquery.com/scrollTop/) _获取匹配元素集中第一个元素的滚动条的当前垂直位置,或为每个匹配元素设置滚动条的垂直位置_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
jQuery 操控
|
||||
------------
|
||||
|
||||
### Examples
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```js
|
||||
/*<span>Span.</span>*/
|
||||
$('span').after('<p>Paragraph.</p>');
|
||||
/*<span>Span.</span><p>Paragraph.</p>*/
|
||||
/*<span>Span.</span>*/
|
||||
$('<span>Span.</span>').replaceAll('p');
|
||||
/*<p>Span.</p>*/
|
||||
/*<span>This is span.</span>*/
|
||||
$('span').wrap('<p></p>');
|
||||
/*<p><span>This is span.</span></p>*/
|
||||
```
|
||||
|
||||
### 复刻
|
||||
|
||||
- [.clone()](https://api.jquery.com/clone/) _创建匹配元素集的深层副本_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 插入,环绕
|
||||
|
||||
- [.wrap()](https://api.jquery.com/wrap/) _在匹配元素集中的每个元素周围包装一个 HTML 结构_<!--rehype:tooltips-->
|
||||
- [.wrapAll()](https://api.jquery.com/wrapAll/) _在匹配元素集中的所有元素周围包装一个 HTML 结构_<!--rehype:tooltips-->
|
||||
- [.wrapInner()](https://api.jquery.com/wrapInner/) _围绕匹配元素集中每个元素的内容包装一个 HTML 结构_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 插入,内部
|
||||
|
||||
- [.append()](https://api.jquery.com/append/) _在匹配的元素集中,插入由参数指定的内容插入每个元素的末尾_<!--rehype:tooltips-->
|
||||
- [.appendTo()](https://api.jquery.com/appendTo/) _将匹配元素集中的每个元素插入目标末端_<!--rehype:tooltips-->
|
||||
- [.html()](https://api.jquery.com/html/) _在匹配元素集中获取第一个元素的HTML内容_<!--rehype:tooltips-->
|
||||
- [.prepend()](https://api.jquery.com/prepend/) _插入由参数指定的内容插入匹配元素集中每个元素的开始_<!--rehype:tooltips-->
|
||||
- [.prependTo()](https://api.jquery.com/prependTo/) _将匹配元素集中的每个元素插入目标开始_<!--rehype:tooltips-->
|
||||
- [.text()](https://api.jquery.com/text/) _在匹配的元素集(包括其后代)中获取每个元素的组合文本内容_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 插入,外部
|
||||
|
||||
- [.after()](https://api.jquery.com/after/) _在匹配元素集中的每个元素之后,插入由参数指定的内容_<!--rehype:tooltips-->
|
||||
- [.before()](https://api.jquery.com/before/) _在匹配元素集中的每个元素之前,插入由参数指定的内容_<!--rehype:tooltips-->
|
||||
- [.insertAfter()](https://api.jquery.com/insertAfter/) _在目标之后插入匹配元素集中的每个元素_<!--rehype:tooltips-->
|
||||
- [.insertBefore()](https://api.jquery.com/insertBefore/) _在目标之前插入匹配元素集中的每个元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 移除
|
||||
|
||||
- [.detach()](https://api.jquery.com/detach/) _从DOM上删除一组匹配的元素_<!--rehype:tooltips-->
|
||||
- [.empty()](https://api.jquery.com/empty/) _从DOM中删除一组匹配元素的所有子节点_<!--rehype:tooltips-->
|
||||
- [.remove()](https://api.jquery.com/remove/) _从DOM上删除一组匹配的元素_<!--rehype:tooltips-->
|
||||
- [.unwrap()](https://api.jquery.com/unwrap/) _从DOM上删除一组匹配元素的父母,将匹配的元素留在其位置_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 替换
|
||||
|
||||
- [.replaceAll()](https://api.jquery.com/replaceAll/) _用匹配的元素集替换每个目标元素_<!--rehype:tooltips-->
|
||||
- [.replaceWith()](https://api.jquery.com/replaceWith/) _用提供的新内容替换一组匹配元素中的每个元素,然后返回已删除的元素集_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
jQuery 遍历
|
||||
------------
|
||||
|
||||
### 过滤
|
||||
|
||||
- [.eq()](https://api.jquery.com/eq/) _将匹配的元素集减少到指定索引处的集合_<!--rehype:tooltips-->
|
||||
- [.filter()](https://api.jquery.com/filter/) _将匹配的元素集减少到匹配选择器或传递函数测试的元素_<!--rehype:tooltips-->
|
||||
- [.first()](https://api.jquery.com/first/) _将匹配的元素集减少到集合中的第一个_<!--rehype:tooltips-->
|
||||
- [.has()](https://api.jquery.com/has/) _将匹配的元素集减少到具有与选择器或DOM元素相匹配的后代的元素_<!--rehype:tooltips-->
|
||||
- [.is()](https://api.jquery.com/is/) _检查当前匹配的元素与选择器,元素或jQuery对象的元素集,如果至少其中一个元素与给定参数匹配,则返回true_<!--rehype:tooltips-->
|
||||
- [.last()](https://api.jquery.com/last/) _将匹配的元素集减少到集合中的最后一个元素_<!--rehype:tooltips-->
|
||||
- [.map()](https://api.jquery.com/map/) _将当前匹配的每个元素通过函数传递,从而产生包含返回值的新jQuery对象_<!--rehype:tooltips-->
|
||||
- [.not()](https://api.jquery.com/not/) _从匹配元素集中删除元素_<!--rehype:tooltips-->
|
||||
- [.slice()](https://api.jquery.com/slice/) _将匹配的元素集减少为由一系列索引指定的子集_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 杂项遍历
|
||||
|
||||
- [.add()](https://api.jquery.com/add/) _创建一个新的jQuery对象,其中添加到匹配元素集中的元素_<!--rehype:tooltips-->
|
||||
- [.addBack()](https://api.jquery.com/addBack/) _将堆栈上的上一个元素添加到当前集合中,并由选择器进行过滤_<!--rehype:tooltips-->
|
||||
- [.andSelf()](https://api.jquery.com/andSelf/) _将堆栈上的先前元素添加到当前集合中_<!--rehype:tooltips-->
|
||||
- [.contents()](https://api.jquery.com/contents/) _在一组匹配元素中获取每个元素的孩子,包括文本和评论节点_<!--rehype:tooltips-->
|
||||
- [.each()](https://api.jquery.com/each/) _在jQuery对象上迭代,为每个匹配的元素执行一个函数_<!--rehype:tooltips-->
|
||||
- [.end()](https://api.jquery.com/end/) _结束当前链中最新的过滤操作,并将匹配元素集返回其先前状态_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 树遍历
|
||||
|
||||
- [.children()](https://api.jquery.com/children/) _在一组匹配元素中获取每个元素的孩子,并被选择器进行过滤_<!--rehype:tooltips-->
|
||||
- [.closest()](https://api.jquery.com/closest/) _对于集合中的每个元素,通过测试元素本身并通过其祖先在DOM树中的祖先进行遍历来获取与选择器匹配的第一个元素_<!--rehype:tooltips-->
|
||||
- [.find()](https://api.jquery.com/find/) _在当前匹配元素集中获取每个元素的后代,并由选择器,jQuery对象或元素过滤_<!--rehype:tooltips-->
|
||||
- [.next()](https://api.jquery.com/next/) _在匹配的元素集中,立即获取每个元素的兄弟姐妹。 如果提供了选择器,则仅在匹配该选择器的情况下才能检索下一个兄弟姐妹_<!--rehype:tooltips-->
|
||||
- [.nextAll()](https://api.jquery.com/nextAll/) _在一组匹配元素中获取每个元素的所有以下兄弟姐妹,并由选择器进行过滤_<!--rehype:tooltips-->
|
||||
- [.nextUntil()](https://api.jquery.com/nextUntil/) _将每个元素的所有以下兄弟姐妹添加到,但不包括通过选择器,DOM节点或jQuery对象匹配的元素_<!--rehype:tooltips-->
|
||||
- [.parent()](https://api.jquery.com/parent/) _在当前匹配元素集中获取每个元素的父,由选择器选择过滤_<!--rehype:tooltips-->
|
||||
- [.parents()](https://api.jquery.com/parents/) _在当前匹配元素集中获取每个元素的祖先,并被选择器进行过滤_<!--rehype:tooltips-->
|
||||
- [.parentsUntil()](https://api.jquery.com/parentsUntil/) _在当前匹配元素集中获取每个元素的祖先,直到但不包括由选择器,DOM节点或jQuery对象匹配的元素_<!--rehype:tooltips-->
|
||||
- [.prev()](https://api.jquery.com/prev/) _在匹配元素集中获取每个元素的立即兄弟姐妹。 如果提供了选择器,则仅在匹配该选择器时才检索先前的同胞_<!--rehype:tooltips-->
|
||||
- [.prevAll()](https://api.jquery.com/prevAll/) _在一组匹配元素中获取每个元素的所有先前兄弟姐妹,并由选择器进行过滤_<!--rehype:tooltips-->
|
||||
- [.prevUntil()](https://api.jquery.com/prevUntil/) _将每个元素的所有先前兄弟姐妹添加到,但不包括由选择器,DOM节点或jQuery对象匹配的元素_<!--rehype:tooltips-->
|
||||
- [.siblings()](https://api.jquery.com/siblings/) _在匹配的元素集中获取每个元素的兄弟姐妹,并被选择器进行过滤_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
jQuery 事件
|
||||
------------
|
||||
|
||||
### Examples
|
||||
<!--rehype:wrap-class=row-span-6-->
|
||||
|
||||
```js
|
||||
// 鼠标事件“点击”
|
||||
$('#menu-button').on('click', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
// 键盘事件“键盘”
|
||||
$('#textbox').on('keyup', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
// 滚动事件“滚动”
|
||||
$('#menu-button').on('scroll', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
```
|
||||
|
||||
#### 事件对象
|
||||
|
||||
```js
|
||||
$('#menu').on('click', event => {
|
||||
$(event.currentTarget).hide();
|
||||
});
|
||||
```
|
||||
|
||||
#### 方法链
|
||||
|
||||
```js
|
||||
$('#menu-btn').on('mouseenter', () => {
|
||||
$('#menu').show();
|
||||
}).on('mouseleave', () => {
|
||||
$('#menu').hide();
|
||||
});
|
||||
```
|
||||
|
||||
#### 防止事件
|
||||
|
||||
```js
|
||||
$( "p" ).click(function( event ) {
|
||||
event.stopPropagation();
|
||||
// Do something
|
||||
});
|
||||
```
|
||||
|
||||
### 浏览器事件
|
||||
|
||||
- [.error()](https://api.jquery.com/error/) _将事件处理程序绑定到错误 JavaScript 事件_ <!--rehype:tooltips-->
|
||||
- [.resize()](https://api.jquery.com/resize/) _将事件处理程序绑定到调整大小的 JavaScript 事件,或在元素上触发该事件_ <!--rehype:tooltips-->
|
||||
- [.scroll()](https://api.jquery.com/scroll/) _将事件处理程序绑定到滚动 JavaScript 事件,或在元素上触发该事件_ <!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 事件对象
|
||||
<!--rehype:wrap-class=row-span-6-->
|
||||
|
||||
- [event.currentTarget](https://api.jquery.com/event.currentTarget/) _事件冒泡阶段中的当前 DOM 元素_ <!--rehype:tooltips-->
|
||||
- [event.delegateTarget](https://api.jquery.com/event.delegateTarget/) _附加了当前调用的 jQuery 事件处理程序的元素_ <!--rehype:tooltips-->
|
||||
- [event.data](https://api.jquery.com/event.data/) _绑定当前正在执行的处理程序时传递给事件方法的可选数据对象_ <!--rehype:tooltips-->
|
||||
- [event.isDefaultPrevented()](https://api.jquery.com/event.isDefaultPrevented/) _返回是否曾在此事件对象上调用过 event.preventDefault()_ <!--rehype:tooltips-->
|
||||
- [event.isImmediatePropagationStopped()](https://api.jquery.com/event.isImmediatePropagationStopped/) _返回是否曾在此事件对象上调用过 event.stopImmediatePropagation()_ <!--rehype:tooltips-->
|
||||
- [event.isPropagationStopped()](https://api.jquery.com/event.isPropagationStopped/) _返回是否曾在此事件对象上调用过 event.stopPropagation()_ <!--rehype:tooltips-->
|
||||
- [event.metaKey](https://api.jquery.com/event.metaKey/) _指示事件触发时是否按下了 META 键_ <!--rehype:tooltips-->
|
||||
- [event.namespace](https://api.jquery.com/event.namespace/) _触发事件时指定的命名空间_ <!--rehype:tooltips-->
|
||||
- [event.pageX](https://api.jquery.com/event.pageX/) _鼠标相对于文档左边缘的位置_ <!--rehype:tooltips-->
|
||||
- [event.pageY](https://api.jquery.com/event.pageY/) _鼠标位置相对于文档的上边缘_ <!--rehype:tooltips-->
|
||||
- [event.preventDefault()](https://api.jquery.com/event.preventDefault/) _如果调用该方法,则不会触发事件的默认动作_ <!--rehype:tooltips-->
|
||||
- [event.relatedTarget](https://api.jquery.com/event.relatedTarget/) _事件中涉及的其他 DOM 元素(如果有)_ <!--rehype:tooltips-->
|
||||
- [event.result](https://api.jquery.com/event.result/) _由此事件触发的事件处理程序返回的最后一个值,除非该值未定义_ <!--rehype:tooltips-->
|
||||
- [event.stopImmediatePropagation()](https://api.jquery.com/event.stopImmediatePropagation/) _保持其余的处理程序不被执行,并防止事件在 DOM 树中向上冒泡_ <!--rehype:tooltips-->
|
||||
- [event.stopPropagation()](https://api.jquery.com/event.stopPropagation/) _防止事件在 DOM 树中向上冒泡,从而防止任何父处理程序收到事件通知_ <!--rehype:tooltips-->
|
||||
- [event.target](https://api.jquery.com/event.target/) _发起事件的 DOM 元素_ <!--rehype:tooltips-->
|
||||
- [event.timeStamp](https://api.jquery.com/event.timeStamp/) _浏览器创建事件的时间与 1970 年 1 月 1 日之间的毫秒差_ <!--rehype:tooltips-->
|
||||
- [event.type](https://api.jquery.com/event.type/) _描述事件的性质_ <!--rehype:tooltips-->
|
||||
- [event.which](https://api.jquery.com/event.which/) _对于键或鼠标事件,此属性指示按下的特定键或按钮_ <!--rehype:tooltips-->
|
||||
<!--rehype:className=style-none-->
|
||||
|
||||
### 文档加载
|
||||
|
||||
- [.load()](https://api.jquery.com/load-event/) _将事件处理程序绑定到加载 JavaScript 事件_<!--rehype:tooltips-->
|
||||
- [.ready()](https://api.jquery.com/ready/) _指定在 DOM 完全加载时执行的函数_<!--rehype:tooltips-->
|
||||
- [.unload()](https://api.jquery.com/unload/) _将事件处理程序绑定到卸载 JavaScript 事件_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 事件处理程序附件
|
||||
|
||||
- [.bind()](https://api.jquery.com/bind/) _将处理程序附加到元素的事件_<!--rehype:tooltips-->
|
||||
- [.delegate()](https://api.jquery.com/delegate/) _基于一组特定的根元素,将处理程序附加到现在或将来与选择器匹配的所有元素的一个或多个事件_<!--rehype:tooltips-->
|
||||
- [.die()](https://api.jquery.com/die/) _从元素中删除先前使用 .live() 附加的事件处理程序_<!--rehype:tooltips-->
|
||||
- [.live()](https://api.jquery.com/live/) _现在和将来为所有匹配当前选择器的元素附加一个事件处理程序_<!--rehype:tooltips-->
|
||||
- [.off()](https://api.jquery.com/off/) _删除事件处理程序_<!--rehype:tooltips-->
|
||||
- [.on()](https://api.jquery.com/on/) _将一个或多个事件的事件处理函数附加到所选元素_<!--rehype:tooltips-->
|
||||
- [.one()](https://api.jquery.com/one/) _将处理程序附加到元素的事件。 每个事件类型的每个元素最多执行一次处理程序_<!--rehype:tooltips-->
|
||||
- [.trigger()](https://api.jquery.com/trigger/) _执行附加到给定事件类型的匹配元素的所有处理程序和行为_<!--rehype:tooltips-->
|
||||
- [.triggerHandler()](https://api.jquery.com/triggerHandler/) _执行附加到事件元素的所有处理程序_<!--rehype:tooltips-->
|
||||
- [.unbind()](https://api.jquery.com/unbind/) _从元素中删除先前附加的事件处理程序_<!--rehype:tooltips-->
|
||||
- [.undelegate()](https://api.jquery.com/undelegate/) _根据一组特定的根元素,从与当前选择器匹配的所有元素的事件中删除处理程序_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 形式事件
|
||||
|
||||
- [.blur()](https://api.jquery.com/blur/) _将事件处理程序绑定到 blur JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.change()](https://api.jquery.com/change/) _将事件处理程序绑定到更改 JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.focus()](https://api.jquery.com/focus/) _将事件处理程序绑定到焦点 JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.focusin()](https://api.jquery.com/focusin/) _将事件处理程序绑定到 focusin 事件_<!--rehype:tooltips-->
|
||||
- [.focusout()](https://api.jquery.com/focusout/) _将事件处理程序绑定到 focusout JavaScript 事件_<!--rehype:tooltips-->
|
||||
- [.select()](https://api.jquery.com/select/) _将事件处理程序绑定到 select JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.submit()](https://api.jquery.com/submit/) _将事件处理程序绑定到提交 JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 键盘事件
|
||||
|
||||
- [.keydown()](https://api.jquery.com/keydown/) _将事件处理程序绑定到 keydown JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.keypress()](https://api.jquery.com/keypress/) _将事件处理程序绑定到按键 JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.keyup()](https://api.jquery.com/keyup/) _将事件处理程序绑定到 keyup JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 鼠标事件
|
||||
|
||||
- [.click()](https://api.jquery.com/click/) _将事件处理程序绑定到 click JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.contextMenu()](https://api.jquery.com/contextmenu/) _将事件处理程序绑定到 contextmenu JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.dblclick()](https://api.jquery.com/dblclick/) _将事件处理程序绑定到 dblclick JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.hover()](https://api.jquery.com/hover/) _将两个处理程序绑定到匹配的元素,当鼠标指针进入和离开元素时执行_<!--rehype:tooltips-->
|
||||
- [.mousedown()](https://api.jquery.com/mousedown/) _将事件处理程序绑定到 mousedown JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.mouseenter()](https://api.jquery.com/mouseenter/) _绑定要在鼠标进入元素时触发的事件处理程序,或在元素上触发该处理程序_<!--rehype:tooltips-->
|
||||
- [.mouseleave()](https://api.jquery.com/mouseleave/) _绑定要在鼠标离开元素时触发的事件处理程序,或在元素上触发该处理程序_<!--rehype:tooltips-->
|
||||
- [.mousemove()](https://api.jquery.com/mousemove/) _将事件处理程序绑定到 mousemove JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.mouseout()](https://api.jquery.com/mouseout/) _将事件处理程序绑定到 mouseout JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.mouseover()](https://api.jquery.com/mouseover/) _将事件处理程序绑定到 mouseover JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.mouseup()](https://api.jquery.com/mouseup/) _将事件处理程序绑定到 mouseup JavaScript 事件,或在元素上触发该事件_<!--rehype:tooltips-->
|
||||
- [.toggle()](https://api.jquery.com/toggle-event/) _将两个或多个处理程序绑定到匹配的元素,以在交替单击时执行_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
jQuery Effects
|
||||
------------
|
||||
|
||||
### 例子
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
$('#menu-button').on('click', () => {
|
||||
// $('#menu').fadeIn(400, 'swing')
|
||||
$('#menu').fadeIn();
|
||||
});
|
||||
```
|
||||
|
||||
#### 淡出效果
|
||||
|
||||
```js
|
||||
$('#menu-button').on('click', () => {
|
||||
// $('#menu').fadeOut(400, 'swing')
|
||||
$('#menu').fadeOut();
|
||||
});
|
||||
```
|
||||
|
||||
### 基本
|
||||
|
||||
- [.hide()](https://api.jquery.com/hide/) _隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
- [.show()](https://api.jquery.com/show/) _显示匹配的元素_<!--rehype:tooltips-->
|
||||
- [.toggle()](https://api.jquery.com/toggle/) _显示或隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 滑动
|
||||
|
||||
- [.slideDown()](https://api.jquery.com/slideDown/) _以滑动方式显示匹配的元素_<!--rehype:tooltips-->
|
||||
- [.slideToggle()](https://api.jquery.com/slideToggle/) _通过滑动显示或隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
- [.slideUp()](https://api.jquery.com/slideUp/) _通过滑动隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 自定义
|
||||
|
||||
- [.animate()](https://api.jquery.com/animate/) _执行一组 CSS 属性的自定义动画_<!--rehype:tooltips-->
|
||||
- [.clearQueue()](https://api.jquery.com/clearQueue/) _从队列中删除所有尚未运行的项目_<!--rehype:tooltips-->
|
||||
- [.delay()](https://api.jquery.com/delay/) _设置一个计时器来延迟队列中后续项目的执行_<!--rehype:tooltips-->
|
||||
- [.dequeue()](https://api.jquery.com/dequeue/) _为匹配的元素执行队列上的下一个函数_<!--rehype:tooltips-->
|
||||
- [jQuery.dequeue()](https://api.jquery.com/jQuery.dequeue/) _为匹配的元素执行队列上的下一个函数_<!--rehype:tooltips-->
|
||||
- [.finish()](https://api.jquery.com/finish/) _停止当前运行的动画,移除所有排队的动画,并完成匹配元素的所有动画_<!--rehype:tooltips-->
|
||||
- [jQuery.fx.interval](https://api.jquery.com/jQuery.fx.interval/) _动画触发的速率(以毫秒为单位)_<!--rehype:tooltips-->
|
||||
- [jQuery.fx.off](https://api.jquery.com/jQuery.fx.off/) _全局禁用所有动画_<!--rehype:tooltips-->
|
||||
- [jQuery.speed](https://api.jquery.com/jQuery.speed/) _创建一个对象,其中包含一组准备用于自定义动画定义的属性_<!--rehype:tooltips-->
|
||||
- [.queue()](https://api.jquery.com/queue/) _显示要在匹配元素上执行的函数队列_<!--rehype:tooltips-->
|
||||
- [jQuery.queue()](https://api.jquery.com/jQuery.queue/) _显示要在匹配元素上执行的函数队列_<!--rehype:tooltips-->
|
||||
- [.stop()](https://api.jquery.com/stop/) _停止匹配元素上当前运行的动画_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 衰退
|
||||
|
||||
- [.fadeIn()](https://api.jquery.com/fadeIn/) _通过将匹配的元素淡化为不透明来显示它们_<!--rehype:tooltips-->
|
||||
- [.fadeOut()](https://api.jquery.com/fadeOut/) _通过将它们淡化为透明来隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
- [.fadeTo()](https://api.jquery.com/fadeTo/) _调整匹配元素的不透明度_<!--rehype:tooltips-->
|
||||
- [.fadeToggle()](https://api.jquery.com/fadeToggle/) _通过设置不透明度动画来显示或隐藏匹配的元素_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
jQuery Ajax
|
||||
------------
|
||||
|
||||
### Examples
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
$.ajax({
|
||||
url: this.action,
|
||||
type: this.method,
|
||||
data: $(this).serialize()
|
||||
}).done(function(server_data){
|
||||
console.log("success" + server_data);
|
||||
}).fail(function(jqXHR, status, err){
|
||||
console.log("fail" + err);
|
||||
});
|
||||
```
|
||||
|
||||
### 全局 Ajax 事件处理程序
|
||||
|
||||
- [.ajaxComplete()](https://api.jquery.com/ajaxComplete/) _注册要在 Ajax 请求完成时调用的处理程序。 这是一个 AjaxEvent_<!--rehype:tooltips-->
|
||||
- [.ajaxError()](https://api.jquery.com/ajaxError/) _注册一个处理程序,当 Ajax 请求完成但出现错误时调用。 这是一个 Ajax 事件_<!--rehype:tooltips-->
|
||||
- [.ajaxSend()](https://api.jquery.com/ajaxSend/) _附加一个要在发送 Ajax 请求之前执行的函数。 这是一个 Ajax 事件_<!--rehype:tooltips-->
|
||||
- [.ajaxStart()](https://api.jquery.com/ajaxStart/) _注册一个处理程序,在第一个 Ajax 请求开始时调用。 这是一个 Ajax 事件_<!--rehype:tooltips-->
|
||||
- [.ajaxStop()](https://api.jquery.com/ajaxStop/) _注册一个处理程序,在所有 Ajax 请求完成时调用。 这是一个 Ajax 事件_<!--rehype:tooltips-->
|
||||
- [.ajaxSuccess()](https://api.jquery.com/ajaxSuccess/) _附加一个要在 Ajax 请求成功完成时执行的函数。 这是一个 Ajax 事件_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 辅助功能
|
||||
|
||||
- [jQuery.param()](https://api.jquery.com/jQuery.param/) _创建适合在 URL 查询字符串或 Ajax 请求中使用的数组、普通对象或 jQuery 对象的序列化表示。 如果传递了 jQuery 对象,它应该包含具有名称/值属性的输入元素_<!--rehype:tooltips-->
|
||||
- [.serialize()](https://api.jquery.com/serialize/) _将一组表单元素编码为字符串以供提交_<!--rehype:tooltips-->
|
||||
- [.serializeArray()](https://api.jquery.com/serializeArray/) _将一组表单元素编码为名称和值的数组_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 底层接口
|
||||
|
||||
- [jQuery.ajax()](https://api.jquery.com/jQuery.ajax/) _执行异步 HTTP (Ajax) 请求_<!--rehype:tooltips-->
|
||||
- [jQuery.prefilter()](https://api.jquery.com/jQuery.ajaxPrefilter/) _在发送每个请求之前和 $.ajax() 处理它们之前处理自定义 Ajax 选项或修改现有选项_<!--rehype:tooltips-->
|
||||
- [jQuery.ajaxSetup()](https://api.jquery.com/jQuery.ajaxSetup/) _为将来的 Ajax 请求设置默认值。 不推荐使用它_<!--rehype:tooltips-->
|
||||
- [jQuery.ajaxTransport()](https://api.jquery.com/jQuery.ajaxTransport/) _创建一个对象来处理 Ajax 数据的实际传输_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 速记方法
|
||||
|
||||
- [jQuery.get()](https://api.jquery.com/jQuery.get/) _使用 HTTP GET 请求从服务器加载数据_<!--rehype:tooltips-->
|
||||
- [jQuery.getJSON()](https://api.jquery.com/jQuery.getJSON/) _使用 GET HTTP 请求从服务器加载 JSON 编码的数据_<!--rehype:tooltips-->
|
||||
- [jQuery.getScript()](https://api.jquery.com/jQuery.getScript/) _使用 GET HTTP 请求从服务器加载 JavaScript 文件,然后执行它_<!--rehype:tooltips-->
|
||||
- [jQuery.post()](https://api.jquery.com/jQuery.post/) _使用 HTTP POST 请求将数据发送到服务器_<!--rehype:tooltips-->
|
||||
- [.load()](https://api.jquery.com/load/) _从服务器加载数据并将返回的 HTML 放入匹配的元素中_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
各种各样的
|
||||
------------
|
||||
|
||||
### jQuery 对象
|
||||
|
||||
- [jQuery()](https://api.jquery.com/jQuery/) _接受包含 CSS 选择器的字符串,然后用于匹配一组元_<!--rehype:tooltips-->
|
||||
- [jQuery.noConflict()](https://api.jquery.com/jQuery.noConflict/) _放弃 jQuery 对 $ 变量的控_<!--rehype:tooltips-->
|
||||
- [jQuery.sub()](https://api.jquery.com/jQuery.sub/) _创建一个新的 jQuery 副本,可以在不影响原始 jQuery 对象的情况下修改其属性和方_<!--rehype:tooltips-->
|
||||
- [jQuery.holdReady()](https://api.jquery.com/jQuery.holdReady/) _持有或释放jQuery的就绪事件的执_<!--rehype:tooltips-->
|
||||
- [jQuery.when()](https://api.jquery.com/jQuery.when/) _提供一种基于零个或多个 Thenable 对象执行回调函数的方法,通常是表示异步事件的 Deferred 对_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 延迟对象
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
- [jQuery.Deferred()](https://api.jquery.com/jQuery.Deferred/) _返回可链接实用程序对象的工厂函数,该对象具有将多个回调注册到回调队列、调用回调队列以及中继任何同步或异步函数的成功或失败状态的方法_<!--rehype:tooltips-->
|
||||
- [deferred.always()](https://api.jquery.com/deferred.always/) _添加要在延迟对象被解析或拒绝时调用的处理程序_<!--rehype:tooltips-->
|
||||
- [deferred.done()](https://api.jquery.com/deferred.done/) _添加要在解析延迟对象时调用的处理程序_<!--rehype:tooltips-->
|
||||
- [deferred.fail()](https://api.jquery.com/deferred.fail/) _添加处理程序以在延迟对象被拒绝时调用_<!--rehype:tooltips-->
|
||||
- [deferred.isRejected()](https://api.jquery.com/deferred.isRejected/) _判断一个 Deferred 对象是否被拒绝_<!--rehype:tooltips-->
|
||||
- [deferred.isResolved()](https://api.jquery.com/deferred.isResolved/) _判断一个 Deferred 对象是否已经解析_<!--rehype:tooltips-->
|
||||
- [deferred.notify()](https://api.jquery.com/deferred.notify/) _使用给定的 args 在 Deferred 对象上调用 progressCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.notifyWith()](https://api.jquery.com/deferred.notifyWith/) _使用给定的上下文和参数调用 Deferred 对象的 progressCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.pipe()](https://api.jquery.com/deferred.pipe/) _过滤和/或链接 Deferreds 的实用方法_<!--rehype:tooltips-->
|
||||
- [deferred.progress()](https://api.jquery.com/deferred.progress/) _添加在 Deferred 对象生成进度通知时要调用的处理程序_<!--rehype:tooltips-->
|
||||
- [deferred.promise()](https://api.jquery.com/deferred.promise/) _返回一个 Deferred 的 Promise 对象_<!--rehype:tooltips-->
|
||||
- [deferred.reject()](https://api.jquery.com/deferred.reject/) _拒绝 Deferred 对象并使用给定的 args 调用任何 failCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.rejectWith()](https://api.jquery.com/deferred.rejectWith/) _拒绝 Deferred 对象并使用给定的上下文和参数调用任何 failCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.resolve()](https://api.jquery.com/deferred.resolve/) _解析一个 Deferred 对象并使用给定的 args 调用任何 doneCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.resolveWith()](https://api.jquery.com/deferred.resolveWith/) _解析延迟对象并使用给定的上下文和参数调用任何 doneCallbacks_<!--rehype:tooltips-->
|
||||
- [deferred.state()](https://api.jquery.com/deferred.state/) _确定 Deferred 对象的当前状态_<!--rehype:tooltips-->
|
||||
- [deferred.then()](https://api.jquery.com/deferred.then/) _添加要在延迟对象被解析、拒绝或仍在进行中时调用的处理程序_<!--rehype:tooltips-->
|
||||
- [.promise()](https://api.jquery.com/promise/) _返回一个 Promise 对象以观察绑定到集合的特定类型的所有操作(无论是否排队)何时完成_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 公用事业
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
- [jQuery.boxModel](https://api.jquery.com/jQuery.boxModel/) _说明用户浏览器中的当前页面是否正在使用 W3C CSS 盒模型呈现_<!--rehype:tooltips-->
|
||||
- [jQuery.browser](https://api.jquery.com/jQuery.browser/) _包含用户代理的标志,从 navigator.userAgent 读取。 此属性在 jQuery 1.9 中被删除,只能通过 jQuery.migrate 插件使用。 请尝试改用特征检测_<!--rehype:tooltips-->
|
||||
- [jQuery.contains()](https://api.jquery.com/jQuery.contains/) _检查一个 DOM 元素是否是另一个 DOM 元素的后代_<!--rehype:tooltips-->
|
||||
- [jQuery.each()](https://api.jquery.com/jQuery.each/) _通用迭代器函数,可用于无缝迭代对象和数组。 具有长度属性的数组和类似数组的对象(例如函数的参数对象)按数字索引迭代,从 0 到 length-1。 其他对象通过它们的命名属性迭代_<!--rehype:tooltips-->
|
||||
- [jQuery.extend()](https://api.jquery.com/jQuery.extend/) _将两个或多个对象的内容合并到第一个对象中_<!--rehype:tooltips-->
|
||||
- [jQuery.globalEval()](https://api.jquery.com/jQuery.globalEval/) _全局执行一些 JavaScript 代码_<!--rehype:tooltips-->
|
||||
- [jQuery.grep()](https://api.jquery.com/jQuery.grep/) _查找满足过滤功能的数组元素。 原数组不受影响_<!--rehype:tooltips-->
|
||||
- [jQuery.inArray()](https://api.jquery.com/jQuery.inArray/) _在数组中搜索指定值并返回其索引(如果未找到,则返回 -1)_<!--rehype:tooltips-->
|
||||
- [jQuery.isArray()](https://api.jquery.com/jQuery.isArray/) _判断参数是否为数组_<!--rehype:tooltips-->
|
||||
- [jQuery.isEmptyObject()](https://api.jquery.com/jQuery.isEmptyObject/) _检查对象是否为空(不包含可枚举属性)_<!--rehype:tooltips-->
|
||||
- [jQuery.isFunction()](https://api.jquery.com/jQuery.isFunction/) _确定其参数是否可作为函数调用_<!--rehype:tooltips-->
|
||||
- [jQuery.isNumeric()](https://api.jquery.com/jQuery.isNumeric/) _确定其参数是否表示 JavaScript 数字_<!--rehype:tooltips-->
|
||||
- [jQuery.isPlainObject()](https://api.jquery.com/jQuery.isPlainObject/) _检查对象是否为普通对象_<!--rehype:tooltips-->
|
||||
- [jQuery.isWindow()](https://api.jquery.com/jQuery.isWindow/) _判断参数是否为窗口_<!--rehype:tooltips-->
|
||||
- [jQuery.isXMLDoc()](https://api.jquery.com/jQuery.isXMLDoc/) _检查 DOM 节点是否在 XML 文档中(或者是 XML 文档)_<!--rehype:tooltips-->
|
||||
- [jQuery.makeArray()](https://api.jquery.com/jQuery.makeArray/) _将类数组对象转换为真正的 JavaScript 数组_<!--rehype:tooltips-->
|
||||
- [jQuery.map()](https://api.jquery.com/jQuery.map/) _将数组或对象中的所有项转换为新的项数组_<!--rehype:tooltips-->
|
||||
- [jQuery.merge()](https://api.jquery.com/jQuery.merge/) _将两个数组的内容合并到第一个数组中_<!--rehype:tooltips-->
|
||||
- [jQuery.noop()](https://api.jquery.com/jQuery.noop/) _空函数_<!--rehype:tooltips-->
|
||||
- [jQuery.now()](https://api.jquery.com/jQuery.now/) _返回代表当前时间的数字_<!--rehype:tooltips-->
|
||||
- [jQuery.parseHTML()](https://api.jquery.com/jQuery.parseHTML/) _将字符串解析为 DOM 节点数组_<!--rehype:tooltips-->
|
||||
- [jQuery.parseJSON()](https://api.jquery.com/jQuery.parseJSON/) _获取格式正确的 JSON 字符串并返回生成的 JavaScript 值_<!--rehype:tooltips-->
|
||||
- [jQuery.parseXML()](https://api.jquery.com/jQuery.parseXML/) _将字符串解析为 XML 文档_<!--rehype:tooltips-->
|
||||
- [jQuery.proxy()](https://api.jquery.com/jQuery.proxy/) _接受一个函数并返回一个总是有特定上下文的新函数_<!--rehype:tooltips-->
|
||||
- [jQuery.support](https://api.jquery.com/jQuery.support/) _表示存在不同浏览器功能或错误的属性集合。 用于 jQuery 的内部使用; 当内部不再需要特定属性以提高页面启动性能时,可能会删除它们。 对于您自己项目的功能检测需求,我们强烈建议使用外部库(例如 Modernizr),而不是依赖于 jQuery.support 中的属性_<!--rehype:tooltips-->
|
||||
- [jQuery.trim()](https://api.jquery.com/jQuery.trim/) _删除字符串开头和结尾的空格_<!--rehype:tooltips-->
|
||||
- [jQuery.type()](https://api.jquery.com/jQuery.type/) _确定对象的内部 JavaScript [[Class]]_<!--rehype:tooltips-->
|
||||
- [jQuery.unique()](https://api.jquery.com/jQuery.unique/) _对 DOM 元素数组进行适当的排序,并删除重复项。 请注意,这仅适用于 DOM 元素数组,不适用于字符串或数字_<!--rehype:tooltips-->
|
||||
- [jQuery.uniqueSort()](https://api.jquery.com/jQuery.uniqueSort/) _对 DOM 元素数组进行适当的排序,并删除重复项。 请注意,这仅适用于 DOM 元素数组,不适用于字符串或数字_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### DOM 元素方法
|
||||
|
||||
- [.get()](https://api.jquery.com/get/) _检索与 jQuery 对象匹配的元素之一_<!--rehype:tooltips-->
|
||||
- [.index()](https://api.jquery.com/index/) _从匹配的元素中搜索给定的元素_<!--rehype:tooltips-->
|
||||
- [.size()](https://api.jquery.com/size/) _返回 jQuery 对象中元素的数量_<!--rehype:tooltips-->
|
||||
- [.toArray()](https://api.jquery.com/toArray/) _检索 jQuery 集合中包含的所有元素,作为数组_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 内部结构
|
||||
|
||||
- [.jquery](https://api.jquery.com/jquery-2/) _包含 jQuery 版本号的字符串_<!--rehype:tooltips-->
|
||||
- [.context](https://api.jquery.com/context/) _最初传递给 jQuery() 的 DOM 节点上下文; 如果未通过,则上下文可能是文档_<!--rehype:tooltips-->
|
||||
- [jQuery.error()](https://api.jquery.com/jQuery.error/) _获取一个字符串并抛出包含它的异常_<!--rehype:tooltips-->
|
||||
- [.length](https://api.jquery.com/length/) _jQuery 对象中元素的数量_<!--rehype:tooltips-->
|
||||
- [.pushStack()](https://api.jquery.com/pushStack/) _将一组 DOM 元素添加到 jQuery 堆栈中_<!--rehype:tooltips-->
|
||||
- [.selector](https://api.jquery.com/selector/) _代表选择器的选择器在创建原始集合时传递给 jQuery(),如果有的话_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### 回调对象
|
||||
|
||||
- [jQuery.Callbacks()](https://api.jquery.com/jQuery.Callbacks/) _一个多用途回调列表对象,提供了一种管理回调列表的强大方法_<!--rehype:tooltips-->
|
||||
- [callbacks.add()](https://api.jquery.com/callbacks.add/) _将回调或回调集合添加到回调列表_<!--rehype:tooltips-->
|
||||
- [callbacks.disable()](https://api.jquery.com/callbacks.disable/) _禁止回调列表做更多的事情_<!--rehype:tooltips-->
|
||||
- [callbacks.disabled()](https://api.jquery.com/callbacks.disabled/) _确定回调列表是否已被禁用_<!--rehype:tooltips-->
|
||||
- [callbacks.empty()](https://api.jquery.com/callbacks.empty/) _从列表中删除所有回调_<!--rehype:tooltips-->
|
||||
- [callbacks.fire()](https://api.jquery.com/callbacks.fire/) _使用给定参数调用所有回调_<!--rehype:tooltips-->
|
||||
- [callbacks.fired()](https://api.jquery.com/callbacks.fired/) _确定回调是否已至少被调用一次_<!--rehype:tooltips-->
|
||||
- [callbacks.fireWith()](https://api.jquery.com/callbacks.fireWith/) _使用给定的上下文和参数调用列表中的所有回调_<!--rehype:tooltips-->
|
||||
- [callbacks.has()](https://api.jquery.com/callbacks.has/) _确定列表是否附加了任何回调。如果回调作为参数提供,请确定它是否在列表中_<!--rehype:tooltips-->
|
||||
- [callbacks.lock()](https://api.jquery.com/callbacks.lock/) _将回调列表锁定在其当前状态_<!--rehype:tooltips-->
|
||||
- [callbacks.locked()](https://api.jquery.com/callbacks.locked/) _判断回调列表是否被锁定_<!--rehype:tooltips-->
|
||||
- [callbacks.remove()](https://api.jquery.com/callbacks.remove/) _从回调列表中删除回调或回调集合_<!--rehype:tooltips-->
|
||||
<!--rehype:className=cols-2 style-none-->
|
@ -1,7 +1,7 @@
|
||||
Julia 备忘清单
|
||||
===
|
||||
|
||||
本备忘清单旨在快速理解 [Julia](https://mysql.com) 一份简单而粗略的语言概览,供您参考。
|
||||
本备忘清单旨在快速理解 [Julia](https://julialang.org/) 一份简单而粗略的语言概览,供您参考。
|
||||
|
||||
入门
|
||||
---
|
||||
@ -678,4 +678,5 @@ names(ModuleName, all::Bool, imported::Bool)
|
||||
另见
|
||||
---
|
||||
|
||||
- [快速入门一份简单而粗略的语言概览](https://cheatsheet.juliadocs.org/zh-cn/)
|
||||
- [Julia 官方网站](https://julialang.org/) _(julialang.org)_
|
||||
- [快速入门一份简单而粗略的语言概览](https://cheatsheet.juliadocs.org/zh-cn/) _(juliadocs.org)_
|
||||
|
@ -350,7 +350,7 @@ when(grade) {
|
||||
var height = 46 // inches
|
||||
|
||||
if (height in 1..53) {
|
||||
println("抱歉,您必须至少 54 英寸才能乘坐过山车")
|
||||
println("抱歉,您必须至少 54 英寸才能乘坐过山车")
|
||||
}
|
||||
// Prints: 抱歉,您必须至少 54 英寸才能乘坐过山车
|
||||
```
|
||||
|
342
docs/kubernetes.md
Normal file
@ -0,0 +1,342 @@
|
||||
Kubernetes 备忘清单
|
||||
===
|
||||
|
||||
查看资源信息
|
||||
---
|
||||
|
||||
### 节点
|
||||
|
||||
资源名称: nodes, 缩写: no
|
||||
|
||||
```bash
|
||||
$ kubectl get no # 显示所有节点信息
|
||||
$ kubectl get no -o wide # 显示所有节点的更多信息
|
||||
$ kubectl describe no # 显示节点详情
|
||||
$ kubectl get no -o yaml # 以yaml格式,显示节点详情
|
||||
$ kubectl get node --selector=[label_name] # 筛选指定标签的节点
|
||||
$ kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
|
||||
# 输出jsonpath表达式定义的字段信息
|
||||
$ kubectl top node [node_name] # 显示节点(CPU/内存/存储)使用情况
|
||||
```
|
||||
|
||||
### 容器组
|
||||
|
||||
资源名称: pods, 缩写: po
|
||||
|
||||
```bash
|
||||
$ kubectl get po # 显示所有容器组信息
|
||||
$ kubectl get po -o wide
|
||||
$ kubectl describe po
|
||||
$ kubectl get po --show-labels # 查看容器组的labels
|
||||
$ kubectl get po -l app=nginx
|
||||
$ kubectl get po -o yaml
|
||||
$ kubectl get pod [pod_name] -o yaml --export
|
||||
$ kubectl get pod [pod_name] -o yaml --export > nameoffile.yaml
|
||||
# 以yaml格式导出容器组信息到yaml文件
|
||||
$ kubectl get pods --field-selector status.phase=Running
|
||||
# 使用字段选择器筛选出容器组信息
|
||||
```
|
||||
|
||||
### 命名空间
|
||||
|
||||
资源名称: namespaces, 缩写: ns
|
||||
|
||||
```bash
|
||||
$ kubectl get ns
|
||||
$ kubectl get ns -o yaml
|
||||
$ kubectl describe ns
|
||||
```
|
||||
|
||||
### 无状态
|
||||
|
||||
资源名称: deployments, 缩写: deploy
|
||||
|
||||
```bash
|
||||
$ kubectl get deploy
|
||||
$ kubectl describe deploy
|
||||
$ kubectl get deploy -o wide
|
||||
$ kubectl get deploy -o yaml
|
||||
```
|
||||
|
||||
### 服务
|
||||
|
||||
资源名称: services, 缩写: svc
|
||||
|
||||
```bash
|
||||
$ kubectl get svc
|
||||
$ kubectl describe svc
|
||||
$ kubectl get svc -o wide
|
||||
$ kubectl get svc -o yaml
|
||||
$ kubectl get svc --show-labels
|
||||
```
|
||||
|
||||
### 守护进程集
|
||||
|
||||
资源名称: daemonsets, 缩写: ds
|
||||
|
||||
```bash
|
||||
$ kubectl get ds
|
||||
$ kubectl describe ds --all-namespaces
|
||||
$ kubectl describe ds [daemonset_name] -n [namespace_name]
|
||||
$ kubectl get ds [ds_name] -n [ns_name] -o yaml
|
||||
```
|
||||
|
||||
### 事件
|
||||
|
||||
资源名称: events, 缩写: ev
|
||||
|
||||
```bash
|
||||
$ kubectl get events
|
||||
$ kubectl get events -n kube-system
|
||||
$ kubectl get events -w
|
||||
```
|
||||
|
||||
### 日志
|
||||
|
||||
```bash
|
||||
$ kubectl logs [pod_name]
|
||||
$ kubectl logs --since=1h [pod_name]
|
||||
$ kubectl logs --tail=20 [pod_name]
|
||||
$ kubectl logs -f -c [container_name] [pod_name]
|
||||
$ kubectl logs [pod_name] > pod.log
|
||||
```
|
||||
|
||||
### 服务帐户
|
||||
|
||||
资源名称: serviceaccounts, 缩写: sa
|
||||
|
||||
```bash
|
||||
$ kubectl get sa
|
||||
$ kubectl get sa -o yaml
|
||||
$ kubectl get serviceaccounts default -o yaml >./sa.yaml
|
||||
$ kubectl replace serviceaccount default -f ./sa.yaml
|
||||
```
|
||||
|
||||
### 副本集
|
||||
|
||||
资源名称: replicasets, 缩写: rs
|
||||
|
||||
```bash
|
||||
$ kubectl get rs
|
||||
$ kubectl describe rs
|
||||
$ kubectl get rs -o wide
|
||||
$ kubectl get rs -o yaml
|
||||
```
|
||||
|
||||
### 角色
|
||||
|
||||
```bash
|
||||
$ kubectl get roles --all-namespaces
|
||||
$ kubectl get roles --all-namespaces -o yaml
|
||||
```
|
||||
|
||||
### 保密字典
|
||||
|
||||
```bash
|
||||
$ kubectl get secrets
|
||||
$ kubectl get secrets --all-namespaces
|
||||
$ kubectl get secrets -o yaml
|
||||
```
|
||||
|
||||
### 配置项
|
||||
|
||||
资源名称: configmaps, 缩写: cm
|
||||
|
||||
```bash
|
||||
$ kubectl get cm
|
||||
$ kubectl get cm --all-namespaces
|
||||
$ kubectl get cm --all-namespaces -o yaml
|
||||
```
|
||||
|
||||
### 路由
|
||||
|
||||
资源名称: ingresses, 缩写: ing
|
||||
|
||||
```bash
|
||||
$ kubectl get ing
|
||||
$ kubectl get ing --all-namespaces
|
||||
```
|
||||
|
||||
### 持久卷
|
||||
|
||||
资源名称: persistentvolumes, 缩写: pv
|
||||
|
||||
```bash
|
||||
$ kubectl get pv
|
||||
$ kubectl describe pv
|
||||
```
|
||||
|
||||
### 持久卷声明
|
||||
|
||||
资源名称: persistentvolumeclaims, 缩写: pvc
|
||||
|
||||
```bash
|
||||
$ kubectl get pvc
|
||||
$ kubectl describe pvc
|
||||
```
|
||||
|
||||
### 存储类
|
||||
|
||||
资源名称: storageclasses, 缩写: sc
|
||||
|
||||
```bash
|
||||
$ kubectl get sc
|
||||
$ kubectl get sc -o yaml
|
||||
```
|
||||
|
||||
### 多个资源
|
||||
|
||||
```bash
|
||||
$ kubectl get svc, po
|
||||
$ kubectl get deploy, no
|
||||
$ kubectl get all
|
||||
$ kubectl get all --all-namespaces
|
||||
```
|
||||
|
||||
变更资源属性
|
||||
---
|
||||
|
||||
### 污点
|
||||
|
||||
```bash
|
||||
$ kubectl taint [node_name] [taint_name]
|
||||
```
|
||||
|
||||
### 标签
|
||||
|
||||
```bash
|
||||
$ kubectl label [node_name] disktype=ssd
|
||||
$ kubectl label [pod_name] env=prod
|
||||
```
|
||||
|
||||
### 维护/可调度
|
||||
|
||||
```bash
|
||||
$ kubectl cordon [node_name] # 节点维护
|
||||
$ kubectl uncordon [node_name] # 节点可调度
|
||||
```
|
||||
|
||||
### 清空节点
|
||||
|
||||
```bash
|
||||
$ kubectl drain [node_name] # 清空节点
|
||||
```
|
||||
|
||||
### 节点/容器组
|
||||
|
||||
```bash
|
||||
$ kubectl delete node [node_name]
|
||||
$ kubectl delete pod [pod_name]
|
||||
$ kubectl edit node [node_name]
|
||||
$ kubectl edit pod [pod_name]
|
||||
```
|
||||
|
||||
### 无状态/命名空间
|
||||
|
||||
```bash
|
||||
$ kubectl edit deploy [deploy_name]
|
||||
$ kubectl delete deploy [deploy_name]
|
||||
$ kubectl expose deploy [deploy_name] --port=80 --type=NodePort
|
||||
$ kubectl scale deploy [deploy_name] --replicas=5
|
||||
$ kubectl delete ns
|
||||
$ kubectl edit ns [ns_name]
|
||||
```
|
||||
|
||||
### 服务
|
||||
|
||||
```bash
|
||||
$ kubectl edit svc [svc_name]
|
||||
$ kubectl delete svc [svc_name]
|
||||
```
|
||||
|
||||
### 守护进程集
|
||||
|
||||
```bash
|
||||
$ kubectl edit ds [ds_name] -n kube-system
|
||||
$ kubectl delete ds [ds_name]
|
||||
```
|
||||
|
||||
### 服务账号
|
||||
|
||||
```bash
|
||||
$ kubectl edit sa [sa_name]
|
||||
$ kubectl delete sa [sa_name]
|
||||
```
|
||||
|
||||
### 注释
|
||||
|
||||
```bash
|
||||
$ kubectl annotatepo [pod_name] [annotation]
|
||||
$ kubectl annotateno [node_name]
|
||||
```
|
||||
|
||||
添加资源
|
||||
---
|
||||
|
||||
### 创建容器组
|
||||
|
||||
```bash
|
||||
$ kubectl create -f [name_of_file]
|
||||
$ kubectl apply -f [name_of_file]
|
||||
$ kubectl run [pod_name] --image=nginx --restart=Never
|
||||
$ kubectl run [pod_name] --generator=run-pod/v1 --image=nginx
|
||||
$ kubectl run [pod_name] --image=nginx --restart=Never
|
||||
```
|
||||
|
||||
### 创建服务
|
||||
|
||||
```bash
|
||||
$ kubectl create svc nodeport [svc_name] --tcp=8080:80
|
||||
```
|
||||
|
||||
### 创建无状态应用
|
||||
|
||||
```bash
|
||||
$ kubectl create -f [name_of_file]
|
||||
$ kubectl apply -f [name_of_file]
|
||||
$ kubectl create deploy [deploy_name] --image=nginx
|
||||
```
|
||||
|
||||
### 容器交互
|
||||
|
||||
```bash
|
||||
$ kubectl run [pod_name] --image=busybox --rm -it --restart=Never -- sh
|
||||
```
|
||||
|
||||
### 输出YAML文件
|
||||
|
||||
```bash
|
||||
$ kubectl create deploy [deploy_name] --image=nginx --dry-run -o yaml > deploy.yaml
|
||||
$ kubectl get po [pod_name] -o yaml --export > pod.yaml
|
||||
```
|
||||
|
||||
### 获取帮助
|
||||
|
||||
```bash
|
||||
$ kubectl -h
|
||||
$ kubectl create -h
|
||||
$ kubectl run -h
|
||||
$ kubectl explain deploy.spec
|
||||
```
|
||||
|
||||
请求
|
||||
---
|
||||
|
||||
### API调用
|
||||
|
||||
```bash
|
||||
$ kubectl get --raw /apis/metrics.k8s.io/
|
||||
```
|
||||
|
||||
### 集群信息
|
||||
|
||||
```bash
|
||||
$ kubectl config
|
||||
$ kubectl cluster-info
|
||||
$ kubectl get componentstatus
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Kubernetes 官方文档 命令行工具 (kubectl)](https://kubernetes.io/zh-cn/docs/reference/kubectl/) _(kubernetes.io)_
|
@ -293,7 +293,7 @@ print(a ^ b) -- 64.0
|
||||
---
|
||||
|
||||
### 运算符
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
#### 关系运算符
|
||||
|
||||
|
556
docs/make.md
@ -28,15 +28,15 @@ a.txt: b.txt c.txt
|
||||
|
||||
### 文件命令
|
||||
|
||||
文件会以 `GNUmakefile`(不推荐使用)、`Makefile`、`makefile` 查找目录下的名称。
|
||||
make命令会以 `GNUmakefile`(不推荐使用)、`makefile`、`Makefile`(推荐使用)的顺序查找当前目录下的文件。
|
||||
|
||||
#### 自定义文件名称
|
||||
#### 自定义文件路径
|
||||
|
||||
```bash
|
||||
$ make target -f NAME
|
||||
$ make target -f FILE
|
||||
```
|
||||
|
||||
我们可以使用 `-f NAME` 来指定需要编译的文件名
|
||||
我们可以使用 `-f FILE` 来指定makefile文件的路径
|
||||
|
||||
#### 隐式生成
|
||||
|
||||
@ -369,6 +369,35 @@ run:
|
||||
书写规则
|
||||
---
|
||||
|
||||
### 文件搜寻(`vpath`)
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
如果没有指定 vpath 变量,make 只会在当前的目录中去寻找依赖文件和目标文件。否则,如果当前目录没有,就会到指定的目录中去寻找
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`vpath <pattern> <directories>` | 为符合模式 \<pattern> 的文件指定搜索目录 \<directories>
|
||||
`vpath <pattern>` | 清除符合模式 \<pattern> 的文件的搜索目录。
|
||||
`vpath` | 清除所有已被设置好了的文件搜索目录
|
||||
|
||||
#### `%`
|
||||
|
||||
* vpath 使用方法中的 \<pattern> 需要包含 `%` 字符。`%` 的意思是匹配零或若干字符(类似于**通配符**),并且引用规则是需要使用**自动变量**
|
||||
|
||||
```makefile
|
||||
vpath %.c dist
|
||||
TARGET = hello
|
||||
OBJ = bar.o foo.o
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
$(CC) -o $@ $^
|
||||
|
||||
%.o: $.c
|
||||
$(CC) -o $< -o #@
|
||||
```
|
||||
|
||||
<!--rehype:className=auto-wrap-->
|
||||
|
||||
### 通配符
|
||||
|
||||
#### `*`
|
||||
@ -399,36 +428,6 @@ run:
|
||||
ls -ll packag?.json
|
||||
```
|
||||
|
||||
### 文件搜寻(`vpath`)
|
||||
|
||||
如果没有指定 vpath 变量,make 只会在当前的目录中去寻找依赖文件和目标文件。否则,如果当前目录没有,就会到指定的目录中去寻找
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`vpath <pattern> <directories>` | 为符合模式 \<pattern> 的文件指定搜索目录 \<directories>
|
||||
`vpath <pattern>` | 清除符合模式<pattern>的文件的搜索目录。
|
||||
`vpath` | 清除所有已被设置好了的文件搜索目录
|
||||
|
||||
#### `%`
|
||||
|
||||
* vpath使用方法中的 \<pattern> 需要包含 `%` 字符。
|
||||
* `%` 的意思是匹配零或若干字符
|
||||
* 并且引用规则是需要使用**自动变量**
|
||||
|
||||
```makefile
|
||||
vpath %.c dist
|
||||
TARGET = hello
|
||||
OBJ = bar.o foo.o
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
$(CC) -o $@ $^
|
||||
|
||||
%.o: $.c
|
||||
$(CC) -o $< -o #@
|
||||
```
|
||||
|
||||
<!--rehype:className=auto-wrap-->
|
||||
|
||||
### 静态模式
|
||||
|
||||
```makefile
|
||||
@ -469,6 +468,20 @@ clean :
|
||||
rm *.o temp
|
||||
```
|
||||
|
||||
### 约定俗成的规则
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`all` | 该伪目标是所有目标的目标,一般用于编译所有的目标
|
||||
`clean` | 该伪目标用于删除所有由 make 创建的文件
|
||||
`install` | 该伪目标用于安装已编译好的程序,即将目标执行文件拷贝到指定目标中
|
||||
`print` | 该伪目标用于例出改变过的源文件
|
||||
`tar` | 该伪目标用于把源程序打包备份为 tar 文件
|
||||
`dist` | 该伪目标用于创建压缩文件,一般将 tar 文件压成 Z 或 gz 文件
|
||||
`TAGS` | 该伪目标用于更新所有的目标,以备完整地重编译使用
|
||||
`check/test` | 这两个伪目标用于测试 makefile 的流程
|
||||
|
||||
<!--rehype:className=style-round-->
|
||||
<!--rehype:className=auto-wrap-->
|
||||
|
||||
@ -535,6 +548,481 @@ exec:
|
||||
cd /home/hchen; pwd
|
||||
```
|
||||
|
||||
### make 参数
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`-b`,`-m` | 忽略和其它版本make的兼容性
|
||||
`-B` | (`--always-make`) 认为所有的目标都需要重编译
|
||||
`-C <dir>` | (`--directory=<dir>`) 指定读取makefile的目录
|
||||
`-e` | (`--environment-overrides`) 指明环境变量的值覆盖 makefile 中定义的变量的值
|
||||
`-f=<file>` | 指定需要执行的makefile
|
||||
`-h` | 显示帮助信息
|
||||
`-i` | (`--ignore-errors`)在执行时忽略所有的错误
|
||||
`-I <dir>` | (`--include-dir=<dir>`) 指定一个被包含 makefile 的搜索目标
|
||||
`-j [<nums>]` | (`--jobs[=<jobsnum>]`)指同时运行命令的个数
|
||||
`-k` | (`--keep-going`)出错也不停止运行
|
||||
`-l <load>` | `--load-average[=<load>]`、`-max-load[=<load>]` 指定make运行命令的负载
|
||||
`-n` | (`--just-print`, `--dry-run`, `--recon`) 仅输出执行过程中的命令序列,但不执行
|
||||
`-o <file>` | (`--old-file=<file>`, `--assume-old=<file>`)不重新生成的指定的 \<file>,即使目标的依赖文件新于它
|
||||
`-p` | (`--print-data-base`) 输出 makefile 中的所有数据,包括所有的规则和变量
|
||||
`-q` | (`--question`) 不运行命令,也不输出。仅仅是检查所指定的目标是否需要更新
|
||||
`-r` | (`--no-builtin-rules`) 禁止 make 使用任何隐含规则
|
||||
`-R` | (`--no-builtin-variabes`) 禁止 make 使用任何作用于变量上的隐含规则
|
||||
`-s` | (`--silent`,`--quiet`) 在命令运行时不输出命令的输出
|
||||
`-S` | (`--no-keep-going`, `--stop`) 取消“-k”选项的作用
|
||||
`-t` | `--touch` 相当于 UNIX 的 touch 命令,只是把目标的修改日期变成最新的,也就是阻止生成目标的命令运行
|
||||
`-v` | (`--version`) 输出 make 程序的版本、版权等关于 make 的信息
|
||||
`-w` | (`--print-directory`) 输出运行 makefile 之前和之后的信息。`--no-print-directory` 可以禁止 `-w`
|
||||
`-W <file>` | `--what-if=<file>`, `--new-file=<file>`, `--assume-file=<file>` 假定目标 \<file> 需要更新,如果和 `-n` 选项使用,那么这个参数会输出该目标更新时的运行动作
|
||||
`--warn-undefined-variables` | 只要 make 发现有未定义的变量,那么就输出警告信息
|
||||
<!--rehype:className=left-align-->
|
||||
|
||||
### `-debug[=<options>]`
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
输出 make 的调试信息。下面是 \<options>的取值:
|
||||
|
||||
options | :-
|
||||
:- | :-
|
||||
`a` | `all`,输出所有的调试信息
|
||||
`b` | `basic`,只输出简单的调试信息。即输出不需要重编译的目标
|
||||
`v` | `verbose`,包括 b 的信息。输出包括 makefile 被解析的信息,不需要被重编译的依赖文件等
|
||||
`i` | `implicit`,输出所有的隐含规则
|
||||
`j` | `jobs`,输出执行规则中命令的详细信息,如命令的 PID、返回码等
|
||||
`m` | `makefile`,输出 make 读取 makefile,更新 makefile,执行 makefile 的信息
|
||||
<!--rehype:className=left-align-->
|
||||
|
||||
### make 的退出码
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`0` | 成功执行
|
||||
`1` | 运行时出现错误
|
||||
`2` | 使用了 `-q` 选项,并且一些目标不需要更新
|
||||
|
||||
判断和循环
|
||||
---
|
||||
|
||||
### 单分支条件判断
|
||||
|
||||
* `ifeq` 的意思表示条件语句的开始,表达式包含两个参数,如果相同则为真。
|
||||
* `ifneq` 的意思表示条件语句的开始,表达式包含两个参数,如果不同则为真。
|
||||
* `else` 表示条件表达式为假的情况。
|
||||
* `endif` 表示一个条件语句的结束,任何一个条件表达式都应该以 `endif` 结束。
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
```makefile
|
||||
run:
|
||||
ifeq ($(CC), cc)
|
||||
$(CC) -o foo foo.c
|
||||
else
|
||||
$(CC) -o bar bar.c
|
||||
endif
|
||||
```
|
||||
|
||||
### 多分支条件判断
|
||||
|
||||
#### ifneq 语法
|
||||
|
||||
```makefile
|
||||
ifneq (<arg1>, <arg2>)
|
||||
ifneq '<arg1>' '<arg2>'
|
||||
ifneq "<arg1>" "<arg2>"
|
||||
ifneq "<arg1>" '<arg2>'
|
||||
ifneq '<arg1>' "<arg2>"
|
||||
```
|
||||
|
||||
#### ifeq 语法
|
||||
|
||||
```makefile
|
||||
ifeq (<arg1>, <arg2>)
|
||||
ifeq '<arg1>' '<arg2>'
|
||||
ifeq "<arg1>" "<arg2>"
|
||||
ifeq "<arg1>" '<arg2>'
|
||||
ifeq '<arg1>' "<arg2>"
|
||||
```
|
||||
|
||||
### ifdef
|
||||
|
||||
```makefile
|
||||
ifdef <variable-name>
|
||||
```
|
||||
|
||||
`ifdef` 会根据 variable-name 判断,如果为空则为真
|
||||
|
||||
```makefile
|
||||
bar =
|
||||
foo = $(bar)
|
||||
ifdef foo
|
||||
frobozz = yes
|
||||
else
|
||||
frobozz = no
|
||||
endif
|
||||
|
||||
run:
|
||||
echo $(frobozz)
|
||||
```
|
||||
|
||||
`ifndef` 则和 `ifdef` 是相反的意思
|
||||
|
||||
### for 循环
|
||||
|
||||
```makefile
|
||||
LIST = one two three
|
||||
all:
|
||||
for i in $(LIST); do \
|
||||
echo $$i; \
|
||||
done
|
||||
```
|
||||
|
||||
函数
|
||||
---
|
||||
|
||||
### 字符串处理函数 - 替换函数(`subst`)
|
||||
|
||||
把字串 \<text> 中的 \<from> 字符串替换成 \<to> 。
|
||||
|
||||
```makefile
|
||||
$(subst <from>,<to>,<text>)
|
||||
```
|
||||
|
||||
示例
|
||||
|
||||
```makefile
|
||||
$(subst ee,EE,feet on the street)
|
||||
```
|
||||
|
||||
### 字符串处理函数 - 模式字符串替换函数(`patsubst`)
|
||||
|
||||
查找 \<text> 中的单词(**单词以空格、Tab或回车换行分隔**)是否符合模式 \<pattern>。匹配,则以 \<replacement> 替换。
|
||||
|
||||
```makefile
|
||||
$(patsubst <pattern>,<replacement>,<text>)
|
||||
```
|
||||
|
||||
* 示例
|
||||
|
||||
```makefile
|
||||
$(patsubst %.c,%.o,x.c.c bar.c)
|
||||
```
|
||||
|
||||
把字串 x.c.c bar.c 符合模式 %.c 的单词替换成 %.o ,返回结果是 x.c.o bar.o
|
||||
|
||||
### 字符串处理函数 - 去空格函数(`strip`)
|
||||
|
||||
去掉 <string> 字串中开头和结尾的空字符。
|
||||
|
||||
```makefile
|
||||
$(strip <string>)
|
||||
```
|
||||
|
||||
示例
|
||||
|
||||
```makefile
|
||||
$(strip a b c )
|
||||
```
|
||||
|
||||
把字串 `a b c` 去掉开头和结尾的空格,结果是 a b c。
|
||||
|
||||
### 字符串处理函数 - 查找字符串函数(`findstring`)
|
||||
|
||||
在字串 \<in> 中查找 \<find> 字串。
|
||||
|
||||
```makefile
|
||||
$(findstring <find>,<in>)
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
```makefile
|
||||
$(findstring a,a b c)
|
||||
$(findstring a,b c)
|
||||
```
|
||||
|
||||
第一个函数返回 a 字符串,第二个返回空字符串
|
||||
|
||||
### 字符串处理函数 - 过滤函数(`filter`)
|
||||
|
||||
以 \<pattern> 模式过滤 \<text> 字符串中的单词,保留符合模式 \<pattern> 的单词。可以有多个模式。
|
||||
|
||||
```makefile
|
||||
$(filter <pattern...>,<text>)
|
||||
```
|
||||
|
||||
示例
|
||||
|
||||
```makefile
|
||||
sources := foo.c bar.c baz.s ugh.h
|
||||
foo: $(sources)
|
||||
cc $(filter %.c %.s,$(sources)) -o foo
|
||||
$(filter %.c %.s,$(sources))
|
||||
# 返回的值是 foo.c bar.c baz.s
|
||||
```
|
||||
|
||||
### 字符串处理函数 - 反过滤函数(`filter-out`)
|
||||
|
||||
以 \<pattern> 模式过滤 \<text> 字符串中的单词,去除符合模式 \<pattern> 的单词。可以有多个模式。
|
||||
|
||||
```makefile
|
||||
$(filter-out <pattern...>,<text>)
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
```makefile
|
||||
objects=main1.o foo.o main2.o bar.o
|
||||
mains=main1.o main2.o
|
||||
$(filter-out $(mains),$(objects))
|
||||
# 返回值是 foo.o bar.o 。
|
||||
```
|
||||
|
||||
### 字符串处理函数 - 排序函数(`sort`)
|
||||
|
||||
给字符串 \<list> 中的单词排序(升序)。
|
||||
|
||||
```makefile
|
||||
$(sort <list>)
|
||||
```
|
||||
|
||||
* 示例:`$(sort foo bar lose)` 返回 `bar foo lose`
|
||||
* 注意:sort 函数会去掉 `<list>` 中相同的单词
|
||||
|
||||
### 字符串处理函数 - 取单词函数(`word`)
|
||||
|
||||
取字符串 \<text> 中第 \<n> 个单词。(从一开始)
|
||||
|
||||
```makefile
|
||||
$(word <n>,<text>)
|
||||
```
|
||||
|
||||
示例:`$(word 2, foo bar baz)` 返回值是 `bar`
|
||||
|
||||
### 字符串处理函数 - 取单词串函数(`wordlist`)
|
||||
|
||||
* 从字符串 \<text> 中取从 \<s> 开始到 \<e> 的单词串。\<s> 和 \<e> 是一个数字。
|
||||
|
||||
```makefile
|
||||
$(wordlist <ss>,<e>,<text>)
|
||||
```
|
||||
|
||||
示例:`$(wordlist 2, 3, foo bar baz)` 返回值是 bar baz。
|
||||
|
||||
### 字符串处理函数 - 单词个数统计函数(`words`)
|
||||
|
||||
* 统计 \<text> 中字符串中的单词个数。
|
||||
|
||||
```makefile
|
||||
$(words <text>)
|
||||
```
|
||||
|
||||
* 示例:`$(words, foo bar baz)` 返回值是 3。
|
||||
|
||||
### 字符串处理函数 - 首单词函数(`firstword`)
|
||||
|
||||
* 取字符串 \<text> 中的第一个单词。
|
||||
|
||||
```makefile
|
||||
$(firstword <text>)
|
||||
```
|
||||
|
||||
* 示例:`$(firstword foo bar)` 返回值是 `foo`
|
||||
|
||||
### 文件名操作函数
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### 取目录函数(`dir`)
|
||||
|
||||
从文件名序列 \<names> 中取出目录部分。目录部分是指最后一个反斜杠(`/`)之前的部分。如果没有反斜杠,那么返回 `./`。
|
||||
|
||||
```makefile
|
||||
$(dir <names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(dir src/foo.c hacks)
|
||||
#返回值是 src/ ./
|
||||
```
|
||||
|
||||
#### 取文件函数(`notdir`)
|
||||
|
||||
从文件名序列 \<names> 中取出非目录部分。非目录部分是指最後一个反斜杠(`/`)之后的部分。
|
||||
|
||||
```makefile
|
||||
$(notdir <names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(notdir src/foo.c hacks)
|
||||
# 返回值是 foo.c hacks
|
||||
```
|
||||
|
||||
#### 取后缀函数(`suffix`)
|
||||
|
||||
从文件名序列 \<names> 中取出各个文件名的后缀
|
||||
|
||||
```makefile
|
||||
$(suffix <names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(suffix src/foo.c src-1.0/bar.c hacks)
|
||||
# 返回值是 .c .c
|
||||
```
|
||||
|
||||
#### 取前缀函数(`basename`)
|
||||
|
||||
从文件名序列 \<names> 中取出各个文件名的前缀部分。
|
||||
|
||||
```makefile
|
||||
$(basename <names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(basename src/foo.c src-1.0/bar.c hacks)
|
||||
# 返回值是 src/foo src-1.0/bar hacks
|
||||
```
|
||||
|
||||
#### 加后缀函数(`addsuffix`)
|
||||
|
||||
把后缀 \<suffix> 加到 \<names> 中的每个单词后面
|
||||
|
||||
```makefile
|
||||
$(addsuffix <suffix>,<names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(addsuffix .c,foo bar)
|
||||
# 返回值是 foo.c bar.c
|
||||
```
|
||||
|
||||
#### 加前缀函数(`addprefix`)
|
||||
|
||||
把前缀 \<prefix> 加到 \<names> 中的每个单词前面。
|
||||
|
||||
```makefile
|
||||
$(addprefix <prefix>,<names...>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(addprefix src/,foo bar)
|
||||
# 返回值是 src/foo src/bar 。
|
||||
```
|
||||
|
||||
#### 连接函数(`join`)
|
||||
|
||||
把 \<list2> 中的单词对应地加到 \<list1> 的单词后面。
|
||||
|
||||
```makefile
|
||||
$(join <list1>,<list2>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
$(join aaa bbb , 111 222 333)
|
||||
# 返回值是 aaa111 bbb222 333 。
|
||||
```
|
||||
|
||||
### 其它函数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
#### foreach 函数
|
||||
|
||||
```makefile
|
||||
$(foreach <var>,<list>,<text>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
# $(name) 中的单词会被挨个取出,并存到变量 n 中,
|
||||
# $(n).o 每次根据 $(n) 计算出一个值,这些值以空格分隔,最后作为 foreach 函数的返回
|
||||
names := a b c d
|
||||
files := $(foreach n,$(names),$(n).o)
|
||||
run:
|
||||
echo $(files)
|
||||
```
|
||||
|
||||
#### if 函数
|
||||
|
||||
与之前的条件语句——`ifeq` 类似
|
||||
|
||||
```makefile
|
||||
$(if <condition>,<then-part>)
|
||||
# 或者
|
||||
$(if <condition>,<then-part>,<else-part>)
|
||||
```
|
||||
|
||||
#### call 函数
|
||||
|
||||
call 函数是唯一一个可以用来创建新的参数化的函数。
|
||||
|
||||
```makefile
|
||||
$(call <expression>,<parm1>,<parm2>,...,<parmn>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```makefile
|
||||
reverse = $(2) $(1)
|
||||
|
||||
foo = $(call reverse,a,b)
|
||||
|
||||
run:
|
||||
echo $(foo)
|
||||
# b a
|
||||
```
|
||||
|
||||
#### shell 函数
|
||||
|
||||
使用操作系统 Shell 的命令
|
||||
|
||||
```makefile
|
||||
contents := $(shell cat foo)
|
||||
files := $(shell echo *.c)
|
||||
```
|
||||
|
||||
#### 控制 make 的函数
|
||||
|
||||
```makefile
|
||||
$(error <text ...>)
|
||||
# and
|
||||
$(warning <text ...>)
|
||||
```
|
||||
|
||||
#### origin 函数
|
||||
|
||||
```makefile
|
||||
$(origin <variable>)
|
||||
```
|
||||
|
||||
origin 函数用于告诉这个变量的从何而来
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`undefined` | 如果 \<variable> 未定义,返回 `undefined`
|
||||
`default` | 如果 \<variable> 是默认的,如 `CC`
|
||||
`environment` | 如果 \<variable> 是环境变量,并且当 Makefile 执行时,-e 参数没有被打开
|
||||
`file` | 如果 \<variable> 这个变量被定义在 Makefile 中。
|
||||
`command line` | 如果 \<variable> 这个变量是被命令行定义的。
|
||||
`override` | 如果 \<variable> 是被 override 指示符重新定义的。
|
||||
`automatic` | 如果 \<variable> 是一个命令运行中的自动化变量
|
||||
<!--rehype:className=left-align-->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
434
docs/mongodb.md
Normal file
@ -0,0 +1,434 @@
|
||||
MongoDB 备忘清单
|
||||
===
|
||||
|
||||
[MongoDB](https://www.mongodb.com/developer/products/mongodb/cheat-sheet/#connect-mongodb-shell) 此备忘单包含一些方便的提示、命令和快速参考,可让您立即连接并进行 CRUD
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 连接 MongoDB Shell
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
mongo # 默认连接到 mongodb://127.0.0.1:27017
|
||||
mongo --host <host> --port <port> -u <user> -p <pwd> # 如果需要提示,请省略密码
|
||||
mongo "mongodb://192.168.1.1:27017"
|
||||
# MongoDB 地图集
|
||||
mongo "mongodb+srv://cluster-name.abcde.mongodb.net/<dbname>" --username <username>
|
||||
```
|
||||
|
||||
### 显示数据库
|
||||
|
||||
```mongodb
|
||||
show dbs
|
||||
db // 打印当前数据库
|
||||
```
|
||||
|
||||
### 切换数据库
|
||||
|
||||
```mongodb
|
||||
use <database_name>
|
||||
```
|
||||
|
||||
### 显示收藏
|
||||
|
||||
```mongodb
|
||||
show collections
|
||||
```
|
||||
|
||||
### 运行 JavaScript 文件
|
||||
|
||||
```mongodb
|
||||
load("myScript.js")
|
||||
```
|
||||
|
||||
CRUD
|
||||
---
|
||||
|
||||
### 创建
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```mongodb
|
||||
db.coll.insertOne({ name: "Max" })
|
||||
db.coll.insert([{ name: "Max"}, {name:"Alex"}]) // 订购批量插入
|
||||
db.coll.insert([{ name: "Max"}, {name:"Alex"}], {ordered: false}) // 无序批量插入
|
||||
db.coll.insert({ date: ISODate()})
|
||||
db.coll.insert({ name: "Max"}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
```
|
||||
|
||||
### 寻找文件
|
||||
|
||||
Commands | Description
|
||||
:-- | ---
|
||||
`db.docx.findOne()` | 查找一个随机文档
|
||||
`db.docx.find().prettyPrint()` | 查找所有文档
|
||||
`db.docx.find({}, {name:true, _id:false})` | 仅显示文档 Docx 的名称
|
||||
`db.docx.find({}, {name:true, _id:false})` | 可以在多个文件中按属性查找一个文件
|
||||
|
||||
### 使用运算符查找文档
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
Operator | Description | Commands
|
||||
:-- | --- | ---
|
||||
`$gt` | 比...更棒 | `db.docx.find({class:{$gt:'T'}`
|
||||
`$gte` | 大于等于 | `db.docx.find({class:{$gt:'T'}`
|
||||
`$lt` | 小于 | `db.docx.find({class:{$lt:'T'}`
|
||||
`$lte` | 小于等于 | `db.docx.find({class:{$lte:'T'}`
|
||||
`$exists` | 属性是否存在 | `db.docx.find({class:{$gt:'T'}`
|
||||
`$regex` | 正则表达式匹配 | `db.docx.find({name:{$regex:'^USS\\sE'}})`
|
||||
`$type` | 按元素类型搜索 | `db.docx.find({name : {$type:4}})`
|
||||
|
||||
### 读取
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```mongodb
|
||||
db.coll.findOne() // 返回单个文档
|
||||
db.coll.find() // 返回一个游标 - 显示 20 个结果 - "it" 显示更多
|
||||
db.coll.find().pretty()
|
||||
db.coll.find({name: "Max", age: 32}) // 隐式逻辑“与”。
|
||||
db.coll.find({date: ISODate("2020-09-25T13:57:17.180Z")})
|
||||
|
||||
// 或“queryPlanner”或“allPlansExecution”
|
||||
db.coll.find({name: "Max", age: 32}).explain("executionStats")
|
||||
db.coll.distinct("name")
|
||||
|
||||
// 数数
|
||||
db.coll.count({age: 32}) // 基于馆藏元数据的估计
|
||||
db.coll.estimatedDocumentCount() // 基于馆藏元数据的估计
|
||||
db.coll.countDocuments({age: 32}) // 聚合管道的别名 - 准确计数
|
||||
|
||||
// Comparison 比较
|
||||
db.coll.find({"year": {$gt: 1970}})
|
||||
db.coll.find({"year": {$gte: 1970}})
|
||||
db.coll.find({"year": {$lt: 1970}})
|
||||
db.coll.find({"year": {$lte: 1970}})
|
||||
db.coll.find({"year": {$ne: 1970}})
|
||||
db.coll.find({"year": {$in: [1958, 1959]}})
|
||||
db.coll.find({"year": {$nin: [1958, 1959]}})
|
||||
|
||||
|
||||
// Logical 逻辑
|
||||
db.coll.find({name:{$not: {$eq: "Max"}}})
|
||||
db.coll.find({$or: [{"year" : 1958}, {"year" : 1959}]})
|
||||
db.coll.find({$nor: [{price: 1.99}, {sale: true}]})
|
||||
db.coll.find({
|
||||
$and: [
|
||||
{$or: [{qty: {$lt :10}}, {qty :{$gt: 50}}]},
|
||||
{$or: [{sale: true}, {price: {$lt: 5 }}]}
|
||||
]
|
||||
})
|
||||
|
||||
// Element 元素
|
||||
db.coll.find({name: {$exists: true}})
|
||||
db.coll.find({"zipCode": {$type: 2 }})
|
||||
db.coll.find({"zipCode": {$type: "string"}})
|
||||
|
||||
// Aggregation Pipeline 聚合管道
|
||||
db.coll.aggregate([
|
||||
{$match: {status: "A"}},
|
||||
{$group: {_id: "$cust_id", total: {$sum: "$amount"}}},
|
||||
{$sort: {total: -1}}
|
||||
])
|
||||
|
||||
// 使用“文本”索引进行文本搜索
|
||||
db.coll.find({$text: {$search: "cake"}}, {score: {$meta: "textScore"}})
|
||||
.sort({score: {$meta: "textScore"}})
|
||||
|
||||
// Regex 正则表达式
|
||||
db.coll.find({name: /^Max/}) // 正则表达式:以字母“M”开头
|
||||
db.coll.find({name: /^Max$/i}) // 正则表达式不区分大小写
|
||||
|
||||
// Array
|
||||
db.coll.find({tags: {$all: ["Realm", "Charts"]}})
|
||||
db.coll.find({field: {$size: 2}}) // 无法索引 - 更喜欢存储数组的大小并更新它
|
||||
db.coll.find({results: {$elemMatch: {product: "xyz", score: {$gte: 8}}}})
|
||||
|
||||
// Projections 预测
|
||||
db.coll.find({"x": 1}, {"actors": 1}) // actors + _id
|
||||
db.coll.find({"x": 1}, {"actors": 1, "_id": 0}) // actors
|
||||
db.coll.find({"x": 1}, {"actors": 0, "summary": 0}) // 除了“actors”和“summary”之外的所有内容
|
||||
|
||||
// Sort 排序, skip 跳过, limit 限制
|
||||
db.coll.find({}).sort({"year": 1, "rating": -1}).skip(10).limit(3)
|
||||
|
||||
// Read Concern 阅读关注
|
||||
db.coll.find().readConcern("majority")
|
||||
```
|
||||
|
||||
### 更新
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```mongodb
|
||||
db.coll.update({"_id": 1}, {"year": 2016}) // 警告! 替换整个文档
|
||||
db.coll.update({"_id": 1}, {$set: {"year": 2016, name: "Max"}})
|
||||
db.coll.update({"_id": 1}, {$unset: {"year": 1}})
|
||||
db.coll.update({"_id": 1}, {$rename: {"year": "date"} })
|
||||
db.coll.update({"_id": 1}, {$inc: {"year": 5}})
|
||||
db.coll.update({"_id": 1}, {$mul: {price: NumberDecimal("1.25"), qty: 2}})
|
||||
db.coll.update({"_id": 1}, {$min: {"imdb": 5}})
|
||||
db.coll.update({"_id": 1}, {$max: {"imdb": 8}})
|
||||
db.coll.update({"_id": 1}, {$currentDate: {"lastModified": true}})
|
||||
db.coll.update({"_id": 1}, {$currentDate: {"lastModified": {$type: "timestamp"}}})
|
||||
|
||||
// Array
|
||||
db.coll.update({"_id": 1}, {$push :{"array": 1}})
|
||||
db.coll.update({"_id": 1}, {$pull :{"array": 1}})
|
||||
db.coll.update({"_id": 1}, {$addToSet :{"array": 2}})
|
||||
db.coll.update({"_id": 1}, {$pop: {"array": 1}}) // 最后一个元素
|
||||
db.coll.update({"_id": 1}, {$pop: {"array": -1}}) // 第一个元素
|
||||
db.coll.update({"_id": 1}, {$pullAll: {"array" :[3, 4, 5]}})
|
||||
db.coll.update({"_id": 1}, {$push: {scores: {$each: [90, 92, 85]}}})
|
||||
db.coll.updateOne({"_id": 1, "grades": 80}, {$set: {"grades.$": 82}})
|
||||
db.coll.updateMany({}, {$inc: {"grades.$[]": 10}})
|
||||
db.coll.update({}, {$set: {"grades.$[element]": 100}}, {multi: true, arrayFilters: [{"element": {$gte: 100}}]})
|
||||
|
||||
// 更新很多
|
||||
db.coll.update({"year": 1999}, {$set: {"decade": "90's"}}, {"multi":true})
|
||||
db.coll.updateMany({"year": 1999}, {$set: {"decade": "90's"}})
|
||||
|
||||
// FindOneAndUpdate 查找并更新
|
||||
db.coll.findOneAndUpdate({"name": "Max"}, {$inc: {"points": 5}}, {returnNewDocument: true})
|
||||
|
||||
// Upsert 更新插入
|
||||
db.coll.update({"_id": 1}, {$set: {item: "apple"}, $setOnInsert: {defaultQty: 100}}, {upsert: true})
|
||||
|
||||
// Replace 代替
|
||||
db.coll.replaceOne({"name": "Max"}, {"firstname": "Maxime", "surname": "Beugnet"})
|
||||
|
||||
// Save 保存
|
||||
db.coll.save({"item": "book", "qty": 40})
|
||||
|
||||
// Write concern 写关注
|
||||
db.coll.update({}, {$set: {"x": 1}}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
```
|
||||
|
||||
### 删除
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```mongodb
|
||||
db.coll.remove({name: "Max"})
|
||||
db.coll.remove({name: "Max"}, {justOne: true})
|
||||
db.coll.remove({}) // 警告!删除所有文档但不删除集合本身及其索引定义
|
||||
db.coll.remove({name: "Max"}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
db.coll.findOneAndDelete({"name": "Max"})
|
||||
```
|
||||
|
||||
数据库和集合
|
||||
---
|
||||
|
||||
### Drop
|
||||
|
||||
```mongodb
|
||||
// 删除集合及其索引定义
|
||||
db.coll.drop()
|
||||
// 仔细检查你*不*在 PROD 集群上......:-)
|
||||
db.dropDatabase()
|
||||
```
|
||||
|
||||
### 创建集合
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```mongodb
|
||||
// 使用 $jsonschema 创建集合
|
||||
db.createCollection("contacts", {
|
||||
validator: {$jsonSchema: {
|
||||
bsonType: "object",
|
||||
required: ["phone"],
|
||||
properties: {
|
||||
phone: {
|
||||
bsonType: "string",
|
||||
description: "必须是一个字符串并且是必需的"
|
||||
},
|
||||
email: {
|
||||
bsonType: "string",
|
||||
pattern: "@mongodb\.com$",
|
||||
description: "必须是字符串并匹配正则表达式模式"
|
||||
},
|
||||
status: {
|
||||
enum: [ "Unknown", "Incomplete" ],
|
||||
description: "只能是枚举值之一"
|
||||
}
|
||||
}
|
||||
}}
|
||||
})
|
||||
```
|
||||
|
||||
### 其他采集功能
|
||||
|
||||
```mongodb
|
||||
db.coll.stats()
|
||||
db.coll.storageSize()
|
||||
db.coll.totalIndexSize()
|
||||
db.coll.totalSize()
|
||||
db.coll.validate({full: true})
|
||||
// 第二个参数用于删除目标集合(如果存在)
|
||||
db.coll.renameCollection("new_coll", true)
|
||||
```
|
||||
|
||||
索引
|
||||
---
|
||||
|
||||
### 列表索引
|
||||
|
||||
```mongodb
|
||||
db.coll.getIndexes()
|
||||
db.coll.getIndexKeys()
|
||||
```
|
||||
|
||||
### 创建索引
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```mongodb
|
||||
// 索引类型
|
||||
db.coll.createIndex({"name": 1}) // 单字段索引
|
||||
db.coll.createIndex({"name": 1, "date": 1}) // 复合索引
|
||||
db.coll.createIndex({foo: "text", bar: "text"}) // 文本索引
|
||||
db.coll.createIndex({"$**": "text"}) // 通配符文本索引
|
||||
db.coll.createIndex({"userMetadata.$**": 1}) // 通配符索引
|
||||
db.coll.createIndex({"loc": "2d"}) // 二维索引
|
||||
db.coll.createIndex({"loc": "2dsphere"}) // 2dsphere 索引
|
||||
db.coll.createIndex({"_id": "hashed"}) // 哈希索引
|
||||
|
||||
// Index Options
|
||||
db.coll.createIndex({"lastModifiedDate": 1}, {expireAfterSeconds: 3600}) // TTL指数
|
||||
db.coll.createIndex({"name": 1}, {unique: true})
|
||||
db.coll.createIndex({"name": 1}, {partialFilterExpression: {age: {$gt: 18}}}) // 部分索引
|
||||
// 强度为 1 或 2 的不区分大小写的索引
|
||||
db.coll.createIndex({"name": 1}, {collation: {locale: 'en', strength: 1}})
|
||||
db.coll.createIndex({"name": 1 }, {sparse: true})
|
||||
```
|
||||
|
||||
### 删除索引
|
||||
|
||||
```mongodb
|
||||
db.coll.dropIndex("name_1")
|
||||
```
|
||||
|
||||
### 隐藏/取消隐藏索引
|
||||
|
||||
```mongodb
|
||||
db.coll.hideIndex("name_1")
|
||||
db.coll.unhideIndex("name_1")
|
||||
```
|
||||
|
||||
方便的命令
|
||||
---
|
||||
|
||||
###
|
||||
<!--rehype:wrap-class=col-span-3&style=display:none;&wrap-style=padding-top: 0;-->
|
||||
|
||||
```mongodb
|
||||
use admin
|
||||
db.createUser({"user": "root", "pwd": passwordPrompt(), "roles": ["root"]})
|
||||
db.dropUser("root")
|
||||
db.auth( "user", passwordPrompt() )
|
||||
|
||||
use test
|
||||
db.getSiblingDB("dbname")
|
||||
db.currentOp()
|
||||
db.killOp(123) // opid
|
||||
|
||||
db.fsyncLock()
|
||||
db.fsyncUnlock()
|
||||
|
||||
db.getCollectionNames()
|
||||
db.getCollectionInfos()
|
||||
db.printCollectionStats()
|
||||
db.stats()
|
||||
|
||||
db.getReplicationInfo()
|
||||
db.printReplicationInfo()
|
||||
db.isMaster()
|
||||
db.hostInfo()
|
||||
db.printShardingStatus()
|
||||
db.shutdownServer()
|
||||
db.serverStatus()
|
||||
|
||||
db.setSlaveOk()
|
||||
db.getSlaveOk()
|
||||
|
||||
db.getProfilingLevel()
|
||||
db.getProfilingStatus()
|
||||
db.setProfilingLevel(1, 200) // 0 == OFF, 1 == ON with slowms, 2 == ON
|
||||
|
||||
db.enableFreeMonitoring()
|
||||
db.disableFreeMonitoring()
|
||||
db.getFreeMonitoringStatus()
|
||||
|
||||
db.createView("viewName", "sourceColl", [{$project:{department: 1}}])
|
||||
```
|
||||
|
||||
各种各样的
|
||||
---
|
||||
|
||||
### 改变流
|
||||
|
||||
```mongodb
|
||||
watchCursor = db.coll.watch([
|
||||
{
|
||||
$match : {"operationType": "insert" }
|
||||
}
|
||||
])
|
||||
|
||||
while (!watchCursor.isExhausted()){
|
||||
if (watchCursor.hasNext()){
|
||||
print(tojson(watchCursor.next()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 分片集群
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```mongodb
|
||||
sh.status()
|
||||
sh.addShard("rs1/mongodbd1.example.net:27017")
|
||||
sh.shardCollection("mydb.coll", {zipcode: 1})
|
||||
|
||||
sh.moveChunk("mydb.coll", { zipcode: "53187" }, "shard0019")
|
||||
sh.splitAt("mydb.coll", {x: 70})
|
||||
sh.splitFind("mydb.coll", {x: 70})
|
||||
sh.disableAutoSplit()
|
||||
sh.enableAutoSplit()
|
||||
|
||||
sh.startBalancer()
|
||||
sh.stopBalancer()
|
||||
sh.disableBalancing("mydb.coll")
|
||||
sh.enableBalancing("mydb.coll")
|
||||
sh.getBalancerState()
|
||||
sh.setBalancerState(true/false)
|
||||
sh.isBalancerRunning()
|
||||
|
||||
sh.addTagRange("mydb.coll", {state: "NY",zip: MinKey}, {state: "NY",zip: MaxKey}, "NY")
|
||||
sh.removeTagRange("mydb.coll", {state: "NY",zip: MinKey}, {state: "NY",zip: MaxKey}, "NY")
|
||||
sh.addShardTag("shard0000", "NYC")
|
||||
sh.removeShardTag("shard0000", "NYC")
|
||||
|
||||
sh.addShardToZone("shard0000", "JFK")
|
||||
sh.removeShardFromZone("shard0000", "NYC")
|
||||
sh.removeRangeFromZone("mydb.coll", {a: 1, b: 1}, {a: 10, b: 10})
|
||||
```
|
||||
|
||||
### 副本集
|
||||
|
||||
```mongodb
|
||||
rs.status()
|
||||
rs.initiate({"_id": "replicaTest",
|
||||
members: [
|
||||
{ _id: 0, host: "127.0.0.1:27017" },
|
||||
{ _id: 1, host: "127.0.0.1:27018" },
|
||||
{ _id: 2, host: "127.0.0.1:27019",
|
||||
arbiterOnly:true }]
|
||||
})
|
||||
rs.add("mongodbd1.example.net:27017")
|
||||
rs.addArb("mongodbd2.example.net:27017")
|
||||
rs.remove("mongodbd1.example.net:27017")
|
||||
rs.conf()
|
||||
rs.isMaster()
|
||||
rs.printReplicationInfo()
|
||||
rs.printSlaveReplicationInfo()
|
||||
rs.reconfig(<valid_conf>)
|
||||
rs.slaveOk()
|
||||
rs.stepDown(20, 5)
|
||||
// (stepDownSecs, secondaryCatchUpPeriodSecs)
|
||||
```
|
248
docs/ps.md
Normal file
@ -0,0 +1,248 @@
|
||||
ps 备忘清单
|
||||
===
|
||||
|
||||
Linux 为我们提供了一个名为 `ps` 的实用程序,用于查看与系统上的进程相关的信息,它是 `Process Status` 的缩写
|
||||
这份 `ps` 命令备忘清单的快速参考列表,包含常用选项和示例。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 语法
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
```bash
|
||||
$ ps [options]
|
||||
```
|
||||
|
||||
命令运行示例,列出当前 shell 中的所有进程:
|
||||
|
||||
```bash
|
||||
$ ps
|
||||
|
||||
PID TTY TIME CMD
|
||||
12330 pts/0 00:00:00 bash
|
||||
21621 pts/0 00:00:00 ps
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`PID` | 唯一的进程 ID
|
||||
`TTY` | 用户登录的终端类型
|
||||
`TIME` | 进程运行的 CPU 数量,以分钟和秒为单位
|
||||
`CMD` | 启动进程的命令的名称
|
||||
|
||||
注意:有时当我们执行 `ps` 命令时,它显示 `TIME` 为 `00:00:00`
|
||||
|
||||
---
|
||||
|
||||
ps 命令支持 3 种使用语法风格
|
||||
|
||||
- `Unix` 可以分组并以连字符开头
|
||||
- `BSD` 可以分组但前面没有连字符
|
||||
- `GNU` 长选项,前面有双连字符
|
||||
|
||||
### 示例
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
Option | Function
|
||||
:-- | --
|
||||
`ps -ef / -aux` | 以完整格式列出当前正在运行的进程
|
||||
`ps -ax` | 列出当前正在运行的进程
|
||||
`ps -u <username>` | 列出特定用户的进程
|
||||
`ps -C <command>` | 列出给定命令的进程
|
||||
`ps -p <PID>` | 列出具有给定 PID 的进程
|
||||
`ps -ppid <PPID>` | 列出具有给定 ppid 的进程
|
||||
`pstree` | 在层次结构中显示过程
|
||||
`ps -L` | 列出特定进程的所有线程
|
||||
`ps --sort pmem` | 查找内存泄漏
|
||||
`ps -eo` | 显示安全信息
|
||||
`ps T` | 允许您仅选择与此终端关联的所有进程
|
||||
`ps -U root -u root u` | 显示由 root 运行的进程
|
||||
<!--rehype:className=code-nowrap-->
|
||||
|
||||
### 查看系统上的每个进程
|
||||
|
||||
要使用标准语法查看系统上的每个进程:
|
||||
|
||||
```bash
|
||||
$ ps -e # 列出所有进程
|
||||
$ ps -ef
|
||||
$ ps -eF
|
||||
$ ps -ely
|
||||
```
|
||||
|
||||
要使用 BSD 语法查看系统上的每个进程:
|
||||
|
||||
```bash
|
||||
$ ps ax # 以 BSD 格式列出所有进程
|
||||
$ ps axu
|
||||
```
|
||||
|
||||
### 打印进程树
|
||||
|
||||
```bash
|
||||
$ ps -ejH
|
||||
$ ps axjf
|
||||
```
|
||||
|
||||
### 仅打印 PID 42 的名称
|
||||
|
||||
```bash
|
||||
$ ps -q 42 -o comm=
|
||||
```
|
||||
|
||||
### 获取有关线程的信息
|
||||
|
||||
```bash
|
||||
$ ps -eLf
|
||||
$ ps axms
|
||||
```
|
||||
|
||||
### 列出当前用户拥有的所有进程
|
||||
|
||||
```bash
|
||||
$ ps x
|
||||
```
|
||||
|
||||
### 获取安全信息
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ ps -eo euser,ruser,suser,fuser,f,comm,label
|
||||
$ ps axZ
|
||||
$ ps -eM
|
||||
```
|
||||
|
||||
### 查看以 root 身份运行的每个进程
|
||||
|
||||
查看以 root 身份运行的每个进程(真实且有效的 ID)用户格式:
|
||||
|
||||
```bash
|
||||
$ ps -U root -u root u
|
||||
```
|
||||
|
||||
### 查看具有用户定义格式的每个进程
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
|
||||
$ ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
|
||||
$ ps -Ao pid,tt,user,fname,tmout,f,wchan
|
||||
```
|
||||
|
||||
### 仅打印 syslogd 的进程 ID
|
||||
|
||||
```bash
|
||||
$ ps -C syslogd -o pid=
|
||||
```
|
||||
|
||||
### 显示面向用户的格式
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ps u
|
||||
|
||||
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
|
||||
refs 11400 1.1 0.0 34853544 5816 s025 Ss Tue02PM 0:02.82 /bin/zsh --login
|
||||
refs 34561 0.6 0.0 34822644 3152 s016 S+ 14Dec22 115:59.28 zsh (figterm)
|
||||
refs 21377 0.5 0.0 34973972 7076 s028 S+ Wed09AM 4:32.19 zsh (figterm)
|
||||
refs 78881 0.5 0.0 34843484 3256 s015 S+ 17Dec22 90:27.10 zsh (figterm)
|
||||
```
|
||||
|
||||
### 列出具有完整格式的进程
|
||||
|
||||
```bash
|
||||
$ ps f
|
||||
$ ps -F
|
||||
```
|
||||
|
||||
### 显示虚拟内存格式
|
||||
|
||||
```bash
|
||||
$ ps v
|
||||
```
|
||||
|
||||
### 按有效用户 ID 或名称显示进程
|
||||
|
||||
```bash
|
||||
$ ps -u user[name or id]
|
||||
# OR
|
||||
$ ps --user user[name or id]
|
||||
$ ps -u root
|
||||
```
|
||||
|
||||
按**真实**用户 ID 或名称显示进程
|
||||
|
||||
```bash
|
||||
$ ps -U user[name or id]
|
||||
# OR
|
||||
$ ps --User user[name or id]
|
||||
```
|
||||
|
||||
### 按实际组 ID 或名称显示进程
|
||||
|
||||
```bash
|
||||
$ ps -G group[name or id]
|
||||
# OR
|
||||
$ ps --Group group[name or id]
|
||||
```
|
||||
|
||||
### 隐藏 ps 命令输出的标题
|
||||
|
||||
```bash
|
||||
$ ps h
|
||||
|
||||
PID TT STAT TIME COMMAND
|
||||
33790 s000 S+ 104:10.45 zsh (figterm)
|
||||
33800 s001 Ss+ 0:02.76 /bin/zsh --login
|
||||
77830 s002 S+ 90:22.51 zsh (figterm)
|
||||
77840 s003 Ss 0:00.66 /bin/zsh --login
|
||||
```
|
||||
|
||||
### 显示命令后的环境
|
||||
|
||||
```bash
|
||||
$ ps e
|
||||
|
||||
PID TTY STAT TIME COMMAND
|
||||
886 tty2 Ssl+ 0:00 /usr/li....
|
||||
```
|
||||
|
||||
### 重复 ps 命令输出的标题行
|
||||
|
||||
```bash
|
||||
$ ps --headers -A
|
||||
PID TTY TIME CMD
|
||||
1 ? 00:00:01 systemd
|
||||
2 ? 00:00:00 kthreadd
|
||||
3 ? 00:00:00 rcu_gp
|
||||
```
|
||||
|
||||
### 显示进程树
|
||||
|
||||
```bash
|
||||
$ ps --forest -A
|
||||
PID TTY TIME CMD
|
||||
2 ? 00:00:00 kthreadd
|
||||
3 ? 00:00:00 \_ rcu_gp
|
||||
4 ? 00:00:00 \_ rcu_par_gp
|
||||
960 ? 00:00:00 \_ goa-identity-se
|
||||
1118 ? 00:00:00 \_ at-spi-bus-laun
|
||||
1124 ? 00:00:00 | \_ dbus-daemon
|
||||
```
|
||||
|
||||
您可以使用 -H 选项打印进程层次结构
|
||||
|
||||
```bash
|
||||
$ ps -H -A
|
||||
PID TTY TIME CMD
|
||||
2 ? 00:00:00 kthreadd
|
||||
3 ? 00:00:00 rcu_gp
|
||||
1832 ? 00:00:37 gnome-terminal-
|
||||
1840 pts/0 00:00:00 bash
|
||||
1925 pts/1 00:00:00 bash
|
||||
2867 pts/1 00:00:00 su
|
||||
2868 pts/1 00:00:00 bash
|
||||
```
|
163
docs/pycharm.md
Normal file
@ -0,0 +1,163 @@
|
||||
PyCharm 键盘快捷键备忘清单
|
||||
===
|
||||
|
||||
这个 [PyCharm](https://resources.jetbrains.com/storage/products/pycharm/docs/PyCharm_ReferenceCard.pdf) 快速参考备忘单显示了它的键盘快捷键和命令
|
||||
|
||||
快捷键
|
||||
---
|
||||
|
||||
### 创建和编辑
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Alt` + `Enter` | 显示意图动作
|
||||
`Ctrl` + `Space` | 基本代码完成
|
||||
`Ctrl` + `Shift` + `Space` | 智能代码完成
|
||||
`Ctrl` + `Alt` + `Space` | 类型名称完成
|
||||
`Ctrl` + `Shift` + `Enter` | 完整声明
|
||||
`Ctrl` + `P` / `Alt` + `Q` | 参数信息/上下文信息
|
||||
`Ctrl` + `Shift` + `I` | 快速定义
|
||||
`Ctrl` + `Q` / `Shift` + `F1` | 快速/外部文档
|
||||
`Alt` + `Insert` | 生成代码
|
||||
`Ctrl` + `O` / `Ctrl` + `I` | 覆盖/实施成员
|
||||
`Ctrl` + `Alt` + `T` | 围绕着……
|
||||
`Ctrl` + `/` | 注释行注释
|
||||
`Ctrl` + `W` / `Ctrl` + `Shift` + `W` | 扩展/收缩选择
|
||||
`Ctrl` + `Alt` + `O` | 优化导入
|
||||
`Ctrl` + `Alt` + `I` | 自动缩进行
|
||||
`Ctrl` + `X` / `Ctrl` + `C` / `Ctrl` + `V` | 剪切/复制/粘贴
|
||||
`Ctrl` + `Shift` + `C` | 复制文档路径
|
||||
`Ctrl` + `Shift` + `V` | 从剪贴板历史粘贴
|
||||
`Ctrl` + `D` | 复制当前行或选择
|
||||
`Ctrl` + `Shift` + `Up` / `Down` | 向上/向下移动线
|
||||
`Ctrl` + `Y` | 删除插入符处的行
|
||||
`Ctrl` + `Shift` + `J` / `Ctrl` + `Enter` | 加入/分割线
|
||||
`Shift` + `Enter` | 开始新行
|
||||
`Ctrl` + `Shift` + `U` | 切换大小写
|
||||
`Ctrl` + `NumPad` `+` / `-` | 展开/折叠代码块
|
||||
`Ctrl` + `Shift` + `NumPad` `+` / `-` | 全部展开/折叠
|
||||
`Ctrl` + `S` | 保存全部
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 版本控制
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Alt` + <code>`</code> | VCS 操作弹出...
|
||||
`Ctrl` + `K` | 提交
|
||||
`Ctrl` + `T` | 更新项目
|
||||
`Alt` + `Shift` + `C` | 近期变动
|
||||
`Ctrl` + `Alt` + `Z` | 恢复
|
||||
`Ctrl` + `Shift` + `K` | 推…
|
||||
`Ctrl` + `Alt` + `Shift` + `Down` / `Up` | 下一个/上一个更改
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 掌握您的 IDE
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Ctrl`+`Shift`+`A` | 寻找行动...
|
||||
`Alt`+`[0-9]` | 打开一个工具窗口
|
||||
`Ctrl`+`Alt`+`Y` | 同步
|
||||
`Ctrl`+<code>`</code> | 快速切换方案...
|
||||
`Ctrl`+`Alt`+`S` | 设置...
|
||||
`F4` / `Alt`+`Home` | 跳转到源/导航栏
|
||||
`F12` | 跳转到最后一个工具窗口
|
||||
`Shift`+`Esc` / `Ctrl`+`Shift`+`F12` | 隐藏活动/所有工具窗口
|
||||
`Alt`+`Right` / `Alt`+`Left` | 转到下一个/上一个编辑器选项卡
|
||||
`Esc` | 转到编辑器(从工具窗口)
|
||||
`Ctrl`+`Shift`+`F4` / `Ctrl`+`F4` | 关闭活动标签/窗口
|
||||
<!--rehype:className=shortcuts left-align-->
|
||||
|
||||
### 找到一切
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Shift` + `Shift` | 到处搜索
|
||||
`Ctrl` + `F` / `R` | 查找/替换
|
||||
`Ctrl` + `Shift` + `F` / `R` | 在路径中查找/在路径中替换
|
||||
`F3` / `Shift` + `F3` | 下/上一个事件
|
||||
`Ctrl` + `F3` | 在插入符处查找单词
|
||||
`Ctrl` + `N` / `Ctrl` + `Shift` + `N` | 去班级/档案
|
||||
`Ctrl` + `F12` | 转到文件成员
|
||||
`Ctrl` + `Alt` + `Shift` + `N` | 转到符号
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 从符号导航
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Ctrl` + `B` | 声明
|
||||
`Ctrl` + `Shift` + `B` | 类型声明 _(仅限 JavaScript)_
|
||||
`Ctrl` + `U` | 超级方法
|
||||
`Ctrl` + `Alt` + `B` | 实施
|
||||
`Alt` + `F7` / `Ctrl` + `F7` | 查找用法/在文件中查找用法
|
||||
`Ctrl` + `Shift` + `F7` | 突出显示文件中的用法
|
||||
`Ctrl` + `Alt` + `F7` | 显示用法
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 重构和清理
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Ctrl` + `Alt` + `Shift` + `T` | 重构这个……
|
||||
`F5` /`F6` | 复制…/移动…
|
||||
`Alt` + `Delete` | 安全删除…
|
||||
`Shift` + `F6` | 改名…
|
||||
`Ctrl` + `F6` | 更改签名…
|
||||
`Ctrl` + `Alt` + `N` | 排队…
|
||||
`Ctrl` + `Alt` + `M` | 提取方法
|
||||
`Ctrl` + `Alt` + `V` / `P` | 引入变量/参数
|
||||
`Ctrl` + `Alt` + `F` / `C` | 引入字段/常量
|
||||
`Ctrl` + `Alt` + `L` | 重新格式化代码
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 分析和探索
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Ctrl` + `F1` | 显示错误描述
|
||||
`F2` / `Shift` + `F2` | 下一个/上一个突出显示的错误
|
||||
`Ctrl` + `Alt` + `Shift` + `I` | 按名称运行检查...
|
||||
`Ctrl` + `H` / `Ctrl` + `Alt` + `H` | 类型/调用层次结构
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 在上下文中导航
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Alt`+`F1` | 选择...
|
||||
`Ctrl`+`E` / `Ctrl`+`Shift`+`E` | 最近查看/最近位置
|
||||
`Ctrl`+`Shift`+`Back` | 最后编辑位置
|
||||
`Ctrl`+`Alt`+`Left` / `Right` | 向后/向前导航
|
||||
`Alt`+`Up` / `Down` | 转到上一个/下一个方法
|
||||
`Ctrl`+`G` | 转到行/列...
|
||||
`Ctrl`+`]` / `[` | 转到代码块结束/开始
|
||||
`Alt`+`Shift`+`F` | 添加到收藏夹
|
||||
`F11` | 切换书签
|
||||
`Ctrl`+`F11` | 使用助记符切换书签
|
||||
`Ctrl`+`[0-9]` | 转到编号书签
|
||||
`Shift`+`F11` | 显示书签
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 构建、运行和调试
|
||||
|
||||
:-- | --
|
||||
:-- | --
|
||||
`Ctrl` + `Shift` + `F10` | 运行上下文配置
|
||||
`Alt` + `Shift` + `F10`/`F9` | 运行/调试所选配置
|
||||
`Shift` + `F10`/`F9` | 运行/调试当前配置
|
||||
`F8` / `F7` | 跨过/进入
|
||||
`Shift` + `F7` | 智能步入
|
||||
`Shift` + `F8` | 走出去
|
||||
`Alt` + `F9` / `Ctrl` + `Alt` + `F9` | 运行到光标/强制运行到光标
|
||||
`Alt` + `F10` | 显示执行点
|
||||
`Alt` + `F8` | 评估表达...
|
||||
`Ctrl` + `F2` | 停止
|
||||
`Ctrl` + `Shift` + `F2` | 停止后台进程...
|
||||
`F9` | 恢复程序
|
||||
`Ctrl` + `F8` | 切换行断点
|
||||
`Ctrl` + `Alt` + `Shift` + `F8` | 切换临时行断点
|
||||
`Ctrl` + `Shift` + `F8` | 编辑/查看断点
|
||||
<!--rehype:className=shortcuts-->
|
@ -441,6 +441,18 @@ Enter your name: Tom
|
||||
True
|
||||
```
|
||||
|
||||
### 转义符号
|
||||
|
||||
| 转义符号 | 对应的操作 |
|
||||
|---|---|
|
||||
| `\\` | 输出反斜杠 |
|
||||
| `\'` | 输出单引号 |
|
||||
| `\"` | 输出双引号 |
|
||||
| `\n` | 换行 |
|
||||
| `\t` | 水平制表符 |
|
||||
| `\r` | 光标回到首位 |
|
||||
| `\b` | 退格 |
|
||||
|
||||
Python F 字符串(自 Python 3.6+ 起)
|
||||
----------------
|
||||
|
||||
|
@ -838,6 +838,16 @@ H2 部分
|
||||
|
||||
默认表格末尾列`右对齐`,添加 `<!--rehype:className=left-align-->` 类让其`左对齐`
|
||||
|
||||
### 强制 code 不换行
|
||||
|
||||
| Command | Description |
|
||||
| ---- | ---- |
|
||||
| `adb remount` | Remounts file system with read/write access |
|
||||
| `adb reboot bootloader` | Reboots the device into fastboot |
|
||||
<!--rehype:className=show-header code-nowrap-->
|
||||
|
||||
添加 `<!--rehype:className=code-nowrap-->` 注释
|
||||
|
||||
列表
|
||||
---
|
||||
|
||||
|
@ -30,8 +30,8 @@ $ ruby --version
|
||||
|
||||
<red>注意:</red> macOS 12.5.1 附带了 Ruby <pur>**2.6.8**</pur>,这不是 React Native 所要求的,React Native 70+ 需要 Ruby <yel>**2.7.5**</yel>,可以使用下面工具切换版本:
|
||||
|
||||
- [rbenv](https://github.com/rbenv/rbenv)
|
||||
- [RVM](https://rvm.io/)
|
||||
- [rbenv](https://github.com/rbenv/rbenv) _推荐_
|
||||
- [RVM](https://rvm.io/) _推荐_
|
||||
- [chruby](https://github.com/postmodern/chruby)
|
||||
- 带有 [asdf-ruby](https://github.com/asdf-vm/asdf-ruby) 插件的 [asdf-vm](https://github.com/asdf-vm)
|
||||
<!--rehype:className=cols-2-->
|
||||
@ -41,9 +41,11 @@ $ ruby --version
|
||||
```bash
|
||||
$ npx react-native init MyApp
|
||||
# 指定 React Native 版本创建
|
||||
$ npx react-native init MyApp --version X.XX.X
|
||||
$ npx react-native init MyApp \
|
||||
--version X.XX.X
|
||||
# 创建 typescript 版本项目
|
||||
$ npx react-native init MyTSApp --template react-native-template-typescript
|
||||
$ npx react-native init MyTSApp \
|
||||
--template react-native-template-typescript
|
||||
```
|
||||
|
||||
安装依赖
|
||||
@ -58,8 +60,10 @@ $ bundle exec pod install # 以安装 iOS 依赖项
|
||||
运行你的 React Native 应用程序
|
||||
|
||||
```bash
|
||||
# 启动监听打包 JS 服务
|
||||
# 启动监听打包 JS 服务,默认端口 8081
|
||||
$ npx react-native start
|
||||
# 指定 8088 端口
|
||||
$ npx react-native start --port=8088
|
||||
# 启动 iOS 模拟器运行你的应用
|
||||
$ npx react-native run-ios
|
||||
```
|
||||
|
1071
docs/reactrouter.md
Normal file
@ -1,4 +1,4 @@
|
||||
Systemd
|
||||
Systemd 备忘清单
|
||||
===
|
||||
|
||||
最常用的 [Systemd](https://systemd.io/) 命令备忘单快速参考
|
||||
|
3238
docs/tailwindcss.md
Normal file
@ -1350,6 +1350,7 @@ const point = [3, 4] as const
|
||||
```
|
||||
|
||||
### satisfies
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
`satisfies` 允许将验证表达式的类型与某种类型匹配,而无需更改该表达式的结果类型。
|
||||
|
||||
@ -1385,10 +1386,10 @@ const palette = {
|
||||
// undefined | number
|
||||
const redComponent = palette.red.at(0)
|
||||
```
|
||||
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### 范型实例化表达式
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
不使用的情况下:
|
||||
|
||||
@ -1432,6 +1433,207 @@ const makeStringBox = makeBox<string>;
|
||||
makeStringBox(42);
|
||||
```
|
||||
|
||||
### 识别全局修改模块
|
||||
|
||||
```ts
|
||||
declare global {
|
||||
interface String {
|
||||
fancyFormat(opts: FancyOption): string;
|
||||
}
|
||||
}
|
||||
export interface FancyOption {
|
||||
fancinessLevel: number;
|
||||
}
|
||||
```
|
||||
|
||||
.d.ts 模版
|
||||
---
|
||||
|
||||
### Module: Plugin
|
||||
|
||||
例如,当您想使用扩展另一个库的 JavaScript 代码时
|
||||
|
||||
```ts
|
||||
import { greeter } from "super-greeter";
|
||||
// 普通欢迎 API
|
||||
greeter(2);
|
||||
greeter("Hello world");
|
||||
// 现在我们在运行时用一个新函数扩展对象
|
||||
import "hyper-super-greeter";
|
||||
greeter.hyperGreet();
|
||||
```
|
||||
|
||||
"`super-greeter`" 的定义:
|
||||
|
||||
```ts
|
||||
/* 此示例说明如何为您的函数设置多个重载 */
|
||||
export interface GreeterFunction {
|
||||
(name: string): void
|
||||
(time: number): void
|
||||
}
|
||||
/* 此示例显示如何导出接口指定的函数 */
|
||||
export const greeter: GreeterFunction;
|
||||
```
|
||||
|
||||
我们可以像下面这样扩展现有模块:
|
||||
|
||||
```ts
|
||||
/* 导入这个模块添加到的模块 */
|
||||
import { greeter } from "super-greeter";
|
||||
/* 声明与上面导入的模块相同的模块,然后我们扩展 greeter 函数的现有声明 */
|
||||
export module "super-greeter" {
|
||||
export interface GreeterFunction {
|
||||
/** Greets even better! */
|
||||
hyperGreet(): void;
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### 全局库模板 Global .d.ts
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
全局库可能如下所示:
|
||||
|
||||
```ts
|
||||
function createGreeting(s) {
|
||||
return "Hello, " + s;
|
||||
}
|
||||
```
|
||||
|
||||
或者像这样:
|
||||
|
||||
```ts
|
||||
window.createGreeting = function (s) {
|
||||
return "Hello, " + s;
|
||||
};
|
||||
```
|
||||
|
||||
<pur>类型声明示例</pur>
|
||||
|
||||
```ts
|
||||
/* 可以作为 myLib(3) 此处包含这些调用签名 */
|
||||
declare function myLib(a: string): string;
|
||||
declare function myLib(a: number): number;
|
||||
/* 如果你希望这个库的名称是一个有效的类型名称,你可以在这里这样做例如,这允许我们写 'var x: myLib'; 确保这确实有意义! 如果没有,只需删除此声明并在下面的命名空间内添加类型 */
|
||||
interface myLib {
|
||||
name: string;
|
||||
length: number;
|
||||
extras?: string[];
|
||||
}
|
||||
/* 如果您的库在全局变量上公开了属性,请将它们放在此处。 您还应该在此处放置类型(接口和类型别名) */
|
||||
declare namespace myLib {
|
||||
// 我们可以写 'myLib.timeout = 50;'
|
||||
let timeout: number;
|
||||
// 我们可以访问 'myLib.version',但不能更改它
|
||||
const version: string;
|
||||
// 我们可以通过 'let c = new myLib.Cat(42)' 创建一些类或参考例如 '函数 f(c: myLib.Cat) { ... }
|
||||
class Cat {
|
||||
constructor(n: number);
|
||||
// 我们可以从 'Cat' 实例中读取 'c.age'
|
||||
readonly age: number;
|
||||
// 我们可以从 'Cat' 实例调用 'c.purr()'
|
||||
purr(): void;
|
||||
}
|
||||
// 我们可以将变量声明为
|
||||
// 'var s: myLib.CatSettings = { weight: 5, name: "Maru" };'
|
||||
interface CatSettings {
|
||||
weight: number;
|
||||
name: string;
|
||||
tailLength?: number;
|
||||
}
|
||||
// 我们可以写 'const v: myLib.VetID = 42;'
|
||||
// 或 'const v: myLib.VetID = "bob";'
|
||||
type VetID = string | number;
|
||||
// 我们可以调用 'myLib.checkCat(c)' 或 'myLib.checkCat(c, v);'
|
||||
function checkCat(c: Cat, s?: VetID);
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Module: Function
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```ts
|
||||
import greeter from "super-greeter";
|
||||
greeter(2);
|
||||
greeter("Hello world");
|
||||
```
|
||||
|
||||
要处理通过 `UMD` 和模块导入:
|
||||
|
||||
```ts
|
||||
/* 如果此模块是一个 UMD 模块,在模块加载器环境之外加载时公开全局变量“myFuncLib”,请在此处声明该全局变量。 否则,删除此声明 */
|
||||
export as namespace myFuncLib;
|
||||
/* 此声明指定该函数是从文件中导出的对象 */
|
||||
export = Greeter;
|
||||
/* 此示例说明如何为您的函数设置多个重载 */
|
||||
declare function Greeter(name: string): Greeter.NamedReturnType;
|
||||
declare function Greeter(length: number): Greeter.LengthReturnType;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
如果你也想从你的模块中公开类型,你可以把它们放在这个块中。 通常你会想要描述函数返回类型的形状; 如本例所示,应在此处声明该类型,请注意,如果您决定包含此命名空间,则模块可能会被错误地导入为命名空间对象,除非 `--esModuleInterop` 已打开: `import * as x from '[~THE MODULE~]';` 错误的!不要这样做!
|
||||
|
||||
```ts
|
||||
declare namespace Greeter {
|
||||
export interface LengthReturnType {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
export interface NamedReturnType {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
/**
|
||||
* 如果模块也有属性,在这里声明它们。 例如,这个声明说这个代码是合法的:
|
||||
* import f = require('super-greeter');
|
||||
* console.log(f.defaultName);
|
||||
*/
|
||||
export const defaultName: string;
|
||||
export let defaultLength: number;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Module: Class
|
||||
|
||||
例如,当您想要使用如下所示的 `JavaScript` 代码时:
|
||||
|
||||
```ts
|
||||
const Greeter = require("super-greeter");
|
||||
const greeter = new Greeter();
|
||||
greeter.greet();
|
||||
```
|
||||
|
||||
要处理通过 `UMD` 和模块导入:
|
||||
|
||||
```ts
|
||||
export as namespace "super-greeter";
|
||||
/* 此声明指定类构造函数是从文件中导出的对象 */
|
||||
export = Greeter;
|
||||
/* 在此类中编写模块的方法和属性 */
|
||||
declare class Greeter {
|
||||
constructor(customGreeting?: string);
|
||||
greet: void;
|
||||
myMethod(opts: MyClass.MyClassMethodOptions): number;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
如果你也想从你的模块中公开类型,你可以把它们放在这个块中,如果您决定包含此命名空间,则模块可能会被错误地导入为命名空间对象,除非 --esModuleInterop 已打开:
|
||||
`import * as x from '[~THE MODULE~]';` 错误的! 不要这样做!
|
||||
|
||||
```ts
|
||||
declare namespace MyClass {
|
||||
export interface MyClassMethodOptions {
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
CLI
|
||||
---
|
||||
|
||||
@ -1463,7 +1665,7 @@ $ tsc app.ts util.ts --target esnext --outfile index.js
|
||||
`--init` _boolean_ | 初始化 TypeScript 项目并创建 tsconfig.json 文件
|
||||
`--listFilesOnly` _boolean_ | 打印作为编译一部分的文件名,然后停止处理
|
||||
`--locale` _string_ | 设置来自 TypeScript 的消息传递语言。 这不影响发射
|
||||
`--project` _string_ | 编译项目给定其配置文件的路径,或带有“tsconfig.json”的文件夹
|
||||
`--project` _string_ | 编译项目给定其配置文件的路径,或带有 'tsconfig.json' 的文件夹
|
||||
`--showConfig` _boolean_ | 打印最终配置而不是构建
|
||||
`--version` _boolean_ | 打印编译器的版本
|
||||
<!--rehype:className=style-list-->
|
||||
|
@ -5,16 +5,16 @@ VSCode 备忘清单
|
||||
|
||||
## Windows
|
||||
|
||||
### 一般的
|
||||
### 通用
|
||||
|
||||
| - | - |
|
||||
|-----------------------------|------------------------|
|
||||
| `Ctrl` `Shift` `P` _/_ `F1` | 显示命令面板 |
|
||||
| `Ctrl` `P` | 快速打开,转到文件 |
|
||||
| `Ctrl` `Shift` `N` | 新窗户 |
|
||||
| `Ctrl` `Shift` `W` | 关闭窗口 |
|
||||
| `Ctrl` `,` | 用户设置 |
|
||||
| `Ctrl` `K` `Ctrl` `S` | 键盘快捷键 |
|
||||
| `Ctrl` `Shift` `N` | 打开新窗口 |
|
||||
| `Ctrl` `Shift` `W` | 关闭当前窗口 |
|
||||
| `Ctrl` `,` | 打开用户设置 |
|
||||
| `Ctrl` `K` `Ctrl` `S` | 打开键盘快捷键设置 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 基本编辑
|
||||
@ -36,16 +36,16 @@ VSCode 备忘清单
|
||||
| `Ctrl` `End` | 转到文件末尾 |
|
||||
| `Ctrl` `↑` _/_ `↓` | 向上/向下滚动行 |
|
||||
| `Alt` `PgUp` _/_ `PgDn` | 向上/向下滚动页面 |
|
||||
| `Ctrl` `Shift` `[` | 折叠(折叠)区域 |
|
||||
| `Ctrl` `Shift` `]` | 展开(展开)区域 |
|
||||
| `Ctrl` `K` `Ctrl` `[` | 折叠(折叠)所有子区域 |
|
||||
| `Ctrl` `K` `Ctrl` `]` | 展开(展开)所有子区域 |
|
||||
| `Ctrl` `K` `Ctrl` `0` | 折叠(折叠)所有区域 |
|
||||
| `Ctrl` `K` `Ctrl` `J` | 展开(展开)所有区域 |
|
||||
| `Ctrl` `Shift` `[` | 折叠区域 |
|
||||
| `Ctrl` `Shift` `]` | 展开区域 |
|
||||
| `Ctrl` `K` `Ctrl` `[` | 折叠所有子区域 |
|
||||
| `Ctrl` `K` `Ctrl` `]` | 展开所有子区域 |
|
||||
| `Ctrl` `K` `Ctrl` `0` | 折叠所有区域 |
|
||||
| `Ctrl` `K` `Ctrl` `J` | 展开所有区域 |
|
||||
| `Ctrl` `K` `Ctrl` `C` | 添加行注释 |
|
||||
| `Ctrl` `K` `Ctrl` `U` | 删除行注释 |
|
||||
| `Ctrl` `/` | 切换行注释 |
|
||||
| `Shift` `Alt` `A` | 切换块评论 |
|
||||
| `Shift` `Alt` `A` | 切换块注释 |
|
||||
| `Alt` `Z` | 切换自动换行 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
@ -54,28 +54,28 @@ VSCode 备忘清单
|
||||
| - | - |
|
||||
|----------------------|--------------------|
|
||||
| `Ctrl` `T` | 显示所有符号 |
|
||||
| `Ctrl` `G` | 去线 |
|
||||
| `Ctrl` `G` | 跳转到指定行数 |
|
||||
| `Ctrl` `P` | 转到文件 |
|
||||
| `Ctrl` `Shift` `O` | 转到符号 |
|
||||
| `Ctrl` `Shift` `M` | 显示问题面板 |
|
||||
| `F8` | 转到下一个错误 |
|
||||
| `Shift` `F8` | 转到上一个错误 |
|
||||
| `Ctrl` `Shift` `Tab` | 浏览编辑组历史 |
|
||||
| `Alt` `←` _/_ `→` | 后退/前进 |
|
||||
| `Ctrl` `M` | 切换 Tab 移动焦点 |
|
||||
| `Alt` `←` _/_ `→` | 后退/前进 |
|
||||
| `Ctrl` `M` | 切换按 Tab 移动焦点 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 搜索和替换
|
||||
|
||||
| - | - |
|
||||
|---------------------------|---------------------------------|
|
||||
| `Ctrl` `F` | 寻找 |
|
||||
| `Ctrl` `H` | 代替 |
|
||||
| `Ctrl` `F` | 查找 |
|
||||
| `Ctrl` `H` | 替换 |
|
||||
| `F3` _/_ `Shift` `F3` | 查找下一个/上一个 |
|
||||
| `Alt` `Enter` | 选择所有出现的查找匹配项 |
|
||||
| `Ctrl` `D` | 将选择添加到下一个查找匹配项 |
|
||||
| `Ctrl` `K` `Ctrl` `D` | 将最后一个选择移动到下一个查找匹配项 |
|
||||
| `Alt` `C` _/_ `R` _/_ `W` | 切换区分大小写/正则表达式/整个单词 |
|
||||
| `Ctrl` `D` | 将所选内容设置为查找关键词 |
|
||||
| `Ctrl` `K` `Ctrl` `D` | 将上一个选择移动到下一个查找匹配项 |
|
||||
| `Alt` `C` _/_ `R` _/_ `W` | 切换区分大小写/正则表达式/全字匹配 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 多光标和选择
|
||||
@ -90,7 +90,7 @@ VSCode 备忘清单
|
||||
| `Ctrl` `Shift` `L` | 选择当前选择的所有匹配项 |
|
||||
| `Ctrl` `F2` | 选择当前单词的所有出现 |
|
||||
| `Shift` `Alt` `→` | 展开选择 |
|
||||
| `Shift` `Alt` `←` | 收缩选择 |
|
||||
| `Shift` `Alt` `←` | 收起选择 |
|
||||
| `Shift` `Alt` `<Drag>` | 列(框)选择 |
|
||||
| `Ctrl` `Shift` `Alt` `<Arrow>` | 列(框)选择 |
|
||||
| `Ctrl` `Shift` `Alt` `PgUp` _/_ `PgDn` | 列(框)选择页上/下 |
|
||||
@ -100,17 +100,17 @@ VSCode 备忘清单
|
||||
|
||||
| - | - |
|
||||
|-----------------------------|-----------------|
|
||||
| `Ctrl` `<Space>` `Ctrl` `I` | 触发建议 |
|
||||
| `Ctrl` `Shift` `<Space>` | 触发参数提示 |
|
||||
| `Ctrl` `<Space>` `Ctrl` `I` | 显示建议 |
|
||||
| `Ctrl` `Shift` `<Space>` | 显示参数提示 |
|
||||
| `Shift` `Alt` `F` | 格式化文档 |
|
||||
| `Ctrl` `K` `Ctrl` `F` | 格式选择 |
|
||||
| `Ctrl` `K` `Ctrl` `F` | 格式化所选区域 |
|
||||
| `F12` | 转到定义 |
|
||||
| `Alt` `F12` | 窥视定义 |
|
||||
| `Ctrl` `K` `F12` | 打开定义到一边 |
|
||||
| `Ctrl` `.` | 快速解决 |
|
||||
| `Shift` `F12` | 显示参考 |
|
||||
| `Alt` `F12` | 速览定义 |
|
||||
| `Ctrl` `K` `F12` | 在侧边栏中打开定义 |
|
||||
| `Ctrl` `.` | 快速修复 |
|
||||
| `Shift` `F12` | 显示引用 |
|
||||
| `F2` | 重命名符号 |
|
||||
| `Ctrl` `K` `Ctrl` `X` | 修剪尾随空格 |
|
||||
| `Ctrl` `K` `Ctrl` `X` | 删除尾随空格 |
|
||||
| `Ctrl` `K` `M` | 更改文件语言 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
@ -121,8 +121,8 @@ VSCode 备忘清单
|
||||
| `Ctrl` `F4` `Ctrl` `W` | 关闭编辑器 |
|
||||
| `Ctrl` `K` `F` | 关闭文件夹 |
|
||||
| `Ctrl` `\` | 拆分编辑器 |
|
||||
| `Ctrl` `1` _/_ `2` _/_ `3` | 专注于第一、第二或第三编辑组 |
|
||||
| `Ctrl` `K` `Ctrl` `←` _/_ `→` | 专注于上一个/下一个编辑组 |
|
||||
| `Ctrl` `1` _/_ `2` _/_ `3` | 将焦点切换到第一/二/三编辑组 |
|
||||
| `Ctrl` `K` `Ctrl` `←` _/_ `→` | 将焦点切换到上/下一个编辑组 |
|
||||
| `Ctrl` `Shift` `PgUp` _/_ `PgDn` | 向左/向右移动编辑器 |
|
||||
| `Ctrl` `K` `←` _/_ `→` | 移动活动编辑器组 |
|
||||
<!--rehype:className=shortcuts-->
|
||||
@ -137,11 +137,11 @@ VSCode 备忘清单
|
||||
| `Ctrl` `Shift` `S` | 另存为 |
|
||||
| `Ctrl` `K` `S` | 保存所有 |
|
||||
| `Ctrl` `F4` | 关闭 |
|
||||
| `Ctrl` `K` `Ctrl` `W` | 关闭松油 |
|
||||
| `Ctrl` `K` `Ctrl` `W` | 关闭所有 |
|
||||
| `Ctrl` `Shift` `T` | 重新打开关闭的编辑器 |
|
||||
| `Ctrl` `K` `Enter` | 保持预览模式编辑器打开 |
|
||||
| `Ctrl` `Tab` | Open next |
|
||||
| `Ctrl` `Shift` `Tab` | Open previous |
|
||||
| `Ctrl` `Tab` | 打开下一项 |
|
||||
| `Ctrl` `Shift` `Tab` | 打开上一项 |
|
||||
| `Ctrl` `K` `P` | 复制活动文件的路径 |
|
||||
| `Ctrl` `K` `R` | 在资源管理器中显示活动文件 |
|
||||
| `Ctrl` `K` `O` | 在新窗口/实例中显示活动文件 |
|
||||
@ -175,12 +175,12 @@ VSCode 备忘清单
|
||||
| `F9` | 切换断点 |
|
||||
| `F5` | 开始/继续 |
|
||||
| `Shift` `F5` | 停止 |
|
||||
| `Shift` `F11` _/_ `F11` | 进/出 |
|
||||
| `F10` | 跨过去 |
|
||||
| `Shift` `F11` _/_ `F11` | 单步调试/跳出 |
|
||||
| `F10` | 单步跳过 |
|
||||
| `Ctrl` `K` `Ctrl` `I` | 显示悬停 |
|
||||
| `Ctrl` <code>\`</code> | 显示综合终端 |
|
||||
| `Ctrl` `Shift` <code>\`</code> | 创建一个新终端 |
|
||||
| `Ctrl` `C` | 复制选择 |
|
||||
| `Ctrl` `C` | 复制所选内容 |
|
||||
| `Ctrl` `V` | 粘贴到活动终端 |
|
||||
| `Ctrl` `↑` _/_ `↓` | 向上/向下滚动 |
|
||||
| `Shift` `PgUp` _/_ `PgDn` | 向上/向下滚动页面 |
|
||||
|
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.31.0",
|
||||
"version": "1.35.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
@ -21,11 +21,18 @@
|
||||
"url": "https://github.com/jaywcjlove/reference/issues"
|
||||
},
|
||||
"keywords": [],
|
||||
"lint-staged": {
|
||||
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": "prettier --write",
|
||||
"*.md": "markdownlint --fix",
|
||||
"docs/*.md": "markdownlint --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"prettier": "^2.7.1",
|
||||
"refs-cli": "^1.2.7"
|
||||
"refs-cli": "^1.2.12",
|
||||
"markdownlint": "^0.27.0",
|
||||
"markdownlint-cli": "^0.32.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
|