Author Archives: Ovidiu Anicai

Thug life

Still getting added on LinkedIn, and lots of offers

MongoDB more indexes on Secondaries

I’ve been wondering for a time if it works, the documentation is not really clear if you can have different indexes on a replicaset secondary, maybe delayed or with priority 0. Using this feature you can do reports better on a … Read more »

Compare strings in PHP

Just read a comment in the PHP documentation and had another PHP madness moment. It seems you have to be really, really careful when comparing strings that include numbers…   Command \ PHP Version 7.0.0 – 7.1.3 5.4.4 – 5.6.30 … Read more »

PHP switch case after default works normally

When you put the a case block after the default block the switch will work normally and fallback to the default only after testing all cases. The documentation doesn’t specify this directly, but there is a note with an example. … Read more »

How Tor works

Great photos explaining what is disclosed at each point when doing a request on the web, with or without Tor or HTTPS. The photo is provided by the EFF https://www.eff.org/pages/tor-and-https

Strings array access issue

What would you expect for this script to output? error_reporting(E_ALL); ini_set(‘display_errors’,1); $text = “abc”; var_dump(isset($text[‘key’])); var_dump((bool) $text[‘key’]); Maybe a notice? maybe some false there.. But if you have in mind PHP logic.. you surely know.. So, $text is a string … Read more »

Foreach with reference

If you iterate over an array with & you should unset the value variable after to not modify the array accidentally after. $array = array(‘a’, ‘b’, ‘c’, ‘d’); foreach($array as $key=>&$value) { if ($key = 3) { // change d … Read more »

PHP echo print question

Working with echo or print is very easy in PHP. At the begining it might be harder to understand concatenations or operations order, but after you master them is really easy. But there are some cases where you wonder how … Read more »

Line history on Git

# file path export FILE=file/path # line number export LINE=10 git log –format=format:%H $FILE | xargs -L 1 git blame $FILE -L $LINE,$LINE | uniq -c