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

How to format JSON in VIM/GVIM

The strength and beauty of VIM is the simple interaction with lots of external programs. To format any JSON file in VIM/GVIM: :% !jq . % means the file you’re working on, and `!jq` is run the external command `jq` That’s all. You need to have `jq` installed: sudo apt install jq whatis jq jq… Continue reading How to format JSON in VIM/GVIM

Published
Categorized as Tutorial

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