Digital Cuckoo Clock

This hobby project came to life when my wife asked if our cuckoo clock can say time along with common cuckoo’s call. The idea is to integrate traditional cuckoo clock with digital options.

This is the work in progress and technical details will be updated soon. Please visit again for updates…

Is hosting at home a good idea?

Please do not let the title mislead you.  By “Hosting” it means to host your web services at home. As an enthusiast I took the command into my hands and started building my own server at home.

Plan was not set up a business strategy to compete with big giants but to host services for my personal usage. Perhaps motivation was also to implement all the knowledge gained in networking lectures.

After spending all the time and money I had services up and running like email with webmail, cloud, audio server, online gallery, calendar, notes, vpn, ssh and more…

The point of all these services if they are open to be shared which also brings the need to open ports. That also make your local network vulnerable to be hacked. Hackers can get access to ports but that can be only dangerous if hackers can manipulate vulnerable services, still it is a vulnerability.

Alternative would be to also go for online paid services with excellent service plans with minimal fee. Economically, going for online hosting services could be a bit more than paying for electricity cost per year for your server at home.

Nevertheless, please decide it for yourself what do you want for yourself, Security loopholes in your home network where you might make bank transactions or paying for online hosting services?

 

Please feel free to leave comments for improvements of this blog, Happy Coding!

Build Systems

Build systems are designed to build your code in a structured way. There are several powerful build automation tools out there which can automated create executable from your source code.

This blog does not discuss which build automation to pick for your projects but to introduce what build systems are and which are the most traditionally used build systems

Make

Make still remains the most widely used for Unix systems.  Here is the sample code to explain how could we use make tool to automatize the build process

main.cpp

#include "logger.h"
#include "factorial.h"

int main() {
 Logger logger;
 Factorial fac;
 logger.log(fac.find_factorial(5));
 return 0;
}

logger.cpp

#include "logger.h"
#include 

Logger::Logger() {
 // TODO Auto-generated constructor stub
}

void Logger::log(int value) {
 log(std::to_string((int) value));
}

void Logger::log(const std::string& msg) {
 std::cout << "LOG : " << msg << std::endl;
}

logger.h

#ifndef LOGGER_H_
#define LOGGER_H_

#include 

class Logger {
public:
 Logger();
 virtual ~Logger() = default;

void log(int value);
 void log(const std::string& msg);
};

#endif /* LOGGER_H_ */

factorial.h

#ifndef FACTORIAL_H_
#define FACTORIAL_H_

class Factorial {
public:
 Factorial();
 virtual ~Factorial() = default;

int find_factorial(int value);
};

#endif /* FACTORIAL_H_ */

factorial.cpp

#include "factorial.h"

Factorial::Factorial() {
 // TODO Auto-generated constructor stub
}

int Factorial::find_factorial(int value) {
 if(value!=1){
 return(value * find_factorial(value-1));
 } else {
 return 1;
 }
}

#ifndef FACTORIAL_H_
#define FACTORIAL_H_

class Factorial {
public:
 Factorial();
 virtual ~Factorial() = default;

int find_factorial(int value);
};

#endif /* FACTORIAL_H_ */

The above code cab be simply build using follow command

g++ -std=c++11 make_hello_world.cpp logger.cpp factorial.cpp -o hello

This is a very simple project and just imagine when this project grows and multiple developers are  working on it. Here is the example on how can this build system can be automated using make tool. Make tool take a Makefile as an input to know where he can find out source files.

Makefile

all: hello

hello: make_hello_world.o factorial.o logger.o
    g++ make_hello_world.o factorial.o logger.o -o hello

main.o: make_hello_world.cpp
    g++ -c make_hello_world.cpp

factorial.o: factorial.cpp
    g++ -c factorial.cpp

hello.o: logger.cpp
    g++ -c loggre.cpp

clean:
    rm *o hello

To build using Makefile, run:

make
OR 
//To build with multi cores
make -j
//To clean and build again 
make clean && make

Maintenance of manual created Makefiles could be very challenging. Specially,  for projects with multi layer architecture and 3rd party dependencies.

To overcome limitations of manual designed makefiles there are many automated build systems which can generate makefiles automatically. Great, right!?

CMake

CMake is also an automated build tool with some more powerful features. CMake is designed to overcome overcome shortcomings like complex syntax and most important not so easy maintenance.

CMake is also taking a file with name CMakeFiles.txt as an input and auto generate the Makefile for us.

cmake_minimum_required (VERSION 2.6)
#set project name
project (hello)
#set c++11 compiler flag
set (CMAKE_CXX_STANDARD 11)
#add all source files
set (SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/make_hello_world.cpp
 ${CMAKE_CURRENT_SOURCE_DIR}/logger.cpp
 ${CMAKE_CURRENT_SOURCE_DIR}/factorial.cpp)
#create binary
add_executable(${PROJECT_NAME} ${SRC_FILES})

To build same code, please run

#create build dir
mkdir build && cd build
# generate Makefile
cmake ..
# generate binary using make tool
make -j

Therefore, you can see CMake a modern, powerful and well maintained wrapper for make.

 

Please feel free to leave comments for improvements of this blog, Happy Coding!