How do I compare two DateTime objects in PHP 5.2.8?

The following seems to confirm that there are comparison operators for the DateTime class: dev:~# php <?php date_default_timezone_set(‘Europe/London’); $d1 = new DateTime(‘2008-08-03 14:52:10’); $d2 = new DateTime(‘2008-01-03 11:11:10’); var_dump($d1 == $d2); var_dump($d1 > $d2); var_dump($d1 < $d2); ?> bool(false) bool(true) bool(false) dev:~# php -v PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03) … Read more

What is the difference between memoization and dynamic programming?

Relevant article on Programming.Guide: Dynamic programming vs memoization vs tabulation What is difference between memoization and dynamic programming? Memoization is a term describing an optimization technique where you cache previously computed results, and return the cached result when the same computation is needed again. Dynamic programming is a technique for solving problems of recursive nature, … Read more

How to pass json POST data to Web API method as an object?

EDIT : 31/10/2017 The same code/approach will work for Asp.Net Core 2.0 as well. The major difference is, In asp.net core, both web api controllers and Mvc controllers are merged together to single controller model. So your return type might be IActionResult or one of it’s implementation (Ex :OkObjectResult) Use contentType:”application/json” You need to use … Read more

What is the purpose of nameof?

What about cases where you want to reuse the name of a property, for example when throwing exception based on a property name, or handling a PropertyChanged event. There are numerous cases where you would want to have the name of the property. Take this example: switch (e.PropertyName) { case nameof(SomeProperty): { break; } // … Read more

Acronyms in CamelCase [closed]

There are legitimate criticisms of the Microsoft advice from the accepted answer. Inconsistent treatment of acronyms/initialisms depending on number of characters: playerID vs playerId vs playerIdentifier. The question of whether two-letter acronyms should still be capitalized if they appear at the start of the identifier: USTaxes vs usTaxes Difficulty in distinguishing multiple acronyms: i.e. USID … Read more

onMeasure custom view explanation

onMeasure() is your opportunity to tell Android how big you want your custom view to be dependent the layout constraints provided by the parent; it is also your custom view’s opportunity to learn what those layout constraints are (in case you want to behave differently in a match_parent situation than a wrap_content situation). These constraints … Read more