幸福飞过海 https://fengqi.me/ zh-CN 风起的网络记事本 Wed, 02 Jul 2025 18:59:00 +0000 Wed, 02 Jul 2025 18:59:00 +0000 关于Gitlab Merge Request功能一件让人唏嘘的往事 https://fengqi.me/default/729.html https://fengqi.me/default/729.html Wed, 02 Jul 2025 18:59:00 +0000 风起 🗣️糟糕的现状

一个功能在Gitlab社区前后讨论了8年多才加上你敢相信?这个功能就是Gitlab的Merge Request文件内容收起功能,你可能不会立即回想起我说的时什么,我用一张截图来说明下:

Gitlab Merge Request

打开一个Merge Request,切换到Changes,当文件过多且部分文件内容收起时,在右侧会出现一个Expand all files按钮,点击后会把所有的文件内容全部展开,然后按钮消失,且并不会出现一个可能叫Collapse all files的按钮,这个时候再想收起文件内容怎么办呢?

[...]

]]>
0 https://fengqi.me/default/729.html#comments https://fengqi.me/feed/
在子进程里执行shell命令 https://fengqi.me/unix/728.html https://fengqi.me/unix/728.html Thu, 29 May 2025 05:28:00 +0000 风起 shell 可以通过添加一个小括号的方式,让命令在子进程执行,和bash xxx.sh执行效果一样,运行过程中设置的环境变量、cd、执行exit等都不影响当前shell,如:

func1() {
    (
        cd /tmp
        touch testfile
        exit 0
    )
}

这里末尾执行exit并不会导致当前的shell退出,这对于行数很多需要提前退出的情况非常有用的。

]]>
0 https://fengqi.me/unix/728.html#comments https://fengqi.me/feed/
使用FFmpeg生成无声的铃声 https://fengqi.me/default/726.html https://fengqi.me/default/726.html Thu, 29 May 2025 05:25:00 +0000 风起 现在的手机通讯录都支持单独设置震动、铃声,所以这里提供一个生成无声的铃声的方法:

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 10 silence-ring.wav
  • -f lavfi:表示使用滤镜
  • anullsrc:代表无声音源
  • channel_layout=stereo:立体声
  • sample_rate=44100:标准采样率
  • -t 10:持续时间为 10 秒
  • 可以将 wav 改为 mp3 来输出 MP3 文件

无声的铃声有什么用能?可以使特定的来电不震动、不响铃,同时又不影响其他的联系人。

]]>
0 https://fengqi.me/default/726.html#comments https://fengqi.me/feed/
[记录]IDEA或者GoLand调试Go提示Delve is too old的解决方案 https://fengqi.me/go/719.html https://fengqi.me/go/719.html Sat, 06 Apr 2024 10:26:00 +0000 风起 完整的报错信息大概是这样WARNING: undefined behavior - version of Delve is too old for Go version 1.21.9 (maximum supported version 1.18)

报错的原因是因为delve版本低,不支持调试高版本的Go,解决方法如下:

1. 确定dlv.exe路径

可以使用Everthing类的工具,但通常的路径是这样的,你可以尝试直接定位:

C:\Users\fengqi\AppData\Roaming\JetBrains\IntelliJIdea2021.3\plugins\go\lib\dlv\windows\

如果是MacOS,通常的路径是这样的:

/Users/fengqi/Library/Application Support/JetBrains/IntelliJIdea2021.3/plugins/go/lib/dlv

2. 安装最新版本的dlv.exe

可以参考文档 https://github.com/go-delve/delve/tree/master/Documentation/installation,或者直接下载源码编译,如果你和我一样使用go install安装的,那么路径大概是在 C:\Users\fengqi\go\bin\dlv.exe

3. 备份并替换Jetbrains的dlv.exe

尝试重新开启调试。

]]>
0 https://fengqi.me/go/719.html#comments https://fengqi.me/feed/
Linux下开启CPU睿频,降低功耗 https://fengqi.me/unix/708.html https://fengqi.me/unix/708.html Sun, 30 Jul 2023 17:05:00 +0000 风起 Linux下默认CPU会使用高性能模式,AMD不清楚,但是Intel默认会启用固定频率也就是最高频率,对于家用NAS或者ALL-IN-BOOM来说其实有点浪费电,因为大多数情况下CPU并不是满载的,开启睿频可以省电。

