Posts in category “Tips”

Solution for Slow logon via Remote Desktop to Server 2012: Disable the Large Send Offload

Recently, I found it became very slow when I am logging onto my development VM, a windows server 2012R2 instance through Remote Desktop. There are many kinds of solutions in Google's search results. I tried many of them and found only this one suits me.

On the Windows Server 2012 machine, disable the Large Send Offload via the following steps:

Open Network Connections. 
Click Change adapter settings
Right-click the icon of the Network card and select Properties.
In Networking tab, click Configure… button.
In the next window, switch to Advanced tab.
Click the Large Send Offload Version 2 (IPv4) and change the value to Disabled.
Click the Large Send Offload Version 2 (IPv6) and change the value to Disabled.

Your RDP connection will disconnect right away after you apply the change. Don't worry, connect it back and you will find the annoying delay disappears!

Reference

CTE 101

Today I first learnt the concept of CTE (Common Table Expression) from my colleague Rod. Basically, CTE can be used to improve the readability of your long and complex SQL statement.

for example, without CTE, you might write the following SQL:

CREATE OR REPLACE VIEW dfx.test_vw123 AS
SELECT 
	a.FIELD_A, 
	a.FIELD_B, 
	b.FIELD_C
	b.FIELD_D
FROM (
	SELECT 
		MAX(FIELD_A) AS FIELD_A, 
		COUNT(*) AS FIELD_B 
	FROM TABLE_A ta 
	WHERE ta.FIELD_E = 'General' 
	GROUP BY ta.FIELD_F
) a 
LEFT JOIN TABLE_A b 
ON a.FIELD_A = b.FIELD_A

with CTE, you could write the following one with better readability.

CREATE OR REPLACE VIEW dfx.test_vw123 AS
WITH TABLE_A_STATS AS (
	SELECT 
		MAX(FIELD_A) AS FIELD_A, 
		COUNT(*) AS FIELD_B 
	FROM TABLE_A ta 
	WHERE ta.FIELD_E = 'General' 
	GROUP BY ta.FIELD_F
)
SELECT 
	a.FIELD_A, 
	a.FIELD_B, 
	b.FIELD_C
	b.FIELD_D
FROM TABLE_A_STATS a 
LEFT JOIN TABLE_A b 
ON a.FIELD_A = b.FIELD_A;

For further information about CTE, click Reference
I also found another article about CTE in Chinese.

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. 服务器端生成签名.....参数一定要按字典序!(坑)