GitHub 上导出 patch

在 Pull Request 的 URL 结尾加上 .patch 即可重定向到 PATCH

例如 https://github.com/hubenchang0515/SmartQQ/pull/3 添加 .patch 变为 https://github.com/hubenchang0515/SmartQQ/pull/3.patch 即可重定向到 https://patch-diff.githubusercontent.com/raw/hubenchang0515/SmartQQ/pull/3.patch

Golang JSON 序列化时动态忽略字段

在使用 JSON 时经常遇到需要忽略字段的情况,例如返回用户信息时不能返回密码,通常将注解 TAG 设为 json:"-" 即可:

1type User struct {
2	Account  string `json:"account"`
3	Password string `json:"-"`
4	Nickname string `json:"nickname"`
5}

Kafka 部分常用配置

Kafka 有两种使用方式:基于 zookeeper 和基于 kraft.

  • 基于 zookeeper

启动:

1./bin/zookeeper-server-start.sh ./config/zookeeper.properties
2./bin/kafka-server-start.sh ./config/server.properties

OpenGL 选择使用独立显卡

OpenGL 没有手动选择显卡的 API,在同时具备核心显卡和独立显卡的设备上常常会在核显上运行。

Windows 上可以添加如下代码选择使用独显:

1#ifdef __cplusplus
2extern "C" {
3#endif

MUI 集成 nextjs

安装依赖包

首先确认安装了 next 和 MUI:

1npm install next react react-dom @mui/material @emotion/react @emotion/styled

Windows 注册表中添加自己的程序

打开方式

Lolipop Media Player 为例。

本文全部使用 HKEY_CURRENT_USER,表示当前用户的配置。 可以替换为 HKEY_LOCAL_MACHINE,表示所有用户的配置。

nginx 常用命令与基础配置

常用命令

  1. 启动: nginx
  2. 使用指定配置文件启动: nginx -c /path/to/file
  3. 正常停止: nginx -s quit
  4. 快速停止: nginx -s stop
  5. 重新加载配置: nginx -s reloadsystemctl reload nginx
  6. 重启: systemctl restart nginx