If you ever used the command line, you probably have heard of dotfiles. Although the word dotfile could refer to hidden files in general in the *nix world, it is usually used to refer to the configuration files of various command line programs, such as bash and vim. When you start to seriously use the command line, you will find that you need to change configurations for programs. For example, you need to update your PATH inside .
Recently I was writing some C++ code and one thing I needed to do is to pass a pointer of an object within itself to another function. At first, I was using raw pointers and everything worked fine. However, later as I decided to use std::shared_ptr instead, I encounter error where the same pointer was freed twice. After some search online, I discovered that I need std::enable_shared_from_this. What’s causing the problem?
In 2017, I wrote a post on how to set up Let’s Encrypt certificates together with NGINX. Back then, Let’s Encrypt hadn’t added support for wildcard certificates. Althought it’s not a big issue, it does mean you have to generate a new certificate each time you want to add a new subdomain to the certificate. Earlier this year, Let’s Encrypt finally added support for wildcard certificates. Therefore, I recently changed to a wildcard certificate.
If you’ve written C/C++ code, you must know and probably have used macros. You may have defined handy macros to compute min and max. However, there are more ways macros can be used in C/C++ projects. I will try to describe a few which I frequently use in this post. Header guard The most frequent use of macro for me is definitely acting as the header guard. In C/C++ code, you cannot redefine the same function or variable twice.
When you first learn C++, you probably know about reference. It allows you to pass parameter as if you are passing by value while having a similar effect as passing a pointer. Sometimes, however, this may not work as you expect. In this post, I will discuss how to pass a reference when the normal way doesn’t work. Passing parameters to std::thread and std::bind If you have used std::thread or std::bind, you probably noticed that even if you pass a reference as parameter, it still creates a copy instead.