Embrace the change

Last week a friend of mine sent me this video. Please take a moment and watch it (It’s just 3 minutes and half):

Javatar

It’s a funny video about a family that worship Microsoft technologies especially .NET framework and C#. The smallest member of the family asks his father about other technologies instead of Microsoft technology stack (Java in this video) and suddenly his father gets angry and tells his child not to even think about it. After the child grows up, he decides to use Java but he hides it from family. One day while they’re having dinner, the child announces that he is going to continue with Java and doesn’t want to use .NET framework anymore. His mother instantly starts crying and tell him to leave them as soon as possible. “You’re not a part of family anymore”, his father says. The child has it’s own path now.

Although it’s just a funny video, it delivers an important message! Some people tend to stick with things they get used to. They’re afraid to try new things because they think it may put their situation at risk. They don’t like to try new things because they have to learn a lot of new stuff and dealing with them is difficult to some people.

As developers we have lots of options to chose from. It’s completely OK to use Microsoft technology stack. In fact, I was (or maybe am) a .NET developer. Undoubtedly it’s a powerful and one of the best frameworks out there. But in my opinion, you have to try new things as well. For example, if you are a backend developer, you may want to try some other programming languages such as Go or Python. If you’re a Windows user, you may want try Linux as well (Backup everything before doing such thing ;)). It gives you an insight about what’s going on outside the .NET world! I know it could be risky sometimes; but, it definitely worth it.

I love Vim too but ...

Vim is a great text editor. It is actually one of the most popular ones among developers and nerds especially if they have experience working with Unix-like operation systems. Most people instantly fall in love with Vim’s key bindings and the philosophy behind its mindset. It allows you to do almost anything without using the mouse.

By default, Vim is just a text editor; however, with the help of a few plugins, you can turn it to an IDE. Plugins like YouCompleteMe and Jedi provide auto completion as you type! NerdTree brings tree-like project structure to Vim and Ctrl-P allows you too simply search through your project files and find the file you’re looking for fast.

It also supports themes! You can download and install your desired theme or simply choose from one of the built-ins. You may want to do some strange things in Vim as well. A friend of mine, checks his emails and plays music in Vim!

These are cool right! You live inside the terminal like you’re living in 70’s and there’s no GUI available. You use Vim because it’s lightweight like your 2019 MacBook Pro has only 32MB of RAM and you’re trying your best saving resources. You behave in a way that your computer is something like below! Oh come on man; this is just insane!

An old computer with 16mb of RAM

Things have changed during the past 3 decades dude! Smartphones now have 16GB of RAM and 1 TB of flash storage. Every CPU now has a powerful GPU built-in which can output up to 8K! The internet connection you’re using to read this post post can download files fast. Developers code in such environments these days:

A modern computer for coding

I love Vim! I really do. I have also published my .vimrc file on Github. But I believe it should be used only if there is no other options. It is the swiss army knife for system administrators because they mostly connect to servers using SSH and need a CLI-based editors get their job done. But as developers, we have much broader options to choose from. That 8GB of memory that is installed on your machine is completely free to use. I don’t want to advertise the text-editor or IDE I’m using myself. It’s completely up to you! You may want to continue using Vim and that’s OK. But just because geeks use Vim for coding doesn’t mean it is the best option and you have to do the same!

If you’re a developer, remember that the job is to develop the software. Your client doesn’t pay you more if you use a geeky text-editor or hard-to-install linux distro. They just want their software to be developed using best-practices and they want it fast. Using CLI-based software doesn’t make you a good developer.

Different ways to split a string in C++

All high-level programming languages provide a large amount of functions for strings manipulation and splitting is one of the most useful ones. Here are some example of how to perform a string split in Python and C# programming languages:

Python:

s = 'Hello world'
result = s.split(' ')

# Result is ['Hello', 'world']

C#:

var str = "Hello world";
result = str.Split([' ']);

// Result is ['Hello', 'world']

In C++ there is not such built-in functions to split a string by a delimiter; however, it is possible to write your own split function. There are two approaches though:

In classic C way

In C standard library has a <string.h> header file that provides some useful functions for string manipulation and one of them is strtok.

