Compare commits

...

24 Commits

Author SHA1 Message Date
e251179751 released v1.29.0 2022-11-29 21:51:36 +08:00
bf114d2ccf doc: update quickreference.md. 2022-11-29 12:33:53 +08:00
5877c04e57 doc: update quickreference.md #189 2022-11-29 12:09:28 +08:00
cb64b52cda doc: update react-native.md 2022-11-29 11:34:05 +08:00
396037f90a doc: Update README.md 2022-11-29 09:03:47 +08:00
3ad1e261c2 doc: modify README.md. 2022-11-28 17:12:51 +00:00
915a802060 doc: modify CONTRIBUTING.md. 2022-11-28 17:12:50 +00:00
b9ca744978 feat: add react-native.md cheatsheet. 2022-11-29 01:11:15 +08:00
c514341b29 doc: update typescript.md (#186) 2022-11-28 23:47:57 +08:00
9562c34876 doc: update cocoapods.md 2022-11-28 22:04:14 +08:00
91190ec29a doc: modify README.md. 2022-11-28 13:51:07 +00:00
7b5e77dd30 doc: modify CONTRIBUTING.md. 2022-11-28 13:51:06 +00:00
a41ec2693e doc: update github-action.md (#184) 2022-11-28 21:49:44 +08:00
f915f4c155 fix: webstorm.md (#182) 2022-11-28 17:42:25 +08:00
e1bf0f9655 doc: modify README.md. 2022-11-28 08:22:14 +00:00
5728ac71f9 doc: modify CONTRIBUTING.md. 2022-11-28 08:22:13 +00:00
39fef5e856 doc: update rust.md (#181) (#20) 2022-11-28 16:20:56 +08:00
d1b87b9de9 doc: Update ffmpeg.md (#180)
增加ffmpeg流处理
2022-11-28 10:27:14 +08:00
026dc585a8 released v1.28.0 2022-11-27 22:44:27 +08:00
d09737fcda doc: update flutter.md #179 #58 2022-11-27 22:42:25 +08:00
029e2751c4 feat: add nextjs.md cheatsheet. 2022-11-27 22:33:24 +08:00
0a4bd03900 doc: update flutter.md (#179)
* doc: update flutter.md

* doc: update flutter.md
2022-11-27 17:17:10 +08:00
fe7782a0c4 doc: update github-actions.md #170 2022-11-27 10:22:20 +08:00
9751df06b9 doc: update rust.md (#178)
* doc: match let

* update
2022-11-27 01:52:50 +08:00
17 changed files with 4003 additions and 22 deletions

View File

@ -6,6 +6,7 @@ on:
jobs:
build:
if: github.repository == 'jaywcjlove/reference'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -58,7 +59,6 @@ jobs:
filter-author: (小弟调调™)
filter: (^[\s]+?[R|r]elease)|(^[R|r]elease)
- name: Create Release
uses: ncipollo/release-action@v1
if: steps.create_tag.outputs.successful
@ -69,26 +69,26 @@ jobs:
body: |
Documentation ${{ needs.build.outputs.create_tag_version }}: https://raw.githack.com/jaywcjlove/reference/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}
## Docker
[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/wcjiang/reference)](https://hub.docker.com/r/wcjiang/reference) [![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/wcjiang/reference)](https://hub.docker.com/r/wcjiang/reference) [![Docker Pulls](https://img.shields.io/docker/pulls/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/
```
@ -144,8 +144,6 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
# # Create Docker Image in Github
# - name: Login to GitHub registry
# run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
@ -166,7 +164,7 @@ jobs:
# # Create Docker Image
# - name: Docker login
# run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
# - name: Build reference image
# run: docker image build -t reference .
@ -181,4 +179,4 @@ jobs:
# run: |
# echo "outputs.tag - ${{ steps.changelog.outputs.version }}"
# docker tag reference ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
# docker push ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
# docker push ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}

View File

@ -6,6 +6,7 @@ on:
jobs:
build:
if: github.repository == 'jaywcjlove/reference'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
@ -24,4 +25,4 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: dist
path: ${{ github.workspace }}\dist\**\*
path: ${{ github.workspace }}\dist\**\*

View File

@ -193,6 +193,9 @@ REF_LABEL=网站首页
<a href="https://github.com/demigodliu" title="DemigodLiu">
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
</a>
<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/jasnzhuang" title="Jason Zhuang">
<img src="https://avatars.githubusercontent.com/u/16612921?v=4" width="42;" alt="Jason Zhuang"/>
</a>
@ -259,6 +262,9 @@ REF_LABEL=网站首页
<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/Mowmowj" title="shelton">
<img src="https://avatars.githubusercontent.com/u/24759562?v=4" width="42;" alt="shelton"/>
</a>
<a href="https://github.com/wjjwkwindy" title="wjjwkwindy">
<img src="https://avatars.githubusercontent.com/u/9508591?v=4" width="42;" alt="wjjwkwindy"/>
</a>

View File

@ -27,7 +27,7 @@ Quick Reference
[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-->
[Lua](./docs/lua.md)<!--rehype:style=background: rgb(3 3 128);-->
[Lua](./docs/lua.md)<!--rehype:style=background: rgb(3 3 128);&class=contributing-->
[NestJS](./docs/nestjs.md)<!--rehype:style=background: rgb(237 21 67);&class=contributing-->
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168);&class=contributing-->
[Oracle](./docs/oracle.md)<!--rehype:style=background: rgb(255 0 0);&class=contributing tag&data-lang=SQL-->
@ -84,7 +84,9 @@ Quick Reference
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39);-->
[JavaScript](./docs/javascript.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 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);-->
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131);-->
@ -230,6 +232,9 @@ Quick Reference
<a href="https://github.com/demigodliu" title="DemigodLiu">
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
</a>
<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/jasnzhuang" title="Jason Zhuang">
<img src="https://avatars.githubusercontent.com/u/16612921?v=4" width="42;" alt="Jason Zhuang"/>
</a>
@ -296,6 +301,9 @@ Quick Reference
<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/Mowmowj" title="shelton">
<img src="https://avatars.githubusercontent.com/u/24759562?v=4" width="42;" alt="shelton"/>
</a>
<a href="https://github.com/wjjwkwindy" title="wjjwkwindy">
<img src="https://avatars.githubusercontent.com/u/9508591?v=4" width="42;" alt="wjjwkwindy"/>
</a>

3
assets/nextjs.svg Normal file
View 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 fill-rule="evenodd" clip-rule="evenodd" d="M0 7.5a7.5 7.5 0 1 1 11.697 6.216L4.907 4.21A.5.5 0 0 0 4 4.5V12h1V6.06l5.83 8.162A7.5 7.5 0 0 1 0 7.5ZM10 10V4h1v6h-1Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 299 B

7
assets/react-native.svg Normal file
View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="1em" width="1em">
<circle cx="12" cy="11.245" r="1.785"/>
<path d="m7.002 14.794-.395-.101c-2.934-.741-4.617-2.001-4.617-3.452 0-1.452 1.684-2.711 4.617-3.452l.395-.1.111.391a19.507 19.507 0 0 0 1.136 2.983l.085.178-.085.178c-.46.963-.841 1.961-1.136 2.985l-.111.39zm-.577-6.095c-2.229.628-3.598 1.586-3.598 2.542 0 .954 1.368 1.913 3.598 2.54.273-.868.603-1.717.985-2.54a20.356 20.356 0 0 1-.985-2.542zm10.572 6.095-.11-.392a19.628 19.628 0 0 0-1.137-2.984l-.085-.177.085-.179c.46-.961.839-1.96 1.137-2.984l.11-.39.395.1c2.935.741 4.617 2 4.617 3.453 0 1.452-1.683 2.711-4.617 3.452l-.395.101zm-.41-3.553c.4.866.733 1.718.987 2.54 2.23-.627 3.599-1.586 3.599-2.54 0-.956-1.368-1.913-3.599-2.542a20.683 20.683 0 0 1-.987 2.542z"/>
<path d="m6.419 8.695-.11-.39c-.826-2.908-.576-4.991.687-5.717 1.235-.715 3.222.13 5.303 2.265l.284.292-.284.291a19.718 19.718 0 0 0-2.02 2.474l-.113.162-.196.016a19.646 19.646 0 0 0-3.157.509l-.394.098zm1.582-5.529c-.224 0-.422.049-.589.145-.828.477-.974 2.138-.404 4.38.891-.197 1.79-.338 2.696-.417a21.058 21.058 0 0 1 1.713-2.123c-1.303-1.267-2.533-1.985-3.416-1.985zm7.997 16.984c-1.188 0-2.714-.896-4.298-2.522l-.283-.291.283-.29a19.827 19.827 0 0 0 2.021-2.477l.112-.16.194-.019a19.473 19.473 0 0 0 3.158-.507l.395-.1.111.391c.822 2.906.573 4.992-.688 5.718a1.978 1.978 0 0 1-1.005.257zm-3.415-2.82c1.302 1.267 2.533 1.986 3.415 1.986.225 0 .423-.05.589-.145.829-.478.976-2.142.404-4.384-.89.198-1.79.34-2.698.419a20.526 20.526 0 0 1-1.71 2.124z"/>
<path d="m17.58 8.695-.395-.099a19.477 19.477 0 0 0-3.158-.509l-.194-.017-.112-.162A19.551 19.551 0 0 0 11.7 5.434l-.283-.291.283-.29c2.08-2.134 4.066-2.979 5.303-2.265 1.262.727 1.513 2.81.688 5.717l-.111.39zm-3.287-1.421c.954.085 1.858.228 2.698.417.571-2.242.425-3.903-.404-4.381-.824-.477-2.375.253-4.004 1.841.616.67 1.188 1.378 1.71 2.123zM8.001 20.15a1.983 1.983 0 0 1-1.005-.257c-1.263-.726-1.513-2.811-.688-5.718l.108-.391.395.1c.964.243 2.026.414 3.158.507l.194.019.113.16c.604.878 1.28 1.707 2.02 2.477l.284.29-.284.291c-1.583 1.627-3.109 2.522-4.295 2.522zm-.993-5.362c-.57 2.242-.424 3.906.404 4.384.825.47 2.371-.255 4.005-1.842a21.17 21.17 0 0 1-1.713-2.123 20.692 20.692 0 0 1-2.696-.419z"/>
<path d="M12 15.313c-.687 0-1.392-.029-2.1-.088l-.196-.017-.113-.162a25.697 25.697 0 0 1-1.126-1.769 26.028 26.028 0 0 1-.971-1.859l-.084-.177.084-.179c.299-.632.622-1.252.971-1.858.347-.596.726-1.192 1.126-1.77l.113-.16.196-.018a25.148 25.148 0 0 1 4.198 0l.194.019.113.16a25.136 25.136 0 0 1 2.1 3.628l.083.179-.083.177a24.742 24.742 0 0 1-2.1 3.628l-.113.162-.194.017c-.706.057-1.412.087-2.098.087zm-1.834-.904c1.235.093 2.433.093 3.667 0a24.469 24.469 0 0 0 1.832-3.168 23.916 23.916 0 0 0-1.832-3.168 23.877 23.877 0 0 0-3.667 0 23.743 23.743 0 0 0-1.832 3.168 24.82 24.82 0 0 0 1.832 3.168z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -11,6 +11,8 @@ CocoaPods 备忘清单
```bash
$ sudo gem install cocoapods
# OR
$ brew install cocoapods
```
无 Sudo 安装,不想为此过程授予 `RubyGems` 管理员权限

View File

@ -718,6 +718,30 @@ $ ffmpeg -i test.mp4 -af "loudnorm=I=-5:LRA=1" out.mp4
$ ffmpeg -i input.mp3 -af "channelmap=1-0|1-1" output.mp3
```
流处理
---
### 拉流
```bash
# 拉取rtmp流并存储到本地
$ ffmpeg -i "rtsp://127.0.0.1/test" test.mp4
```
### 推流
```bash
# 推送test.mp4到远程
$ ffmpeg -re -i test.mp4 -f flv rtmp://127.0.0.1/test
```
### 转发
```bash
# 拉取流并转发
$ ffmpeg -i "rtsp://127.0.0.1/test" -f mpegts -codec:v mpeg1video http://127.0.0.1/demo
```
另见
---

View File

@ -421,8 +421,6 @@ SizedBox(
在实际开发中Container常常用于对一个组件进行包装修饰。
```dart
// 将Contianer大小固定为100 * 100 背景色为蓝色。
// 把Text包裹在Container中并将其居中
Container(
width: 100,
height: 100,
@ -430,9 +428,10 @@ Container(
alignment: Alignment.center,
child: Text('Hello world'),
),
```
将 `Contianer` 大小固定为 `100 * 100` 背景色为蓝色。把 `Text` 包裹在 `Container` 中,并将其居中
### Column
列布局(Column),可以将多个子组件沿着垂直的方向摆放(竖的摆放)
@ -461,7 +460,6 @@ Column(
行布局(Row),可以将多个组件沿水平的方向摆放。
```dart
// 在同一行摆放3个Button
Row(
children: [
ElevatedButton(
@ -480,12 +478,13 @@ Row(
),
```
在同一行摆放 3 个 `Button`
### Wrap
将子组件从左到右依次排列,当空间不足时自动换行。
```dart
// 显示多个Flutter 的logo并自动换行
Wrap(
children: [
FlutterLogo(),
@ -498,14 +497,14 @@ Wrap(
),
```
显示多个 `Flutter` 的 `logo` 并自动换行
### Stack
Stack 可以将一多个子组件叠在一起显示。堆叠顺序按照children属性中的列表依次堆叠摆放默认将子控件沿左上角对齐。
需要控制子控件位置可以嵌套`Positoned`控件。
```dart
// 依次堆叠300*300的蓝色色块、200*200的黑色色块、
// 100*100的黄色色块
Stack(
children: [
Container(
@ -527,6 +526,8 @@ Stack(
),
```
依次堆叠 `300*300` 的蓝色色块、`200*200` 的黑色色块、`100*100` 的黄色色块
### Positioned
<!--rehype:wrap-class=row-span-2-->
若需要控制Stack中子控件的位置则可以嵌套改控件。
@ -603,6 +604,131 @@ Container(
),
```
### Flex
Flex 的用法与 `Row` 或 `Column` 类似,但只需要额外传入 `direction` 参数
- `Row` 和 `Column` 组件都继承 `Flex` 组件
- 设置 `direction` 为 `Axis.horizontal` 表示水平方向(`Row`),为 `Axis.vertical`则为垂直方向(`Column`)
垂直方向依次摆放3个flutter logo
```dart
Flex(
direction: Axis.vertiacl,
children[
Fluterlogo(),
Fluterlogo(),
Fluterlogo(),
],
),
```
水平方向依次摆放 3 个 flutter logo
```dart
Flex(
dirction: Axis.horizontal,
children: [
Flutterlogo(),
Flutterlogo(),
Flutterlogo(),
],
),
```
### Expaneded
<!--rehype:wrap-class=row-span-2-->
Expanded 用于扩张一个子组件。可以通过 `flex` 属性,用于表示该组件相对其他弹性组件放大的倍数(可以理解为一个权重)。
```dart
// Container 会占满剩余的全部空用空间
Row(
children: [
FlutterLogo(),
Expanded(
child: Container(
child: FlutterLogo(),
color: Colors.green,
),
),
FlutterLogo(),
],
),
// 按照1:2 的比例分配一整行的空间
Row(
children: [
Expanded(
flex: 1,
child: Container(
child: FlutterLogo(),
color: Colors.green,
),
),
Expanded(
flex: 2,
child: Container(
child: FlutterLogo(),
color: Colors.blue,
),
),
],
),
```
### Flexible
<!--rehype:wrap-class=row-span-2-->
`Flexible` 是 `Expanded` 组件的父类。
与 `Expanded` 不同的是,`Flexible` 可以通过 `fit` 属性设置子控件是否必须占满 `Flexibal` 扩展的空间。而 `Expaned` 默认子控件必须占满
```dart
// 如果将fit设置为tight
// 则绿色Container 和蓝色Container大小一样。
// 如果将fit设置为loose
// 则两个Flexible扩展的空间大小是一样的
// 但绿色Container并不会填充整个扩展的空间。
Row(
children: [
Flexible(
flex: 2,
// fit: FlexFit.tight,
child: Container(
child: FlutterLogo(),
color: Colors.green,
),
),
Expanded(
flex: 2,
child: Container(
child: FlutterLogo(),
color: Colors.blue,
),
),
],
),
```
将 `Flexible` 的 `fit` 属性设置为 `tingt`,就等价于使用 `Expanded`
### Spacer
Spacer 用于在布局中留白
```dart
Row(
children: [
Text('Item'),
Spacer(),
FlutterLogo(),
],
),
```
例如,需要文本和图标位于一个行的两端,而中间留白时。就可以使用 `Spacer`
另见
---

View File

@ -924,8 +924,273 @@ steps:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```
当 `npm` 推送包失败不影响整个流程,可用于自动发包
GitLab CI/CD 迁移到 GitHub Actions
---
### 语法示例
<yel>GitLab CI/CD</yel>
```yml
job1:
variables:
GIT_CHECKOUT: "true"
script:
- echo "Run your script here"
```
GitHub Actions
```yml
jobs:
job1:
steps:
- uses: actions/checkout@v3
- run: echo "Run your script here"
```
### 运行程序
<!--rehype:wrap-class=row-span-2-->
<yel>GitLab CI/CD</yel>
```yml
windows_job:
tags:
- windows
script:
- echo Hello, %USERNAME%!
linux_job: tags:
- linux script:
- echo "Hello, $USER!"
```
GitHub Actions
```yml
windows_job:
runs-on: windows-latest
steps:
- run: echo Hello, %USERNAME%!
linux_job:
runs-on: ubuntu-latest
steps:
- run: echo "Hello, $USER!"
```
在不同的平台上运行作业
### Docker 映像
<yel>GitLab CI/CD</yel>
```yml
my_job:
image: node:10.16-jessie
```
GitHub Actions
```yml
jobs:
my_job:
container: node:10.16-jessie
```
### 条件和表达式语法
<yel>GitLab CI/CD</yel>
```yml
deploy_prod:
stage: deploy
script:
- echo "部署到生产服务器"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
```
GitHub Actions
```yml
jobs:
deploy_prod:
if: contains( github.ref, 'master')
runs-on: ubuntu-latest
steps:
- run: echo "部署到生产服务器"
```
### Artifacts
<yel>GitLab CI/CD</yel>
```yml
script:
artifacts:
paths:
- math-homework.txt
```
GitHub Actions
```yml
- name: Upload math result for job 1
uses: actions/upload-artifact@v3
with:
name: homework
path: math-homework.txt
```
### 作业之间的依赖关系
<yel>GitLab CI/CD</yel>
```yml
stages:
- build
- test
- deploy
build_a: stage: build script:
- echo "该作业将首先运行"
build_b: stage: build script:
- echo "该作业将首先运行,与 build_a 并行"
test_ab: stage: test script:
- echo "此作业将在 build_a 和 build_b 完成后运行"
deploy_ab: stage: deploy script:
- echo "此作业将在 test_ab 完成后运行"
```
GitHub Actions
```yml
jobs:
build_a:
runs-on: ubuntu-latest
steps:
- run: echo "该作业将首先运行"
build_b:
runs-on: ubuntu-latest
steps:
- run: echo "该作业将首先运行,与 build_a 并行"
test_ab:
runs-on: ubuntu-latest
needs: [build_a,build_b]
steps:
- run: echo "此作业将在 build_a 和 build_b 完成后运行"
deploy_ab:
runs-on: ubuntu-latest
needs: [test_ab]
steps:
- run: echo "此作业将在 test_ab 完成后运行"
```
### 缓存
<yel>GitLab CI/CD</yel>
```yml
image: node:latest
cache: key: $CI_COMMIT_REF_SLUG paths:
- .npm/
before_script:
- npm ci --cache .npm --prefer-offline
test_async: script:
- node ./specs/start.js ./specs/async.spec.js
```
GitHub Actions
```yml
jobs:
test_async:
runs-on: ubuntu-latest
steps:
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: v1-npm-deps-${{ hashFiles('**/package-lock.json') }}
restore-keys: v1-npm-deps-
```
### 数据库和服务容器
<yel>GitLab CI/CD</yel>
```yml
container-job:
variables:
POSTGRES_PASSWORD: postgres
# PostgreSQL 服务容器通信的主机名
POSTGRES_HOST: postgres
# 默认的 PostgreSQL 端口
POSTGRES_PORT: 5432
image: node:10.18-jessie
services:
- postgres
script:
# 执行 package.json 文件中
# 所有依赖项的全新安装
- npm ci
# 运行创建 PostgreSQL 客户端的脚本,
# 用数据填充客户端,并检索数据
- node client.js
tags:
- docker
```
GitHub Actions
```yml
jobs:
container-job:
runs-on: ubuntu-latest
container: node:10.18-jessie
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
steps:
- name: Check out repository code
uses: actions/checkout@v3
# 执行 package.json 文件中
# 所有依赖项的全新安装
- name: Install dependencies
run: npm ci
- name: Connect to PostgreSQL
# 运行创建 PostgreSQL 客户端的脚本,
# 用数据填充客户端,并检索数据
run: node client.js
env:
# PostgreSQL 服务容器通信的主机名
POSTGRES_HOST: postgres
# 默认的 PostgreSQL 端口
POSTGRES_PORT: 5432
```
另见
---
- [Github Actions 学习笔记](https://jaywcjlove.github.io/github-actions) _(jaywcjlove.github.io)_
- [了解 GitHub Actions](https://docs.github.com/cn/actions/learn-github-actions) _(docs.github.com)_
- [从 GitLab CI/CD 迁移到 GitHub Actions](https://docs.github.com/cn/actions/migrating-to-github-actions/migrating-from-gitlab-cicd-to-github-actions) _(docs.github.com)_

1585
docs/nextjs.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -110,6 +110,84 @@ class=tag&data-info=👆看看还缺点儿什么?
添加 `class=tag&data-lang=Python` 类名和参数,会在卡片右上角标记 _`Python`_
### Command Help
```bash
Usage: refs-cli [output-dir] [--help|h]
显示帮助信息
Options:
--version, -v 显示版本号
--help, -h 显示帮助信息
--watch, -w 观看并编译 Markdown 文件
--output, -o 输出目录。默认(分布)
--force, -f 强制文件重新生成
Example:
$ npx refs-cli
$ refs-cli --watch
$ refs-cli --output website
$ refs-cli
refs-cli@v0.0.1
```
### Config
```json
{
"title": "文档网站名称",
"description": "{{description}} 网站说明",
"keywords": "关键字,refs-cli,refs,cli",
"data-info": "👆需要你的参与",
"search": {
"label": "搜索",
"placeholder": "搜索备忘清单",
"cancel": "取消"
},
"editor": {
"label": "编辑"
},
"github": {
"url": "https://<github url>"
},
"home": {
"label": "首页",
"url": "https://<你的网站>"
},
"footer": "<br />备案号支持HTML字符串",
"license": "支持 HTML 字符串"
}
```
`.refsrc.json` 存放在项目的根目录下
### 环境变量
导航菜单
```ini
REF_URL=http://ref.ecdata.cn/
REF_LABEL=网站首页
```
页脚添加 (支持 HTML 字符串)
```ini
REF_FOOTER=备案号沪ICP备20220000000号-1
```
修改版权信息 (支持 HTML 字符串)
```ini
LICENSE=Copyright (c) <b>2022</b> 小弟调调™
```
在项目根目录中创建 <pur>**.env**</pur> 文件
Markdown 语法注释
---

1638
docs/react-native.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -354,6 +354,14 @@ rand.capacity() // => 13
以字节为单位计算字符串的容量
### with_capacity()
```rust
let s = String::with_capacity(10);
```
指定一个足够大的容量值,来减少内存拷贝
### .contains()
```rust
@ -484,6 +492,147 @@ let arr = vec![
`drain(range)` | 删除 `vec` 中指定范围的元素,同时返回一个迭代该范围所有元素的迭代器
`split_off(index)` | 切分 `vec`,索引左边的元素保留在原 `vec` 中(含索引),索引右边的元素(不含索引)在返回的 `vec` 中
Rust HashMap\<K,V>
--------
### 使用
```rust
use std::collections::HashMap;
fn main() {
let mut map: HashMap<String, i32> = HashMap::new();
map.insert(String::from("blue"), 100);
// 查询Yellow对应的值若不存在则插入默认值
let v: &mut i32 =
map.entry("Yellow".to_string()).or_insert(5);
let v: &mut i32 =
map.entry("Yellow".to_string()).or_insert(50); // 不会修改值
}
```
### 获取元素
```rust
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
let team_name = String::from("Blue");
let score: Option<&i32> = scores.get(&team_name);
```
### 遍历
```rust
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
for (key, value) in &scores {
println!("{}: {}", key, value);
}
```
### vec -> HashMap
```rust
let teams_list = vec![
("中国队".to_string(), 100),
("美国队".to_string(), 10),
("日本队".to_string(), 50),
];
let teams_map: HashMap<_,_> =
teams_list.into_iter().collect();
```
----
```rust
let teams = vec![String::from("blue"),String::from("red")];
let intial_scores = vec![10,50];
let scores:HashMap<_,_> =
teams.iter().zip(intial_scores.iter()).collect();
```
Option & Result
--------
### Option
```rust
enum Option<T> {
Some(T),
None,
}
```
#### 使用
```rust
fn main(){
let a = Some(5);
// 直接获取原始值
println!("{}", a.unwrap());
// 给出错误信息
let x: Option<&str> = None;
x.expect("fruits are healthy"); // panics 带有 `fruits are healthy`
}
```
### Result
```rust
enum Result<T, E> {
Ok(T),
Err(E),
}
```
#### 使用
```rust
use std::fs::File;
fn main() {
let f: Result<File,Error> = File::open("hello.txt");
let f = match f {
Ok(file) => file,
Err(error) => {
panic!("Problem opening the file: {:?}", error)
},
};
}
```
### 宏 `?`
`?` 只能用于返回结果是 Result 或者 Option 的函数,或者实现了 Try 类型
```rust
use std::fs::File;
use std::io::{self, Read};
fn read_username_from_file() -> Result<String, io::Error> {
let mut s = String::new();
File::open("hello.txt")?.read_to_string(&mut s)?;
Ok(s)
}
```
----
```rust
fn first(arr: &[i32]) -> Option<&i32> {
let v = arr.get(0)?;
Some(v)
}
```
<!--rehype:className=wrap-text -->
枚举
--------
@ -853,12 +1002,25 @@ let (x, _, y) = (1, 2, 3);
println!("{x},{y}");
```
----
```rust
fn get_count_item(s: &str) -> (&str, &str) {
let mut it = s.split(' ');
let (Some(str1),Some(str2)) = (it.next(),it.next()) else {
panic!("Can't segment count item pair");
};
(str1, str2)
}
```
### 函数中的模式匹配
```rust
fn add((x, y): (i32, i32)) -> i32 {
x + y
}
fn main(){
let sum = add(1, 2);
println!("{sum}");

View File

@ -1325,6 +1325,84 @@ const point = [3, 4] as const
// type 'readonly [3, 4]'
```
### satisfies
`satisfies` 允许将验证表达式的类型与某种类型匹配,而无需更改该表达式的结果类型。
```ts
type Colors = 'red' | 'green' | 'blue';
type RGB = [red: number, green: number, blue: number];
const palette: Record<Colors, string | RGB> = {
red: [255, 0, 0],
green: '#00ff00',
blue: [0, 0, 255],
};
// 通常的方式会推导出 redComponent 为 string | number | undefined
const redComponent = palette.red.at(0);
```
#### 使用 satisfies
```ts
const palette = {
red: [255, 0, 0],
green: '#00ff00',
blue: [0, 0, 255],
} satisfies Record<Colors, string | RGB>
// undefined | number
const redComponent = palette.red.at(0)
```
<!--rehype:className=wrap-text-->
### 范型实例化表达式
不使用的情况下:
```ts
const errorMap: Map<string, Error> = new Map()
// 或者使用 type 定义别名
type ErrorMapType = Map<string, Error>
```
使用泛型实例化表达式:
```ts
const ErrorMap = Map<string, Error>
const errorMap = new ErrorMap()
```
#### 泛型实例化函数
```ts
function makeBox<T>(value: T) {
return { value };
}
```
---
不使用:
```ts
function makeHammerBox(hammer: Hammer) {
return makeBox(hammer);
}
// or...
const makeWrenchBox: (wrench: Wrench) => Box<Wrench> = makeBox;
```
使用:
```ts
const makeStringBox = makeBox<string>;
makeStringBox(42);
```
CLI
---

View File

@ -90,7 +90,7 @@ Webstorm Windows & Linux 键盘映射
`Alt` `Up` | 转到上一个方法
`Alt` `Down` | 转到下一个方法
`Ctrl` `]` _/_ `[` | 移动到代码块结束/开始
`Cltrl` `Shift` `M` | 将插入符号移动到匹配的大括号
`Ctrl` `Shift` `M` | 将插入符号移动到匹配的大括号
`Ctrl` `F12` | 文件结构弹出
`Ctrl` `H` | 类型层次结构
`Ctrl` `Alt` `H` | 调用层次结构

View File

@ -1,6 +1,6 @@
{
"name": "@wcj/reference",
"version": "1.27.0",
"version": "1.29.0",
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
"author": "jaywcjlove",
"license": "MIT",
@ -25,7 +25,7 @@
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"refs-cli": "^0.0.11"
"refs-cli": "^1.2.1"
},
"engines": {
"node": ">=16.0.0"