How to get current time and date in C++?

In C++ 11 you can use std::chrono::system_clock::now() Example (copied from en.cppreference.com): #include <iostream> #include <chrono> #include <ctime> int main() { auto start = std::chrono::system_clock::now(); // Some computation here auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; std::time_t end_time = std::chrono::system_clock::to_time_t(end); std::cout << “finished computation at ” << std::ctime(&end_time) << “elapsed time: ” << elapsed_seconds.count() << … Read more

Cross-Browser Javascript XML Parsing

The following will work in all major browsers, including IE 6: var parseXml; if (typeof window.DOMParser != “undefined”) { parseXml = function(xmlStr) { return ( new window.DOMParser() ).parseFromString(xmlStr, “text/xml”); }; } else if (typeof window.ActiveXObject != “undefined” && new window.ActiveXObject(“Microsoft.XMLDOM”)) { parseXml = function(xmlStr) { var xmlDoc = new window.ActiveXObject(“Microsoft.XMLDOM”); xmlDoc.async = “false”; xmlDoc.loadXML(xmlStr); return … Read more

How do you run a Python script as a service in Windows?

Yes you can. I do it using the pythoncom libraries that come included with ActivePython or can be installed with pywin32 (Python for Windows extensions). This is a basic skeleton for a simple service: import win32serviceutil import win32service import win32event import servicemanager import socket class AppServerSvc (win32serviceutil.ServiceFramework): _svc_name_ = “TestService” _svc_display_name_ = “Test Service” def … Read more