列表2023-week49
#最近读的东西
#自己的一些项目该如何组织
#github 仓库拉取优化
背景是neovim
的插件都在 github 上,大陆拉不下来。
解决方案:全局配置 Git 使用 SSH
:
1 | vi ~/.gitconfig |
加入 👇
1 | [url "git@github.com:"] |
#https 证书
阿里云免费的证书有效期变成 3 个月了= =
免费方案 👆
#快速 csv 文件处理
为压测准备数据
- 从源数据中选取指定列作为待选数据:
1 | cut -d',' -f6 raw.csv > res.txt |
-d
指定分隔符-f
指定选的列,比如我只要第 6 列数据
- 拆分数据集合:
因为我的数据从 100 个表取出来的,然后需要分成多个数据集合,我选择的第一种方法是把奇数行和偶数行拆分成两个文件(假设数据集只需要 2 个)
1 | awk '{if (NR % 2 == 0) print > "res_1.txt"; else print > "res_2.txt"}' res.txt |
- 打散数据:
因为数据是按尾号聚合的数据,具有不均匀性,需要打乱。
1 | shuf res_2.txt > res_2_suf.txt |
感觉 chatgpt 出来之后,笔记已经显得不那么重要了= =
列表2023-week48
#最近读的东西
#1
- What is the difference between sort.Slice and sort.SliceStable
- https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
排序的稳定性,之前还真没关注过= =
#2
- The Log: What every software engineer should know about real-time data’s unifying abstraction
- https://github.com/oldratlee/translations/tree/master/log-what-every-software-engineer-should-know-about-real-time-datas-unifying
#3
验证了很久,一个 redis 的分布式读写锁,在脏缓存的情况下会发生问题,其它 ok
列表2023-week45
#最近读的东西
#1
1 | Usage: paste [OPTION]... [FILE]... |
paste1.txt
:
1 | 1 2 3 |
paste2.txt
:
1 | a b c |
1 | $ paste paste1.txt paste2.txt |
把 N 个文件按列合并
#2
有点难
列表2023-week44
#最近读的东西
#1
Mysql 官方文档
With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an existing row is set to its current values. If you specify the CLIENT_FOUND_ROWS flag to the mysql_real_connect() C API function when connecting to mysqld, the affected-rows value is 1 (not 0) if an existing row is set to its current values.
在用upsert
语句时,标准的返回值是 1 插入、2 更新、0 无影响。
In assignment value expressions in the ON DUPLICATE KEY UPDATE clause, you can use the VALUES(col_name) function to refer to column values from the INSERT portion of the INSERT … ON DUPLICATE KEY UPDATE statement. In other words, VALUES(col_name) in the ON DUPLICATE KEY UPDATE clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred.
VALUES()
在上述语句的后面的时候,语法从来没见过,是存在歧义的,是代指数据库里的值还是插入语句中的值。
1 | INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) |
An INSERT … ON DUPLICATE KEY UPDATE statement against a table having more than one unique or primary key is also marked as unsafe. (Bug #11765650, Bug #58637)
当一个表中有多个唯一索引时,同时使用upsert
的结果是不确定的,只会更新随机一个。
#2
在开发时经常会出现 int 与 string 相互转换的场景,所以从int64
转换成interface{}
的时候,到底发生了什么 👆
1 | package main |
1 | [2023/11/03 13:11:15] mbp ➜ ~/Downloads/workspace/ct go test -bench=. conv_test.go |
#3
为什么对 map 的访问,接了一个参数就不会 panic,还没找到资料
1 | package main |
1 | [2023/11/03 13:21:49] mbp ➜ ~/Downloads/workspace/ct go test -v -run . map_test.go |
Neovim配置相关
neovim笔记
golang图片处理
#前言
不得不感慨,前端的发展迅速以至于我觉得在前端样式下一小段 css 的事情,服务端实现起来无比复杂,甚至无法实现。
所以其实图片编辑的操作一直以来都是由前端或者客户端完成的。但,任何客户端的用户行为其实都是不可信的,对于一个图像裁剪,如果接入审核流又会过于繁重。服务端处理在一定程度上能够解决这个问题,如果这个场景其实不会特别频繁的话。