1. 验证当前模式

cat /sys/devices/system/cpu/intel_pstate/no_turbo
1
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance

这里看到是关闭了睿频,且启用高性能模式。

2. 关闭定频固定频率

grub添加intel_pstate=disable参数

vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="splash intel_pstate=disable intel_iommu=on iommu=pt"
update-grub
reboot

[...]

]]>
0 https://fengqi.me/unix/708.html#comments https://fengqi.me/feed/
[记录] macOS下 VirtualBox-7.0 无界面模式(Headless)Dock有图标的解决办法 https://fengqi.me/default/706.html https://fengqi.me/default/706.html Fri, 21 Jul 2023 09:45:00 +0000 风起 升级了macOS Ventura 13.4以后,VirtuaoBox 6.1就不能使用了,必须升级7.0才可以。

升级后碰到的最大的问题就是无界面模式(Headless)启动后,Dock(程序坞)上会出现一个VirtualBox的图标,然后一直弹跳,各种乱点后来变成普通不弹跳的图标,但是忘记操作过程。

此时关闭VirtualBox界面后,Dock上会残留一个图标,不像之前那样完全后台运行,经过长达几分钟的摸索发现,只要在虚拟机设置-显示-屏幕-扩展特性取消勾选启用3D加速就可以了,具体原因未知,也不打算深究了。

]]>
0 https://fengqi.me/default/706.html#comments https://fengqi.me/feed/
nginx自动屏蔽不友好的ip https://fengqi.me/unix/644.html https://fengqi.me/unix/644.html Fri, 08 Apr 2022 11:19:00 +0000 风起 查看nginx日志的时候发现大量的404302尝试访问不存在的资源,大概率是使用工具扫描。

{"connection": "2572288","pid": "176228","request_id": "7d5dcaac3e4be47a536a4a0d1b5c7abb","request_length": "157","remote_addr": "52.170.115.255","time_local": "08/Apr/2022:17:44:50 +0800","status":"302","host":"fengqi.me","uri":"/Panels.txt","server":"fengqi.me","port":"443","protocol":"HTTP/1.1","request_uri":"/Panels.txt","args": "","scheme": "https","request_time": "0.000","request_method":"GET","http_referrer":"","body_bytes_sent":"138","http_x_forwarded_for":"","http_user_agent":"python-requests/2.27.1","upstream_response_time":""}
{"connection": "2572337","pid": "176261","request_id": "cf56fa6708c4b68d1b8e3b4d7871103c","request_length": "150","remote_addr": "52.170.115.255","time_local": "08/Apr/2022:17:45:09 +0800","status":"302","host":"fengqi.me","uri":"/Panels.txt","server":"fengqi.me","port":"443","protocol":"HTTP/1.1","request_uri":"/Panels.txt","args": "","scheme": "https","request_time": "0.000","request_method":"GET","http_referrer":"","body_bytes_sent":"146","http_x_forwarded_for":"","http_user_agent":"python-requests/2.27.1","upstream_response_time":""}
{"connection": "2186500","pid": "164519","request_id": "aa21defaa0a590422420732b52c58f83","request_length": "253","remote_addr": "13.93.105.179","time_local": "08/Apr/2022:16:18:21 +0800","status":"302","host":"fengqi.me","uri":"/new-index.php","server":"fengqi.me","port":"443","protocol":"HTTP/1.1","request_uri":"/new-index.php","args": "","scheme": "https","request_time": "0.000","request_method":"GET","http_referrer":"","body_bytes_sent":"138","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36","upstream_response_time":""}

正常用户不会这么访问,所以基本上一个ip重复来这么几次就是有问题的,写个脚本,定时扫描nginxaccess.log统计出频繁的ip,然后干掉。

[...]

]]>
0 https://fengqi.me/unix/644.html#comments https://fengqi.me/feed/
我通过自制的Kodi命令行刮削器申请到了JetBrains的开源许可证 https://fengqi.me/go/632.html https://fengqi.me/go/632.html Wed, 06 Apr 2022 07:56:00 +0000 风起 项目地址

