Fython’s Blog

Welcome to my personal blog website 🎉
  • Recording Life Sharing Technology
  • Stay Hungry Stay Foolish 🌟

Arch Sway 安装 Fcitx5

主力机 wm 我之前一直使用的是 i3 最近切换到了 Wayland 桌面环境,使用的是 Manjaro Sway 的发行版,在 Wayland 的生态中 Sway 是之前 X11 上 i3 窗口管理器的直接替代选择 发展了好几年,现在 Wayland 下开发环境逐渐成熟,在输入法这方面 Fcitx5 也已支持,下面是 Sway 安装 Fcitx5 的一些经验,应该所有 Wayland 环境都可参考 安装社区版 sway-im sway 已经合并了实现 text-input-v3 协议的分支,但是仍然没有完全实现 input-method-v2 协议,因此仍然无法显示弹出窗口。有个支持 v2 的 AUR 包 sway-im 修复了这个问题,使用 sway-im 替换自带的 sway yay -S sway-im 相关包安装 安装 Fcitx5 相关的包,我使用的是双拼所以还安装了双拼相关的插件 pacman -S fcitx5 fcitx5-chinese-addons fcitx5-qt fcitx5-gtk fcitx5-config-qt qt5-wayland 配置 Fcitx5 参考文档编辑 /etc/environment 并添加以下几行 GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx SDL_IM_MODULE=fcitx GLFW_IM_MODULE=ibus SDL_IM_MODULE 是为了让一些使用特定版本 SDL2 库的游戏能正常使用输入法。 GLFW_IM_MODULE 是为了让 kitty 启用输入法支持。此环境变量的值只能为 ibus。 按 Fcitx5 上游推荐,环境变量的值一般设置为 fcitx。部分并非由 Arch 从源码编译打包的应用程序因兼容性的需求而需要将之临时设置为 fcitx5...

February 20, 2024 · 1 min · 189 words · Fython

cURL 命令 查看请求响应时间

cURL 是我们常用的 http 命令行请求工具,它支持显示请求开始到响应结束各阶段的耗时,以便于开发中排查问题是网络原因还是服务器处理慢原因,主要是利用 -w 参数 curl -L -w "time_namelookup: %{time_namelookup} time_connect: %{time_connect} time_appconnect: %{time_appconnect} time_pretransfer: %{time_pretransfer} time_redirect: %{time_redirect} time_starttransfer: %{time_starttransfer} time_total: %{time_total} http_code: %{http_code} content_type: %{content_type} speed_download: %{speed_download} (byte/s) " https://example.com/ 如果使用单行方便拷贝 curl -L -w "time_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_redirect: %{time_redirect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\nhttp_code: %{http_code}\ncontent_type: %{content_type}\nspeed_download: %{speed_download} (byte/s)\n" https://example.com/ 返回如下 <!doctype html> <html> ..... </html> time_namelookup: 0.007911 time_connect: 0.008221 time_appconnect: 0.415794 time_pretransfer: 0.415880 time_redirect: 0.000000 time_starttransfer: 0.618522 time_total: 0.618948 http_code: 200 content_type: text/html; charset=UTF-8 speed_download: 2034 (byte/s) 返回的各参数如下,这是官方文档上的截图...

November 26, 2023 · 1 min · 135 words · Fython

PostgreSQL 全文搜索

PostgreSQL 全文搜索 在数据量较小的项目中可以使用 PostgreSQL 自带的全文搜索(Full Text Search)支持,代替非常重的 ElasticSearch,减少开发和维护成本,简单又好用,记录下最近的学习 实现全文搜索主要分为几步,分词、向量化、创建索引(倒排索引)、匹配查询 分词 默认自带的分词配置是不支持中文的,但可以安装第三方扩展来支持,检查支持的配置库在 psql 中使用 \dF 命令,\dFp 列出解析器 。 postgres=> \dF List of text search configurations Schema | Name | Description ------------+------------+--------------------------------------- pg_catalog | danish | configuration for danish language pg_catalog | dutch | configuration for dutch language pg_catalog | english | configuration for english language pg_catalog | portuguese | configuration for portuguese language pg_catalog | russian | configuration for russian language pg_catalog | simple | simple configuration pg_catalog | spanish | configuration for spanish language postgres-# \dFp List of text search parsers Schema | Name | Description ------------+---------+--------------------- pg_catalog | default | default word parser 安装支持中文的扩展 支持中文的扩展有以下这两个...

February 11, 2023 · 4 min · 692 words · Fython

Go 服务性能分析 pprof 的使用

Go 服务性能分析 pprof 的使用 go 是主打性能的语言 所以官方集成了方便性能检测的工具 go tool pprof 方便好用,主要可以收集如下指标 profile : 程序 cpu 使用情况,按照一定频率去采集应用程序在 CPU 和寄存器上面的数据 heap : 程序 heap 内存使用情况,和调用关系 goroutine : 程序内 goroutine 启动数,各自的调用情况。 block : 报告导致阻塞的同步原语的情况 goroutines 不在运行状态的情况,可以用来分析和查找死锁等性能瓶颈。默认情况下未启用,需要手动调用runtime.SetBlockProfileRate启用。 mutex: 报告锁竞争。默认情况下未启用,需要手动调用runtime.SetMutexProfileFraction启用。 集成到服务 服务应用 常驻的服务型应用要使用 pprof 首先得在服务启动入口导入包 import _ "net/http/pprof" ··· go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() 然后浏览器访问http://localhost:6060/debug/pprof/,显示如下页面 如上如果服务是 http 服务且使用的是 http.DefaultServeMux 不需要做任何路由注册默认会注册相关路由,初始化调用了init 函数会自动注册,路径为 /debug/pprof/,显示上图,能大概看个当前 goroutine 数目、堆分配情况、锁的情况,具体分析还是要使用下文的 go tool pprof 工具。 如果使用的是自定义的 ServeMux 或 Handler 需要我们自己手动注册需要的路由,比如使用 echo 框架的时候...

December 16, 2022 · 6 min · 1082 words · Fython

openwrt 自动重拨

有的 openwrt 固件不会断网自动重播,检查 /etc/ppp/options 文件是否存在如下参数,没有的话自己加上一般就好了 maxfail 0 persist 或者使用 crotab 重启接口,每天 3 点重新拨号 0 3 * * * ifdown wan && sleep 3 && ifup wan Reference: https://www.right.com.cn/FORUM/thread-4107089-1-1.html

August 6, 2022 · 1 min · 28 words · Fython