Friday, November 4, 2016

C++: New keyword exceptions

When new is used, a bad_alloc can be thrown. To return null pointer on error instead of the exception a second format can be used:

Site *maanoo = new (std::nothrow) Site("maanoo.com");


done_

Wednesday, October 12, 2016

Windows: Copy only what's new or changed

Copy all files (/H /G) and directories (/E) that are either new or changed (/D /Y)

xcopy C:\From C:\To /D /E /I /H /Y /G


done_

Monday, September 12, 2016

Java: Open link in browser

Open a link with the default browser:

Desktop.getDesktop().browse(new URL("http://maanoo.com").toURI());


done_