Jan 18

What is Sonoff and how to configure it

Remote switches, Internet of Things (IoT) and Smart home in general are quite trendy nowadays. There are plenty of trademarks and devices that allow you to switch lights, heating, garage doors etc via an application on your mobile / web page.

There is one very popular gadget among the Smart housers – the Sonoff. It is actually a trademark that includes various kinds of remote switches. Sonoff devices are getting more and more popular these days because they are small, cheap, cloud ready, easy to use and have built-in AD/DC converter (i.e. no external power supply is needed, just a cable to plug it in the grid). Some sonoffs can be controlled via RF keyfobs.

Continue reading

Jun 03

Мистерия: if (something==NULL) или if (NULL==something)?

Нека разгледаме следния програмен отрязък:

[code lang=”C”]if (NULL == someApiPointer)
//do something here

Защо сравняваме NULL със стойността на someApiPointer, а не обратното – както сани учили в училище и както изглежда по-логично?
Когато за първи път срещнах подобна конструкция си помислих, че има нещо специално в нея – прави се от гледна точка на сигурността или пък е нов стил на писане?

Continue reading