John Liu Blog

Every drop counts

Change NIC category

A network card (NIC) can be classified as in Private network, Public network or Domain network. One can setup different firewall policies for different network category. If need, you can use Powershell script to change NIC netowrk category. #to list NIC network connection profile info Get-NetConnectionProfile #to change NIC network connection profile Set-NetConnectionProfile -Name "Unidentified network" -InterfaceIndex 56 -NetworkCategory Private

HttpWebRequest SSL/TLS error

If you are using HttpWebRequest in your application, you may receive “The request was aborted: Could not create SSL/TLS secure channel” error. This error might be caused by the mismatch SSL/TLS protocol between the server and client. The solution is to make sure that both client and server have a common protocol version supported. Add following line in your code to let the client be able to connect to as many servers as possible (rather than to be as secure as possible).

Regex

Some Regex syntax Find quoted text "(.*?)" Lookahead: matches “x” only if “x” is followed by “y” x(?=y) Negative lookahead: matches “x” only if “x” is NOT followed by “y” x(?!y) Lookbehind: matches “x” only if “x” is preceded by “y” (?=y)x Negative lookbehind: matches “x” only if “x” is NOT preceded by “y” (?!y)x CSV file line columns counts Using comma as delimiter. ,|(".*?"(,(?!$))?) break above down as: , a standard comma | or ( start of group ".

SQL error

1. “Cannot load Counter Name data because an invalid index” When trying to install SQL2019 PolyBase (and possibly other programs as well), you may receive error “Cannot load Counter Name data because an invalid index” exception To fix this error, start CMD as administrator and run C:\WINDOWS\System32> lodctr /r then run C:\WINDOWS\SysWOW64> lodctr /r If all success, you should receive message: “Info: Successfully rebuilt performance counter setting from system backup store”

SQL NoLock query hint

SQL query hint NOLOCK is similar as using READ UNCOMMITTED isolation level. People often under the impression that this query hint will make query run faster (as no blocking or lock allocation required). However, one needs to consider carefully the following big drawback with NOLOCK query hint and better step away from using it. The drawbacks/issues with using NOLOCK query hint: Query may return the same row twice Query may skipping rows Query may see rows not actually commited Query may fail with error “could not continue scan with nolock due to data movment” Unless inaccurate query results is not an issue, we should never use the NOLOCK hint.