Skip to content

Commit 904be0c

Browse files
committed
update zfs, network
1 parent e8b9b8b commit 904be0c

File tree

33 files changed

+925
-56
lines changed

33 files changed

+925
-56
lines changed

notes/culture/game-awesome.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ tags:
55

66
# Game Awesome
77

8+
<!--
9+
Web
10+
https://www.game-game.com.ua/
11+
-->
12+
813
| abbr. | full | cn |
914
| --------- | ------------------------------- | ------------------------ |
1015
| RPG | Role-playing game | 角色扮演游戏 |
@@ -39,22 +44,22 @@ tags:
3944
4045
**To Be Play**
4146

42-
| Release | Name | zh-CN | Status |
43-
| ---------- | -------------------------------------------- | -------------------- | ------ |
44-
| 2023-05-11 | The Legend of Zelda: Tears of the Kingdom | 塞尔达传说:王国之泪 | |
45-
| 2022-10 | PERSONA 5 ROYAL | 女神异闻录 5 皇家版 | |
46-
| 2022-09 | Splatoon 3 | 斯普拉遁 3 | |
47-
| 2022-06 | Portal: Companion Collection | 传送门:同伴合集 | |
48-
| 2021-10 | Metroid Dread | 密特罗德 生存恐惧 | |
49-
| 2020-09 | Ori and the Will of the Wisps | 精灵与萤火意志 | |
50-
| 2020-09-17 | Hades | 哈迪斯 | |
51-
| 2019-09 | Ori and the Blind Forest: Definitive Edition | 精灵与森林 决定版 | |
52-
| 2018-07 | OCTOPATH TRAVELER | 歧路旅人 | |
47+
| Release | Name | zh-CN | Status |
48+
| ---------- | -------------------------------------------- | ------------------- | ------ |
49+
| 2022-10 | PERSONA 5 ROYAL | 女神异闻录 5 皇家版 | |
50+
| 2022-09 | Splatoon 3 | 斯普拉遁 3 | |
51+
| 2022-06 | Portal: Companion Collection | 传送门:同伴合集 | |
52+
| 2021-10 | Metroid Dread | 密特罗德 生存恐惧 | |
53+
| 2020-09 | Ori and the Will of the Wisps | 精灵与萤火意志 | |
54+
| 2020-09-17 | Hades | 哈迪斯 | |
55+
| 2019-09 | Ori and the Blind Forest: Definitive Edition | 精灵与森林 决定版 | |
56+
| 2018-07 | OCTOPATH TRAVELER | 歧路旅人 | |
5357

5458
**Have/Completed**
5559

5660
| Release | Name | zn-CN | Status |
5761
| ---------- | -------------------------------------------------- | --------------------------- | ---------- |
62+
| 2023-05-11 | The Legend of Zelda: Tears of the Kingdom | 塞尔达传说:王国之泪 | |
5863
| 2019-07-25 | Fire Emblem: Three Houses  | 火焰纹章:风花雪月 |
5964
| 2022-10 | Bayonetta 3 | 蓓优妮塔 3 | |
6065
| 2023-01-19 | Fire Emblem Engage | 火焰纹章 Engage | 通关,110h |

notes/db/design-schema.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ tags:
2727

2828
:::
2929

30-
## 主键
30+
## 主键生成
31+
32+
:::tip
33+
34+
- 建议 K-Sortable
35+
- 建议小写
36+
- 不要大小写混合
37+
- 可以考虑加类型 tag
38+
39+
:::
3140

