Code faster with Unit Testing

Wait a minute! How can you possibly code faster when in fact you have to write more code? Test Driven Development requires additional (redundant?!) classes which only duplicates work. The “redundant” code has to be maintained and kept in sync with the main software. It might be good for some big companies (preferably at the other end of the world) but not for us. We all heard that.
Continue reading “Code faster with Unit Testing”

Serial communication between Arduino and PHP with a protocol

In my previous post I discussed basics of serial communication between Arduino and PHP. Theory behind it is very simple. It all comes down to writing to a file. Simplicity of the serial communication paradoxically might contribute to confusion and surprising results. Serial device is like a black hole when you think about it. You send data inside but there is no feedback. You don’t know has your message arrived or not. You don’t know is your transmission going to be divided into multiple chunks or will arrive at one peace. There is no guarantee no feedback. On top of that there are some differences between operating systems and Arduino peculiarities. All of that combined together can confuse for a few hours or even discourage from the project.
Continue reading “Serial communication between Arduino and PHP with a protocol”

Benchmarking Amazon EC2 instance for a Web Server

For the last few days I’ve been testing Amazon web services (AWS). I’m looking for a reliable and scalable hosting provider to host Gloople e-commerce platform. Feature wise AWS is amazing. It offers literally everything an enterprise application might need. In fact, they offer so many services (and various configurations of those services) it might be confusing. I was trying to figure out which setup will be the most cost effective for our usage. It’s quite hard to tell is 4x M1 Small Instance better then 1x M1 Large instance just by reading specification (both setups cost the same). “Better” is of course subjective term and depends on a software although web applications have similar needs.
Continue reading “Benchmarking Amazon EC2 instance for a Web Server”

Creating a Chat server in PHP with sockets, forks and pipes

In my previous post I showed how to create a multi process socket server in PHP with pcntl_fork. This time I’m going to extend this example and write a chat server.
Chat is far more challenging because you not only have to handle simultaneous connections but also allow communications between processes. Inter process communication (IPC) has to be close to real time, synchronized and safe from racing condition.
Continue reading “Creating a Chat server in PHP with sockets, forks and pipes”