Here I will show how to use external libraries like boost in your project and compile it using gcc. I will show it on Ubuntu OS.

First install boost on Linux

sudo apt-get install libboost-all-dev

Now create some C++ script with boost headers

#include <iostream>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
int main()
{
}

And compile with necessary library flags

g++ -o test_boost test_boost.cpp -lboost_system

Let’s try boost::format

int main()
{
unsigned int arr[5] = { 0x05, 0x04, 0xAA, 0x0F, 0x0D };

std::cout << boost::format("%02X-%02X-%02X-%02X-%02X")
% arr[0]
% arr[1]
% arr[2]
% arr[3]
% arr[4]
<< std::endl;
}

Output:

05-04-AA-0F-0D

When we implememt classes in C++ there is a special this pointer pointing to the current instance of the classes it is called for. Here I will show some interesting things about this pointer I have learnt.

‘this’ is const pointer

We can’t modify it. Let’s see on some toy example:

class Foo {
private…

Sometimes in our work we need to get several highest values in list in descending order.

Here is a very simple algorithm to solve this problem for three values

Let’s define a list

vector<int> numbers = {5, 13, 7, 24};

Then sort the list in descending order. First way to do that is

sort(nums.rbegin(), nums.rend());

Second way is

sort(nums.begin(), nums.end(), greater<int>());

You can read about greater here.

Now simply print first two values which should be highest ones

cout << nums[0] << ", " << nums[1] << endl;

Sometimes we need to work with integers in binary format and manipulate individual bytes in their binary representation. Here I will show two ways we can work with integers this way.

First way is to use ordinary int type.

First let’s create two variable in binary format:

int x =…

Sometimes we need to work with some graphical and GIS data in very specific format. Here I will show how to work with shp data foramt in Python.

Here is a library pyshp. Install it

pip install pyshp

Then open some file using pyshp

import shapefilepath_shp_file = 'LineFeature.shp'path_sf = shapefile.Reader(path_shp_file)

We can list points in shp data

shp = path_sf.shapes()[0]points = shp.pointsprint(points)

Result

[(27.01890117981722, 53.323636127351705), (27.018302950803267, 53.3234231966127),

WE can visualize points using matplotlib library. That’s very simple. Import matplotlib.pyplot

import numpy as npimport matplotlib.pyplot as plt

and visualize point

x = [p[0] for p in points]y = [p[1] for p in points]plt.scatter(x, y)plt.plot(x, y)plt.show()

Result

Sometimes unexpected and strange problems arise when you start using new operating system and know very little about it. Here I will tell about tricky problem I met when using CentOS.

When you click icon Start in the bottom left corner you can observe Lock screen button - first one with lock icon

The problem was that the button stop working — just no action at all.

This was caused by creating a symbolic link python3 to specific version of Python. Apperantly desktop shell of CentOS using Python for some reason.

To solve the problem simply change the symbolic link python3 to previous version of Python

sudo ln -sf /usr/bin/python3.4 /usr/bin/python3

and reboot system.

When working on Flask project we often need a functionality to send emails to users. For instance, when registering user we would like to verify his email address or if a user forgot his password and we need to allow him to reset password.

There is a library Flask-Mail which…

Privalov Vladimir

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store