片段
短一点的记录:命令、配置、几行代码,和踩过的坑。
让 git log 只显示最近的提交树
git log --graph --oneline --decorate -20是我用了最久的别名。加一个--date-order可以避免跨分支的提交在时间线上交错,读起来更接近真实的合并顺序。git log --graph --oneline --decorate --date-order -20想只看当前分支、并带上相对时间:
git log --oneline --decorate --relative-date --stat=60 -10psql: 找出占空间最大的表和索引
排查存储问题时,这两个查询比
\dt+快得多。-- 表:数据 + 索引 + TOAST 的总占用 SELECT relname AS table, pg_size_pretty(pg_total_relation_size(oid)) AS total, pg_size_pretty(pg_relation_size(oid)) AS data, pg_size_pretty(pg_total_relation_size(oid) - pg_relation_size(oid)) AS overhead FROM pg_class WHERE relkind = 'r' AND relnamespace = 'public'::regnamespace ORDER BY pg_total_relation_size(oid) DESC LIMIT 15; -- 索引:顺便看有没有从未被扫过的 SELECT indexrelname, idx_scan, pg_size_pretty(pg_relation_size(indexrelid)) AS size FROM pg_stat_user_indexes ORDER BY pg_relation_size(indexrelid) DESC LIMIT 15;idx_scan = 0且不承担唯一约束的索引是删除候选,但先确认统计信息已经重置过(pg_stat_reset()之后所有计数都归零)。CSS: 让长单词不撑破容器
URL、hash、长英文单词撑破窄容器(尤其是移动端侧栏和代码块)时,三个属性能解决绝大多数情况:
.wrap-anywhere { overflow-wrap: anywhere; /* 允许在任意位置断行,且参与 min-content 计算 */ word-break: normal; /* 不要用 break-all,会把正常单词也切碎 */ hyphens: auto; /* 有 lang 属性时按语言断词 */ }overflow-wrap: anywhere和break-word的区别在于:anywhere会影响min-content尺寸,所以在 grid/flex 布局里它能真正把容器压窄,而break-word不行。代码块则应该横滚而不是断行:
pre { overflow-x: auto; white-space: pre; tab-size: 2; }curl 只看状态码和响应头耗时
排查「接口慢」时,把耗时拆开比看总时间有用。
curl -s -o /dev/null \ -w 'dns:%{time_namelookup} connect:%{time_connect} tls:%{time_appconnect} ttfb:%{time_starttransfer} total:%{time_total} code:%{http_code}\n' \ 'https://api.example.com/health'如果
ttfb远大于connect,问题在服务端处理;如果connect就很大,先看网络和 DNS。跟随重定向并显示每一跳:
curl -sIL https://yzqzy.dev/snippets/ | grep -E '^(HTTP|location)'重定向链超过一跳通常意味着配置有问题,比如 http→https 之后又跳了一次裸域。