Fixing Server Side Events and Connection Aborted Issues

Server Side Events offer an easy way to push data to clients. It’s much easier to implement than websockets or another technology. IF you stumble on the problem of connections not getting aborted, when clients closed the event resource, or if you see the data coming in chunks, you need to tweak your PHP server,… Continue reading Fixing Server Side Events and Connection Aborted Issues

JSON Encoding of number problem

You can get quite surprising results if you try to json_encode something like json_encode($n[“number”]=3.53). echo json_encode($n[“number”]=3.53); 3.5299999999999998 Seems there is a bug in PHP, that parse floats with wrong precision. Currently json_encode() uses EG(precision) which is set to 14. The solution is to cast the number to string: echo json_encode($n[“number”]=(string) 3.53); “3.53” Another solution is… Continue reading JSON Encoding of number problem

The ease and beauty of VIM

Never thought that I would write a post with the ease of VIM in the title. But honestly I tried a lot of editors still coming back to VIM. VIM is a lot more hackable then Atom. Probably because I like bash, python and javascript, while Atom is javascript hackable only. VIM is not easy… Continue reading The ease and beauty of VIM

Suppressing errors in PHP with control operator @

Errors give valuable information, it’s worth paying attention to. Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can’t solve. Reading something into simpleXML that isn’t 100% validated XML, because it’s encoded in ISO-8859 instead of UTF-8. Then use the PHP one error control operator¬†@. When… Continue reading Suppressing errors in PHP with control operator @