The strtok() function is used to isolate sequential tokens in a null-terminated string, str. These tokens are separated in the string by at least one of the characters in sep.

#include "string.h"
#include "stdio.h"

char* str = "Hello world";
char* splitted = strtok(str, " ");
while (splitted != NULL) {
    printf("%s", splitted);
    splitted = strtok(NULL, " ");
}

In the about example, please consider the following description:

The first time that strtok() is called, str should be specified; subsequent calls, wishing to obtain further tokens from the same string, should pass a null pointer instead. The separator string, sep, must be supplied each time, and may change between calls.

Please also note that if you want to use the above code in a C++ application, you should change the include section string.h to <cstring>.

The modern C++ way

The other approach is to use C++11 std::string class. The new string class provides various useful functions to work with strings. However and as far as I know, it doesn’t have any split functions yet. But you can simply create one using other functions provided in the string class. The following is an implementation of split function in C++:

#include <string>
#include <vector>

std::vector<std::string> split(const std::string &str, const std::string &delim)
{
    std::vector<std::string> tokens;
    size_t prev = 0, pos = 0;
    do
    {
        pos = str.find(delim, prev);
        if (pos == std::string::npos)
            pos = str.length();
        std::string token = str.substr(prev, pos - prev);
        if (!token.empty())
            tokens.push_back(token);
        prev = pos + delim.length();
    } while (pos < str.length() && prev < str.length());
    return tokens;
}

As you can see in the above code, we have used the built-in find and substr functions to implement our own split! Finally we pushed each token to a vector and return it to the user. The reason we have used the vector is because we don’t know how many items would be in our result list.

My first experience with Zoho Mail

If you have your own domain and website, you probably want to have some @yourdomain emails as well. Although some hosting providers offer free email hosting, some simply don’t. You also have to configure your own mail server if you’re owning a VPN or dedicated server.

If you’re setting up a mail server for your company, there are some premium mail providers available such as Microsoft Office 365 and GSuite that offer huge amount of features such as online storage, document editing features and so on. On the other hand, people like me may just need to have an email address on their own domain. They need a good email server but don’t want the extra featured which I have mentioned a couple of them few lines above. At this point you want to give Zoho Mail a try.

Zoho Mail is an email hosting service is offers just I wanted. All you need to do is to sign up. They guide you through the process of setting things up and then you will have the access to your new inbox. The free plan offers up to 5 users for free. This free plan gives you full access to their web panel and well as Zoho Mail app so you can check your email either on you phone or your computer. However, if you need IMAP or POP access, you need to upgrade to a premium plan as low as $1 per month.

Zoho Mail subscription plans

You can find more information other their website at: https://www.zoho.com/mail/

Moving to Jekyll

When I started this blog at 2008, I used BlogEngine blogging platform to publish my posts. I chose BlogEngine because it was (Or maybe is) written in .NET and I was a .NET enthusiast at that time. After a few years of blogging with The BlogEngine platform, I decided to move to WordPress. WordPress the the most popular blogging platform and I was very satisfied with it. It has a very powerful text editor and a feature-rich administrator panel.

The problem starts when I lost all of my posts! I was a GoDaddy user for a couple of years and due to International sanctions against Iran, I couldn’t pay for my subscription and didn’t have backup of my posts.

WordPress is actually an awesome platform; however, to to able to deploy it to your website, You should install a few prerequisites. The first requirement is the PHP programming languages because it is written in PHP. The second is the MySQL database!

This could cause some minor issues when wanting to backup your website data. To create a backup in WordPress, you will need to backup your not only your files but your database as well.

Jekyll

Jekyll is a very simple programmer-friendly blogging platform. I works by compiling markdown files into pure HTML files. All you need to do is to create a markdown file, write your post and then compile it to HTML files. You can then upload those files to your hosting storage or using simply use GitHub Pages and forget about paying for hosting storage since Github gives you unlimited bandwidth and storage.

When using Jekyll with GitHub Pages, you have to git push your files into a Github repository to post them to be able to see them on your website. By doing so, you have also backed up your code as well.

If you’re interested as I do, you can give Jekyll a try . In addition, you can access the source code of this blog by clicking here