Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wenerme committed Oct 16, 2024
1 parent 11827b3 commit 136452c
Show file tree
Hide file tree
Showing 65 changed files with 1,116 additions and 221 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SHELL:=env bash -O extglob -O globstar
#SHELL:=env bash -O extglob -O globstar
SHELL:=env bash -O extglob

status:
git add -u && git diff --color=always --staged --stat | tee
Expand Down
2 changes: 1 addition & 1 deletion notes/ai/ai-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ tags:

## Coding

:::tips
:::tip

- 功能方向
- Chat - 基于代码询问、解释、找 Bug
Expand Down
11 changes: 10 additions & 1 deletion notes/ai/llm/llm-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,26 @@ tags:
- https://github.com/arc53/llm-price-compass
- https://llmprices.dev/
- https://aichatmakers.com/2024/04/15/llms-pricing-comparison-with-chat-arena-leaderboard-ranking-april-2024/
- Application
- Runner/Inference
- [jmorganca/ollama](./ollama.md)
- MIT, Golang
- 快速启动任意模型
- 提供模型管理
- 提供管理接口
- Application/WebUI/UI/Desktop/Consumer
- [mudler/LocalAI](https://github.com/mudler/LocalAI)
- MIT, C++, Go
- [abi/secret-llama](https://github.com/abi/secret-llama)
- Apache-2.0, TS
- Fully private LLM chatbot that runs entirely with a browser with no server needed. Supports Mistral and LLama 3.
- [Yonom/assistant-ui](https://github.com/Yonom/assistant-ui)
- React Components for AI Chat
- [lobehub/lobe-chat](https://github.com/lobehub/lobe-chat)
- Apache-2.0, TypeScript
- [n4ze3m/page-assist](https://github.com/n4ze3m/page-assist)
- MIT, TS
- 浏览器插件
- https://chrome.google.com/webstore/detail/page-assist/jfgfiigpkhlkbnfnbobbkinehhfdhndo
- [open-webui/open-webui](https://github.com/open-webui/open-webui)
- MIT, Sevlet, Python
- WebUI for LLMs
Expand Down
5 changes: 2 additions & 3 deletions notes/ai/llm/ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ title: ollama

:::caution

- Support tools in OpenAI-compatible API [#4386](https://github.com/ollama/ollama/issues/4386)
- ~~Support tools in OpenAI-compatible API [#4386](https://github.com/ollama/ollama/issues/4386)~~

:::

```bash
# macOS 命令行
brew install ollama
brew install ollama # macOS brew

OLLAMA_FLASH_ATTENTION=1 ollama serve # 启动服务端
ollama run mistral # 运行模型
Expand Down
2 changes: 2 additions & 0 deletions notes/ai/ml/ml-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ tags:

## UI/Desktop/GUI/WebUI {#ui}

- [Yonom/assistant-ui](https://github.com/Yonom/assistant-ui)
- React Components for AI Chat
- [lobehub/lobe-chat](https://github.com/lobehub/lobe-chat)
- Apache-2.0, TypeScript
- [JetBrains/KotlinDL](https://github.com/JetBrains/KotlinDL)
Expand Down
2 changes: 1 addition & 1 deletion notes/culture/alcohol/alcohol-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ tags:
| Yellow Bird | 28% | ⭐️⭐️⭐️⭐️ | 黄鸟 |
| Zombie | 35% | ⭐️⭐️⭐️⭐️ | 僵尸 |

:::tips
:::tip

- 新手推荐: 莫吉托、玛格丽特、大都会

Expand Down
12 changes: 0 additions & 12 deletions notes/db/db-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,6 @@ curl --request POST \
- 注释分割 `-- migrate:up`
- [pressly/goose](https://github.com/pressly/goose)
- MIT, SQL/Go
- NodeJS
- [sequelize/umzug](https://github.com/sequelize/umzug)
- MIT, SQL/DSL
- sequelize
- mikro-orm https://mikro-orm.io/docs/migrations
- [salsita/node-pg-migrate](https://github.com/salsita/node-pg-migrate)
- MIT, DSL
- [graphile/migrate](https://github.com/graphile/migrate)
- MIT, SQL
- 支持 current 概念
- [tj/node-migrate](https://github.com/tj/node-migrate)
- MIT, Code
- 平台/服务/工具
- [bytebase/bytebase](https://github.com/bytebase/bytebase)
- MIT, Go, Vue
Expand Down
3 changes: 2 additions & 1 deletion notes/db/kv/kvrocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ tags:

:::caution

- Redis 4.0.0 兼容,部分 client 不支持
- 不推荐使用,除非只是需要一个分布式 kv 内存存储而不是 Redis
- Redis 4.0.0 兼容,部分 client 不支持
- 例如 bullmq 要求 5.0+

:::
Expand Down
77 changes: 76 additions & 1 deletion notes/db/relational/postgresql/postgresql-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tags:
- https://stackoverflow.com/a/50441059/1870054
- https://commitfest.postgresql.org/17/1252/
- S094
- 不支持 column reordering
- 不支持 column reordering

:::

Expand Down Expand Up @@ -894,3 +894,78 @@ WHERE usesuper = true;

- ⚠️注意 [supabase](./postgres-supabase.md) 的 pg superuser 是 supabase_admin
- supabase_admin 密码和 postgres 相同,登录后 `ALTER USER postgres WITH SUPERUSER`

## Windows minimal

- 下载 zip
- https://www.enterprisedb.com/download-postgresql-binaries
- 解压
- 得到 pgsql 目录
- 17.0
- zip 250MB
- 解压后 997MB
- pgAdmin 650MB
- bin 175MB
- lib 95MB
- doc 31MB
- share 24MB
- 移除后
- 112MB

```bash
rm -rf pgAdmin doc include StackBuilder
rm lib/*.pdb bin/*.pdb

cd bin
rm clusterdb.exe createdb.exe createuser.exe dropdb.exe dropuser.exe ecpg.exe oid2name.exe pg_amcheck.exe pg_archivecleanup.exe pg_basebackup.exe pg_checksums.exe pg_combinebackup.exe pg_config.exe pg_controldata.exe pg_createsubscriber.exe pg_isready.exe pg_receivewal.exe pg_recvlogical.exe pg_resetwal.exe pg_rewind.exe pg_test_fsync.exe pg_test_timing.exe pg_upgrade.exe pg_verifybackup.exe pg_waldump.exe pg_walsummary.exe pgbench.exe reindexdb.exe stackbuilder.exe vacuumdb.exe vacuumlo.exe
cd -

rm -rf share/locale
rm -rf share/doc

ls bin/*.exe | sort
# bin/initdb.exe
# bin/pg_ctl.exe
# bin/pg_dump.exe
# bin/pg_dumpall.exe
# bin/pg_restore.exe
# bin/postgres.exe
# bin/psql.exe
```

**package**

```bash
cd ..
# gnu tar + zstd ~ 27MB
tar -I 'zstd -20' --exclude='.DS_Store' -cvf pgsql.tar.zst pgsql
# just zip ~ 38MB
zip -r -9 pgsql.zip pgsql -x "*.DS_Store"
```

**init**

```batch
set PATH=%PATH%;%CD%\pgsql\bin
initdb.exe -D .\data -U postgres --encoding=UTF-8 --lc-collate=C --lc-ctype=C
pg_ctl -D ./data start -l db.log
```

```bash title="Shell"
export PATH=$PWD/pgsql/bin:$PATH
TZ=Asia/Shanghai initdb -D ./data -U postgres --encoding=UTF-8 --lc-collate=C --lc-ctype=C
pg_ctl -D ./data start -l db.log


export PGDATA=$PWD/data
pg_ctl status
psql -U postgres
pg_ctl stop
```

```bash
echo 'listen_addresses = "*"' >> data/postgresql.conf
echo 'host all all 0.0.0.0/0 md5' >> data/pg_hba.conf

pg_ctl reload
```
53 changes: 44 additions & 9 deletions notes/db/relational/postgresql/postgresql-sql-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,41 @@ tags:
> - column 的 generated 不能修改
> - column 只支持 STORE 的生成列,不支持虚拟列
```sql
-- Diagnostic
select version();
show server_version;
show server_version_num;
show server_encoding;
select current_user, current_schema, current_catalog, current_database();

SHOW server_encoding;
SHOW client_encoding;

SHOW timezone;
SELECT now();
SELECT current_timestamp;

SELECT inet_server_addr() AS server_ip, inet_client_addr() AS client_ip;
SELECT inet_server_port() AS server_port, inet_client_port() AS client_port;

SELECT pg_size_pretty(pg_database_size(current_database())) AS database_size;

SHOW data_directory;
SHOW max_connections;
SHOW shared_buffers;
SHOW default_transaction_isolation;
SHOW ALL;
```

```sql
SELECT * FROM pg_stat_activity;
SELECT * FROM pg_locks;
select * from pg_user; -- 查看所有 user
SELECT usename, usesuper AS superuser, usecreatedb AS createdb, valuntil AS expiration
FROM pg_user;
```

- [JSON Functions and Operators](https://www.postgresql.org/docs/current/functions-json.html)
- `PRIMARY KEY` ~= `UNIQUE` + `NOT NULL`
- FK
Expand All @@ -35,6 +70,15 @@ where type in ('text')
-- 也可以用 replace 如果用不到 regex 的功能 `\u2005` 依赖 regex 的功能
and (LENGTH(text) - LENGTH(regexp_replace(text, '\u2005', ''))) > 0
;

-- 基本的应用初始化
create user app with password 'app'; -- 创建用户
create database app with owner app; -- 创建数据库
\c app; -- 连接数据库
set session authorization app; -- 切换用户
select current_user; -- 查看当前用户
create schema main; -- 创建 schema, 避免使用 public
alter user app set search_path to main,public; -- 设置用户默认 schema
```

## XML xpath 返回结果包含 CDATA
Expand All @@ -49,15 +93,6 @@ select unnest(xpath('/s/text()','<s><![CDATA[text]]></s>'));
select unnest(xpath('string(/s)','<s><![CDATA[text]]></s>'::xml));
```

## 系统信息

```sql
select version();
show server_version;
show server_version_num;
show server_encoding;
```

## 静态数据行

```sql
Expand Down
16 changes: 16 additions & 0 deletions notes/db/relational/sqlite/libsql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: libsql
---

# libsql

- [tursodatabase/libsql](https://github.com/tursodatabase/libsql)
- MIT, C
- fork of SQLite
- 社区运营,接受贡献
- [特性](https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/doc/libsql_extensions.md)
- `ALTER TABLE ... ALTER COLUMN ...`
- WASM UDF
- RANDOM ROWID
- Virtual WAL - 可以 hook WAL 实现
- libsql_close_hook
9 changes: 7 additions & 2 deletions notes/dev/build/make.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ title: make
- `$(wildcard src/**/*.ts)` 在有些平台上是 `$(wildcard src/*/*.ts)`
- 不能遍历所有文件
- 推荐 shell 展开或 find 命令
- macOS 自带 make 是 v3.1

:::

Expand All @@ -28,9 +29,12 @@ SHELL=/bin/bash
.SECONDEXPANSION:

# 总是执行
.PHONEY: always
.PHONY: always
always:

# 所有 target 都不依赖 fs
.PHONY: $(MAKECMDGOALS)

# export 所有变量
.EXPORT_ALL_VARIABLES:

Expand Down Expand Up @@ -77,7 +81,8 @@ foreach:
# 目录切换
foo : bar/lose
cd $(<D) && gobble $(<F) > ../$@
# 使用 ONESHELL 则简单一些

# 使用 ONESHELL 则简单一些 make v3.2+, macOS 自带的 make 是 3.1
.ONESHELL:
foo : bar/lose
cd $(@D)
Expand Down
7 changes: 7 additions & 0 deletions notes/dev/compression/zstd.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ title: zstd
- --ultra - levels >= 20
- 需要更多内存
- https://github.com/facebook/zstd/blob/dev/lib/compress/clevels.h
- .zst

```bash
tar -I zstd --exclude='.DS_Store' -cvf pgsql.tar.zst pgsql
# 压缩级别
tar -I 'zstd -10' --exclude='.DS_Store' -cvf pgsql.tar.zst pgsql
```
3 changes: 2 additions & 1 deletion notes/dev/dev-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ scc --by-file ./src # 找到大文件
- [gopasspw/gopass](https://github.com/gopasspw/gopass)
- password manager for teams

## 有趣
## 有趣 {#fun}

- [ASCII progress indicators](https://glama.ai/blog/2024-09-25-ascii-progress-indicators)
- [denigma](https://denigma.app/)
- [Leetcode has taught me that I'm a bad engineer](https://news.ycombinator.com/item?id=29804607)
- https://github.com/afatcoder/LeetcodeTop
Expand Down
23 changes: 23 additions & 0 deletions notes/dev/dev-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ tags:

# Dev FAQ

- Optimize
- PGO - Profile Guided Optimization
- GCC, Clang, MSVC, Golang
- LTO - Link Time Optimization
- 使得 Link 能全局优化而非局限于单个模块
- AutoFDO - Auto Feedback Directed Optimization
- by Google
- 通过运行时采集数据,优化编译
- ThinLTO - Thin Link Time Optimization
- 一种 LTO 的变种,用更少的内存和时间
- BOLT - Binary Optimization and Layout Tool
- by Facebook/Meta
- GCC, LLVM
- 一种 PLO 技术
- 重新布局代码块,减少分支预测错误,提高 CPU 缓存命中率
- PLO - Post Link Optimization
- XRay - XRay Instrumentation
- LLVM 的性能分析工具
- Intel VTune Profiler
- Binary Instrumentation
- Pin
- DynamoRIO
- Valgrind
- https://www.joelonsoftware.com/
- https://www.martinfowler.com/
- https://web.stanford.edu/~ouster/cgi-bin/decisions.php
Expand Down
8 changes: 6 additions & 2 deletions notes/dev/dict.md
Original file line number Diff line number Diff line change
Expand Up @@ -1166,17 +1166,21 @@ tags:

## sex vs gender

- sex - 性别
- sex - 性别 - 生理性别/生物性别
- male, female
- intersex - 难以划分, 间性
- 生物特征,出生便决定了
- gender - 性别认同
- gender - 社会性别/性别认同
- 个性 - 可变
- 内在自我
- 非二元性别

---

- 性别表达(Gender Expression):指个人通过行为、服饰、发型等外在方式表达其性别认同。
- 跨性别者(Transgender):指性别认同与其生理性别不一致的人。
- 性别多样性(Gender Diversity):强调社会对不同性别身份和表达的包容与认可。
- 性取向(Sexual Orientation):与性别概念不同,指个人在情感或性方面被何种性别的人所吸引。
- 参考
- https://www.ons.gov.uk/economy/environmentalaccounts/articles/whatisthedifferencebetweensexandgender/2019-02-21

Expand Down
Loading

0 comments on commit 136452c

Please sign in to comment.