Get CPU and Memory usage of system in C#

PerformanceCounter cpuCounter=new PerformanceCounter("Processor", "% Processor Time", "_Total");
PerformanceCounter ramCounter= new PerformanceCounter("Memory", "Available MBytes");

// The method nextValue() always returns a 0 value on the first call. So you have to call this method a second time
cpuCounter.NextValue();
Thread.Sleep(1000);
var cpuUsage = cpuCounter.NextValue();
string cpuUsageStr = string.Format("{0:f2} %",cpuUsage);

var ramAvailable = ramCounter.NextValue();
string ramAvaiableStr = string.Format("{0} MB", ramAvailable);

References :
http://stackoverflow.com/questions/4679962/what-is-the-correct-performance-counter-to-get-cpu-and-memory-usage-of-a-process
http://stackoverflow.com/questions/2181828/why-the-cpu-performance-counter-kept-reporting-0-cpu-usage

jQuery Templating

An example template is below:

<script type="text/html" id="template">
    <div data-content="author"></div>
    <div data-content="date"></div>
    <img data-src="authorPicture" data-alt="author"/>
    <div data-content="post"></div>
</script

And to use this do the following:

$("#template-container").loadTemplate($("#template"),
    {
        author: 'Joe Bloggs',
        date: '25th May 2013',
        authorPicture: 'Authors/JoeBloggs.jpg',
        post: 'This is the contents of my post'
    });

Similarly the content of the template could be held in a separate html file without the enclosing script tag, and used like the following:

$("#template-container").loadTemplate("Templates/template.html",
    {
        author: 'Joe Bloggs',
        date: '25th May 2013',
        authorPicture: 'Authors/JoeBloggs.jpg',
        post: 'This is the contents of my post'
    });

References :
http://codepb.github.io/jquery-template/
https://www.sitepoint.com/overview-javascript-templating-engines/

Problem in installing Dot Net Core 1.0.0 VS 2015 Tools Preview 2

Each time I try to install the DotNetCore.1.0.0-VS2015Tools.Preview2.exe package I get an error saying the following:

Setup Failed One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the log file. Setup has detected that Visual Studio 2015 Update 3 may not be completely installed. Please repair Visual Studio 2015 Update 3, then install this product again.

After changing the VS Community UpdateVersion string value from 14.0.25424 to 14.0.25420 in the registry, the installer worked fine for me

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\community
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\community\1033
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\ente‌rprise
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\ente‌rprise\1033

References :
http://stackoverflow.com/questions/38134048/problems-installing-dot-net-core-1-0-0-vs-2015-tools-preview-2