Filesystem in C++17

Multi-Domain Docker Containers

Use case

We have several server applications in the same development environment, each application is bundled in a Docker container, e.g: "Container A" and "Container B".

With Docker those applications have the same IP address. One way to differentiate and access to an specific application is exposing different ports.

/galleries/docker-multidomain/ip.thumbnail.png

Containers exposing the same IP address and different ports

But that solution is a little bit confusing, does 8080 mean we are accessing to "application A"?

It would be simpler and easier to remind something like:

/galleries/docker-multidomain/domain.thumbnail.png

Accessing applications by domain name

Get that extra semantic value is much simpler than I thought at the beginning and you will see below.

Read more…

Rust web frameworks comparison

I'm doing some experiments with Rust because it is a language that promises to be as fast as C/C++, but safer in regards to memory management. Essentially, it doesn't allow the developer to do "bad things" with the memory like: forgetting release the memory that is not going to be used anymore or release memory if the developer is not the owner. In such scenarios, Rust won't compile.

Just for learning I've started a small project that offers a REST API, so I've started looking for frameworks to ease/speed up the development. I've found a Rust web frameworks comparison: https://github.com/flosse/rust-web-framework-comparison

Convert files formats: Windows to Unix

If you are developing from a Windows environment to a Unix target environment, most likely you have had this issue: You install source files in Windows format in your Unix environment.

There is a way quite simple to convert all your files from Windows to Unix format:

find . -type f -print0 | xargs -0 dos2unix

I got it, of course, form http://stackoverflow.com/questions/11929461/how-can-i-run-dos2unix-on-an-entire-directory

REST URLs

C++ Dependency Management: Biicode

I'm interested in building, dependency management, packagin and deployment in regards to software projects. For Java, Scala, Python, and so on is quite easy since there are tools like Maven, Gradle, pip, Sbt, etc. But regarding C++_, the best options I've found are Maven with Nar plugin or Gradle with cpp plugin (incubation).

I knew about Biicode almost 2 years ago, but I've never found time to test it, until today.

How does Biicode work?

Firstly we have to install Biicode.

I've made tiny example project using logging system from Poco library.

I've executed this command to create the project, called bii_log.

bii new carlovin/bii_log --hello=cpp

I've created the project under my Biicode username, just in case I'd like to publish later.

Previous command generates the structure of files and directories, although we are going to focus only on:

blocks/carlosvin/bii_log/main.cpp
blocks/carlosvin/bii_log/biicode.conf

In biicode.conf we are going to configure our dependencies, in this example Poco library.

# Biicode configuration file

[requirements]
    fenix/poco(develop): 0

[parent]
        carlosvin/bii_log: 0

[includes]
    Poco/*.h: fenix/poco/Foundation/include

In [includes] section, we are overriding the path to file headers. If we don't override it we'd had to do something like this:

#include "fenix/poco/Foundation/include/Logger.h"

Thanks to this line, include declarations are going to be clearer, as follows:

#include "Poco/Logger.h"

Easy, now we can start using Poco in our project, e.g:

#include "Poco/FileChannel.h"
#include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h"
#include "Poco/Logger.h"
#include "Poco/AutoPtr.h"

using Poco::FileChannel;
using Poco::FormattingChannel;
using Poco::PatternFormatter;
using Poco::Logger;
using Poco::AutoPtr;

int main(int argc, char** argv) {
        AutoPtr<FileChannel> pChannel(new FileChannel);
        pChannel->setProperty("path", "log/sample.log");
        pChannel->setProperty("rotation", "100 K");
        pChannel->setProperty("archive", "timestamp");

        //AutoPtr<ConsoleChannel> pCons(new ConsoleChannel);
        AutoPtr<PatternFormatter> pPF(new PatternFormatter);
        pPF->setProperty("pattern", "%Y-%m-%d %H:%M:%S %s: %t");
        AutoPtr<FormattingChannel> pFC(new FormattingChannel(pPF, pChannel));
        Logger::root().setChannel(pFC);

        Logger & logger = Logger::get("TestChannel");
        for(int i=0; i<10000; i++){
                poco_information(logger, "This is a info");
                poco_warning(logger, "This is a warning");
        }
        return 0;
}

To compile the project we only have to execute following command:

bii cpp:build

To publish the project and to allow everyone use it as we have used Poco:

bii publish

Besides the ease to use, I like so much the integration with Eclipse with CDT. After "bii cpp:build" execution all files were properly indexed.

I've read also an article about the good integration with CLion: When CLion met biicode.

Software Maintenance

Few days ago at work, I had to fulfill a document where I had to select a type of software maintenance that I was going to apply.

The fact was I had only two choices, it seemed me very weird because during my degree I studied 3 or 4 kinds of software maintenance.

Today I have found my Software Engineering class notes, then the types of Software Maintenance sorted descending by percentage of time spent:

Perfective: Activities to improve or add new functionalities required by the user.
Adaptative: Activities to adapt the system to technological environment changes (hardware or software).
Corrective: Fix defects in hardware or software detected by user running the production system.
Preventive: Activities to ease the future system maintenance.

Build C++ project with Gradle

Introduction

I am more and more worried about building, dependency management and distribution of my projects. I'd like to find a tool unifies those processes with independence of the language. I know several tools those almost fit to what I'm looking for, like I know several tools those almost fit to what I'm looking for, like SCons, Autotools, Ant, Maven and lately Gradle.

I've made several projects with Gradle, but always I was focused in Java and Android projects. In Java projects I've found a Maven replacement, because it is faster, easier and less verbose. About Android projects I suffered the early adoption of Android Studio + Gradle, although currently I think the are more mature and they work fine.

First of all, I have to say: building C/C++/Objective-C projects with Gradle is in incubation phase, although now we can perform advanced tasks like:

  • Generation several artifacts within same project (libraries and executables).
  • Dependency management between artifacts (no versions).
  • Different "flavors" of the same software, e.g: we can generate a “Community” release and other one with more enabled features called “Enterprise”.
  • It allows multi-platform binary generation.

As I said, this plugin is still having limitations although they are working on it: Gradle C++ roadmap. If they achieve it I'll leave Autotools (I'm going to regret saying that).

Read more…