Wednesday, November 14, 2018

Mixing C++ and C and calling a C/C++ dll from Java

In Visual Studio, it is possible to mix C++ and C code, C++ files should have cpp extension, C files should have C extension, the compiler takes care of the rest. When including a C header file inside a C++ file, wrap it inside extern "C { #include "somfile.h"}. Otherwise, you will get LNK2019 (the dreaded "unresolved external symbol" error).

When you want to create a dll from this mixed project to be used with Java, in your wrapper header file of cpp implementation, you have to wrap the header body inside #ifdef __cplusplus extern "C" { #endif ...  #ifdef __cplusplus } #endif. Otherwise you will be able load the dll in Java but when you call a dll method, you will get UnsatisfiedLinkError.

Monday, November 12, 2018

The cost of refactoring

Today a colleague was proposing a design change to the backend of a GUI heavy application with the main rationale that the backend would be more elegant and the change would be easy to implement. I told him that the real cost of refactoring is the necessity to repeat all the manual UI tests (our automated Macro Scheduler tests are not ready yet). A GUI application has many paths to failure and we have been developing this particular application for a couple of years now. Changing the backend would certainly break some edge cases and from the users perspective, the app would have regressed.

The only acceptable reason for a backend refactoring would be if we had lots of functionality to add in the short term and the change would make such additions a breeze, being a net saving in effort, in addition to being elegant.

Thursday, November 01, 2018

Baby / child sleep training

Last weekend we met with friends who have a couple of months old baby. They asked us about sleep training. We told them that we first tried it according to the book but then changed it dramatically.

The main problem was that our son, who was 1 year old at the time of training start, resisted being laid down into the crib. Resisted means that he cried and wept with a terrified "I am going to die" look on his face and arms extended towards you begging for help for 45 minutes! We could not bring ourselves to leave him alone in his room like that. So, we laid besides him in the crib until he fell asleep (took about an hour) and sneaked away.

After a couple of months, we put some pillows beside his crib and waited there for him to fall asleep which again took about 1 hour each day. Every half an hour, I changed places with my spouse. It sometimes took 1.5 hours. After he fell asleep he usually woke up when we put him into the crib and the whole procedure lasted for another half an hour. Trying to carefully lift and place him into the crib was bad for our backs too.


Finally we decided to buy an adult size matress and laid it on the floor of his room and gave up on the crib altogether. At bed time, we cuddled him, played children's music, and when he fell asleep, we simply left the room without the crib hassle. Win-win :)

Monday, October 22, 2018

Why HTTPS?

Recently I converted my web site from HTTP to HTTPS. Reasons:
  1. Chrome flags all HTTP sites as unsecure by default which is annoying.
  2. To protect login information from man in the middle attacks.
  3. For Progressive Web Apps (web apps that can run offline)
  4. For accepting online payment.
The basic steps of converting your site to HTTPS:
  1. Buy a domain name and redirect it to your server IP.
  2. Install Nginx on your server and configure it to forward traffic to relevant ports.
  3. Obtain a TLS/SSL certificate and install it.
  4. Add a cron job to automatically renew the certificate.

Complexity of IoT with web UI

One of my on going projects collects data from IoT sensors and displays them on a web page. The things I had to learn were quite a lot. Here is a short list:
  1. VPS, Ubuntu, Putty, Filezilla
  2. Nodejs, Javascript, HTML, CSS, socket.io
  3. Arduino IDE, libraries for sensor, board etc.
  4. Sending data from sensor to VPS
  5. Custom hardware design for rugged case, smaller form factor and minimal power consumption (done by a friend of mine).
  6. Obtaining a domain name and redirecting it to VPS IP
  7. Nginx as a reverse proxy
  8. HTTPS, certification
  9. Login, register
  10. Online payment
  11. Database

Friday, October 12, 2018

Best way to expand your network

The best way to expand your network is to work on something. Besides learning new things, you will also meet like minded people, exchange ideas and expand your network.

Tuesday, October 09, 2018

How bureaucracies get out of control

Recently I had to spend more than an hour to convince some otherwise very smart people that we should not have QA approval to close a bug. Having such an extra step caused developers to refrain from using the type "bug". Instead, they started to use the more generic "issue" type. The result was not being able to see which issues were bugs. For me, bugs are the more important issues to work on. When you label an issue as a bug, you get a nice red exclamation mark to the left of the issue on your board.

My personal experience is that it is quite easy to add something to an existing procedure but 10 times more difficult to remove something. This bias leads to bureaucracies getting larger, more complicated and less useful in time. This is the exact opposite of "perfection is attained not when there is nothing more to add, but when there is nothing more to remove" [Antoine de Saint Exupéry]