JavaScript Best Practices (edit)
Refresh current page
location.reload(true);
Logging with Pretty Print
javascript - Is it possible to bind a date/time to a console log? - Stack Overflow
<script>
var DEBUG = (function () {
var timestamp = function () { };
timestamp.toString = function () {
return "[" + (new Date).toTimeString() + "]";
};
return {
log: console.log.bind(console, '%s', timestamp)
}
})();
</script>
Moment.js
npm install moment --save
npm install moment-timezone --save
Display client machine date and time with Time Zone in browser
If you want to know the timezone of the client relative to GMT/UTC here you go:
var gmtRe = /GMT([\-\+]?\d{4})/; // Look for GMT, + or - (optionally), and 4 characters of digits (\d) var d = new Date().toString(); var tz = gmtRe.exec(d)[1]; // timezone, i.e. -0700
If you'd like the actual name of the Time Zone try this:
var tzRe = /\(([\w\s]+)\)/; // Look for "(", any words (\w) or spaces (\s), and ")" var d = new Date().toString(); var tz = tzRe.exec(d)[1]; // Time Zone, i.e. "Pacific Daylight Time"
Programmatically open 20 instances of Chrome
private static void Main(string[] args) { for (int i = 0; i < 20; i++) { try { Process process = new Process(); process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; process.StartInfo.Arguments = "https://www.google.com/" + " --new-window --incognito "; process.Start(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }