Posts in category “Tips”

Rider Terminal tips

  1. Stop Leaving the Terminal when you press the Escape key. It is really annoying when you are a vim fan like me! here's the solution

Go to "Settings | Tools | Terminal" and click "Configure terminal keybindings".

Find "Plug-ins | Terminal | Switch Focus To Editor" action and change its keyboard shortcut (by default "Escape") via the context menu.
Keybindings are IDE-wide, so there is no need to change them for each project.

  1. Using msys2 bash as the embedded terminal: at Settings > Tools > Terminal
Environment Variables: CHERE_INVOKING=1
Shell path: c:\msys64\usr\bin\bash.exe --login

Unfortunately, the environment variables above work only on the current project; It is definitely a tedious process that you have to repeatedly set it up for every project. So I eventually found a better way to achieve the same goal without setting up the Environment variables in Rider. Here is the answer Reference:

Shell path:  C:\msys64\msys2_shell.cmd -defterm -here -no-start

TBC...

Fix Printer Spooler service cannot start issue on Windows 7 system

One of my old classmates asked me to fix the issue that her computer cannot print anything. Thanks to TeamViewer, I could connect to her computer then fix the issue. I found that the Printer Spooler service is down and could not start. When you start it, it started and then automatically shuts down in 2 seconds. Google helped me.

For this case, in short: Remove all files in C:\Windows\system32\spool\PRINTERS directory

After that, the service could start, and all printers came back and worked.

微信浏览器内H5活动页调起小程序, 服务器端开发备忘

  1. 公众平台设置H5静态页服务器IP白名单

  2. 上传验证文件到根目录(一定要先做好这一步才能做下一步啊

  3. 公众平台设置域名白名单

  4. 服务器端配置公众平台 appId, appSecret

  5. 缓存针对此appId的 accessToken 和 jsapi_ticket

  6. 服务器端生成签名.....参数一定要按字典序!(坑)

MySQL: Delete All Duplicate Rows Except the Earliest One in One SQL

You want to add a unique index to a table, and unfortunately, there are already many duplicate rows in it. Manually find and delete these rows is time-wasting and error-prone. So why won't we just write one SQL statement and quickly resolve it?

First try, I wrote the following statement, and it won't work:

DELETE FROM PromotionSkus A 
WHERE 
	A.SkuId IN (SELECT SkuId FROM PromotionSkus B GROUP BY B.SkuId HAVING COUNT(B.SkuId) > 1) 
	AND 
	A.Id NOT IN (SELECT MIN(Id) FROM PromotionSkus C GROUP BY C.SkuId HAVING COUNT(C.SkuId) > 1);

AND this one below works!

DELETE FROM PromotionSkus A
WHERE 
	A.Id NOT IN (SELECT Id FROM (SELECT MIN(Id) AS Id, COUNT(SkuId) AS Total FROM PromotionSkus GROUP BY SkuId HAVING Total > 1) AS B)
	AND 
	A.SkuId IN (SELECT SkuId FROM (SELECT SkuId FROM PromotionSkus GROUP BY SkuId HAVING COUNT(SkuId) > 1) AS C);

The reason is well explained in this brilliant article.

However, I found a much simpler solution on 23-Mar-2025, which is

DELETE FROM PromotionSkus 
WHERE Id NOT IN (
    SELECT Id FROM (
        SELECT MIN(Id) AS Id 
        FROM PromotionSkus 
        GROUP BY SkuId
    ) A
);

Another mysql tip: using mysqldump export a table with one line one row.

mysqldump --databases YourDataBaseName --tables YourTableName --skip-extended-insert

Why do we need that? It is much easier to compare !

Using the cookie feature in Insomnia Core

It took me more than an hour to understand how to use cookies when you are sending a request to the API server.

The most important thing is that you only need to correctly add the cookies, then the cookies will be automatically sent to the API server. Don't try to add a cookie item at the headers' configuration part!