3241
- [ULID](./ulid.md)
3342
- 有序 - 可以用于排序
@@ -40,13 +49,46 @@ tags:
4049
- 128bit - 编码后 36 字符
4150
- 随机
4251
- 数据库支持 UUID 类型的话能使用更少空间 -
52+
- UUIDv7
53+
- 兼容 UUID
54+
- 有序 - 时间戳
4355
- [NanoID](https://github.com/ai/nanoid)
44-
- 一般不直接用于 DB
56+
- 一般不直接用于 DB, 前端用的多
4557
- `A-Za-z0-9_-`
4658
- 26 bytes
4759
- [hashid](https://hashids.org/)
4860
- 数字+字符串生成
4961
- 可用于隐藏部分信息
62+
- 例如 微信
63+
- [segmentio/ksuid](https://github.com/segmentio/ksuid)
64+
- `0ujsswThIGTUYm2K8FjOOfXtY1K`
65+
- [beyonddream/snowid](https://github.com/beyonddream/snowid)
66+
- K-Sortable
67+
- 基本有序
68+
69+
## 主键类型
70+
71+
- `type-RANDOM`
72+
- OpenAI `sk-`,`org-`, `chat-`
73+
- `type_RANDOM`
74+
- GraphQL 的 NodeID 包含 Type 信息
75+
- Github [Using global node IDs](https://docs.github.com/en/graphql/guides/using-global-node-ids)
76+
- MDQ6VXNlcjU4MzIzMQ==
77+
- `04:User583231`
78+
- [Global Object Identification](https://graphql.org/learn/global-object-identification/)
79+
- [jetpack-io/typeid](https://github.com/jetpack-io/typeid)
80+
- Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
81+
- [HN](https://news.ycombinator.com/item?id=36508811)
82+
- Tagged Id https://joist-orm.io/docs/advanced/tagged-ids
83+
- `TAG:ID`
84+
- Reddit
85+
- `tN_ID`
86+
- 使用 `_` 可以双击选中复制
87+
88+
<!--
89+
a_1_b_0
90+
a-1-b-0
91+
-->
5092

5193
## 元数据
5294

notes/db/relational/postgresql/postgresql-faq.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,3 +829,12 @@ select 10::money;
829829
```
830830
POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --lc-collate=C --lc-ctype=C'
831831
```
832+
833+
## there is no unique constraint matching given keys for referenced table
834+
835+
外键必须 unique
836+
837+
## permission denied for table
838+
839+
- 外键需要 REFERENCES
840+
- https://www.postgresql.org/docs/current/ddl-priv.html
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: PostgreSQL JSON
3+
---
4+
5+
## PostgreSQL JSON
6+
7+
:::caution
8+
9+
- `data->'field' is not null` 无法检测 null 数据 - 通过 `->>` 可以检测到 null
10+
- 使用 json_typeof 监测 null - `json_typeof(col->'field') = 'null'`
11+
12+
:::
13+
14+
- https://bitnine.net/blog-postgresql/postgresql-internals-jsonb-type-and-its-indexes/
15+
16+
```sql
17+
-- 数组移除 null
18+
select jsonb_path_query_array('{"values": [null, "test", { "key": "value" }]}', '$.values[*] ? (@ != null)');
19+
20+
-- 移除 null 数据
21+
select json_strip_nulls('[{"f1":1, "f2":null}, 2, null, 3]');
22+
23+
-- 检测 key 存在 - jsonb
24+
SELECT '{"a":1}'::jsonb ? 'a';
25+
SELECT '{"a": {"b": 1}}'::jsonb -> 'a' ? 'b';
26+
```
27+
28+
## JSON 数组转行
29+
30+
```sql
31+
-- 转换为单行 JSON 对象
32+
select * from json_array_elements('[{"a":1},{"a":2}]');
33+
34+
-- 同时提取列
35+
select * from json_to_recordset('[{"a":1,"b":"first"},{"a":2,"b":"second"}]') as (a int, b text);
36+
```
37+
38+
## JSON 对象遍历
39+
40+
```sql
41+
-- (key,value)
42+
select * from json_each_text('{"a":1,"b":2}') as d;
43+
```

notes/dev/design/design-auth.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Auth
3+
---
4+
5+
# Auth
6+
7+
:::tip 场景
8+
9+
1. 资源访问
10+
11+
- 有 Owner 对象
12+
- 通常通过 Agent/Browser 方式
13+
- 客户端不受信
14+
- 交换获取 Token
15+
- Token 会失效
16+
17+
2. 服务访问 - 后端-后端
18+
19+
- 客户端受信
20+
- API Key
21+
- Service Account
22+
- Basic Auth
23+
24+
:::
25+
26+
- API Auth
27+
- Service Auth
28+
- Service Account - SA
29+
- API Key
30+
- HTTP Auth [HTTP Authentication Schemes](https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml)
31+
- Basic RFC7617
32+
- Bearer RFC6750
33+
- PAT - Persional Access Token
34+
- Bearer - Opaque 的内容
35+
- JWT 对 Token 内容做第一
36+
- 参考
37+
- [Swagger Aith](https://swagger.io/docs/specification/authentication/)
38+
39+
## API Key
40+
41+
- [Swagger API Key](https://swagger.io/docs/specification/authentication/api-keys/)
42+
- `?api_key=$KEY`
43+
- `X-API-Key: $KEY`
44+
- `Cookie: X-API-KEY=KEY`
45+
- [key-auth](https://apisix.apache.org/docs/apisix/plugins/key-auth/)
46+
- `X-API-KEY: `
47+
- `apikey: `
48+
- `?apikey=`
49+
50+
### OpenAI
51+
52+
```
53+
GET https://api.openai.com/v1/models
54+
Authorization: Bearer $OPENAI_API_KEY
55+
OpenAI-Organization: $ORG_ID
56+
```
57+
58+
- ORG_ID 有默认
59+
- `org-ID`
60+
- Secret Key
61+
- `sk-KEY`
62+
63+
## Service Account
64+
65+
- client_id + client_secret
66+
- grant=client_credential -> AccessToken
67+
- 可以获取用户相关的 AccessToken

notes/dev/testing/k6.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: k6
3+
---
4+
5+
# k6
6+
7+
- [grafana/k6](https://github.com/grafana/k6)
8+
- AGPL-3.0, Golang
9+
10+
```bash
11+
brew install k6
12+
# https://github.com/grafana/k6/releases
13+
curl -LO https://github.com/grafana/k6/releases/download/v0.45.0/k6-v0.45.0-linux-amd64.tar.gz
14+
tar zxvf k6-v0.45.0-linux-amd64.tar.gz --strip-components 1
15+
./k6
16+
17+
k6 run script.js
18+
```
19+
20+
```js
21+
import { check, sleep } from 'k6';
22+
import http from 'k6/http';
23+
24+
export const options = {
25+
// 单个
26+
vus: 10,
27+
duration: '30s',
28+
// or 多个场景
29+
// stages: [
30+
// { duration: '30s', target: 20 },
31+
// { duration: '1m30s', target: 10 },
32+
// { duration: '20s', target: 0 },
33+
// ],
34+
// 目标,SLO
35+
thresholds: {
36+
// Assert that 99% of requests finish within 3000ms.
37+
http_req_duration: ['p(99) < 3000'],
38+
},
39+
};
40+
41+
export default function () {
42+
const res = http.get('https://wener.me');
43+
check(res, { 'status was 200': (r) => r.status == 200 });
44+
sleep(1);
45+
}
46+
```
47+
48+
- virtual users (VUs)
49+
- `__ENV`
50+
51+
```js
52+
// 1. init code
53+
54+
export function setup() {
55+
// 2. setup code
56+
// Set up data for processing, share data among VUs
57+
// e.g. Call API to start test environment
58+
return {};
59+
}
60+
61+
// data 为 setup 返回结果
62+
export default function (data) {
63+
// 3. VU code
64+
}
65+
66+
// data 为 setup 返回结果
67+
export function teardown(data) {
68+
// 4. teardown code
69+
// Process result of setup code, stop test environment
70+
}
71+
72+
// 通过配置 scenarios.*.exec 来指定执行
73+
export function webtest() {}
74+
```
75+
76+
- handleSummary

notes/devops/kubernetes/distro/k0s/k0s-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ k0s stop
132132

133133
## 网络配置问题
134134

135-
因为你服务器有多 lan,配置了路由策略,从 10gbe 进来的从 10gbe 出去
135+
因为服务器有多 lan,配置了路由策略,从 10gbe 进来的从 10gbe 出去
136136

137137
```
138138
auto eth4

notes/devops/kubernetes/distro/k3s/k3s-faq.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ time="2023-06-04T16:17:14.398989382+08:00" level=info msg="containerd successful
411411
412412
是因为 `failed to find snapshotter "zfs"` 导致
413413
414+
```bash
415+
k3s ctr plugin ls
416+
```
417+
414418
## failed to get network \"cbr0\" cached result: decoding version from network config: unexpected end of JSON input"
415419
416420
```bash

notes/devops/kubernetes/distro/k3s/k3s-install.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ title: Install
66

77
## Install
88

9+
:::caution
10+
11+
- 如果 install 用了 https_proxy, 会被写入到 /etc/rancher/k3s/k3s.env
12+
13+
:::
14+
915
```bash
1016
# 下载到临时目录进行安装
1117
curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_START=true INSTALL_K3S_SKIP_ENABLE=true sh -
@@ -274,6 +280,7 @@ ARCH=amd64
274280
SUFFIX=
275281

276282
VERSION_K3S=$(curl -sf https://update.k3s.io/v1-release/channels | jq -r '.data[] | select(.id == "stable") | .latest')
283+
echo Upgrade $VERSION_K3S
277284
# GITHUB_URL=https://github.com/k3s-io/k3s/releases
278285
# 走代理
279286
GITHUB_URL=https://ghproxy.com/github.com/k3s-io/k3s/releases
@@ -288,6 +295,8 @@ sudo cp k3s.$VERSION_K3S $(which k3s)
288295
sudo k3s check-config
289296

290297
# 启动
291-
service k3s start
298+
service k3s restart
292299
rc-update add k3s
300+
301+
k3s kubectl get nodes
293302
```

notes/devops/web/haproxy/haproxy-tuning.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ echo "show info" | socat stdio /run/haproxy-runtime-api.sock
2020
```ini title="/etc/sysctl.d/30-haproxy.conf"
2121
net.ipv4.tcp_rmem = 4096 16060 262144
2222
net.ipv4.tcp_wmem = 4096 16384 262144
23+
net.ipv4.tcp_tw_reuse = 1
2324
net.ipv4.ip_local_port_range = 1024 65023
2425
net.ipv4.tcp_max_syn_backlog = 60000
2526
#net.ipv4.tcp_fin_timeout = 30

0 commit comments

Comments
 (0)