Kodi 刮削器命令行版本,使用TMDB数据源

更早的起源

2021年的双十一我在京东购买了索尼的X91J 65英寸版本,同时幸运的使用了那个2000的特殊优惠券,感谢京东没有回收这个羊毛。

电视安装完成后,我开始着手构建自己的影音环境,在此之前,我是通过PT下载到NAS,然后电脑+2.0音箱播放,没有刮削,这之后我会转移到电视上来。

索尼电视使用的是和当贝合作的Android系统国内特供版,不过也允许用户随意的安装第三方应用,我进行了大量的尝试,最后只保留了Bilibili、Kodi、SmartTubeNext、Netflix、Aptoide这几个应用。

其中Kodi用来管理我从网络下载的电影和剧集,提供海报墙,观看进度跟踪,因为Kodi自带的刮削器不能满足我的需求,tinyMediaManager等半自动又太麻烦,所以我决定自制刮削器。

[...]

]]>
0 https://fengqi.me/go/632.html#comments https://fengqi.me/feed/
[记录]关于新增新字段sqlx报错missing destination name https://fengqi.me/go/629.html https://fengqi.me/go/629.html Tue, 22 Mar 2022 03:34:00 +0000 风起 正常情况下,将数据的字段映射到一个struct的时候,需要使用db这个tag指定关系,典型的使用场景如下:

type News struct {
    Id int64 `json:"id" db:"id"`
    GroupId int64 `json:"group_id" db:"group_id"`
}

news := &News{}
err := db.QueryRowx("select...", x).StructScan(news)

部分类库比如xorm会尝试根据驼峰、下划线去对应,sqlx并不会,而是会报panic级别的错误。

查看源码,发现StructScan内部调用了scanAny这个方法,继续往下看,可以发现这样一段代码:

fields := m.TraversalsByName(v.Type(), columns)
// if we are not unsafe and are missing fields, return an error
if f, err := missingFields(fields); err != nil && !r.unsafe {
    return fmt.Errorf("missing destination name %s in %T", columns[f], dest)
}

这里判断是否有字段缺失,同时有个unsafe开关,如果没有打开,就会报错,unsafe是在初始化db链接的时候指定的,可以通过调用db.Unsafe()方法返回一个打开unsafe开关的db实例,至于是全局使用还是每次调用时指定,看你自己了。

PS: 如果愿意动动手,也可以通过db.Mapper = xx覆盖默认的Mapper方法,其中包括字段名映射逻辑,比如把xorm的逻辑移植过来。

]]>
0 https://fengqi.me/go/629.html#comments https://fengqi.me/feed/
Proxmox VE关于Alpine虚机、MAC地址还有Hostname的小坑 https://fengqi.me/unix/627.html https://fengqi.me/unix/627.html Tue, 15 Feb 2022 08:16:00 +0000 风起 Proxmox VE简称PVE,有kvmlxc两种模式,说人话就是虚拟机和容器,比较轻量的应用我会优先使用lxc,磁盘和内存占用都非常低。

如果对glibc没有强制要求的,我会优先使用 Alpine Linux 这个发行版,除开应用本身的资源,只有2m左右的系统文件,几乎没有内存和磁盘浪费。

我的PVE和虚机优先跑在SSD上,会比跑在HDD上有更好的io,所有SSD空间需要省着用。

问题1:Alpine DHCP可能不发送主机名

我在使用Alpine的时候发现部分机器启动后,DHCP不会发送Hostname,导致OpenWrt看到的主机名是问号?爬了一下Alpine的文档后找到,可在/etc/network/interfaces 增加hostname参数来自定义发送主机名,问题解决,验证方式是查找系统进程udhcpc 看运行参数是否有 hostname:xxx字样,例如:

> ps|grep dhcp
> /sbin/udhcpc -b -R -p /var/run/udhcpc.eth0.pid -i eth0 -x hostname:ptn

原因未知,使用的镜像都是一致的,部分容器开起来就是会出问题。。。可能隐藏的比较深。

[...]

]]>
0 https://fengqi.me/unix/627.html#comments https://fengqi.me/feed/