Check the Available Memory of Default Pool

One capacity planning best practice of using SQL In-Memory OLTP engine is to bind the database with a resource governance pool. The calculation of memory resource of pools is from here, and I translate it into below TSQL code  to check both configured value and available value in run time.