Sometimes in working on your projects you need to undone some unwanted commits made to master branch. I will show how to do it with GitLab repo.

If you follow regular workflow with git reset to reset to some commit

git reset --hard <commit_hash>
git clean -f -d

and then force push to master to reflect changes on remote repo

git push -f origin main

you can get error

remote: GitLab: You are not allowed to force push code to a protected branch on this project.To! [remote rejected] main -> main (pre-receive hook declined)error: failed to push some refs to ''

You need to obtain rights to force push to protected branch.

If you are maintainer go to Settings > Repository. Expand Protected branches, find master branch in list and move switch for option Allowed to force push

Thats it.



Sometimes we need to save some webpage. Standard way is to copy url and title (some main header) of webpage.

We can automate it and make our life easier. Use Copy page title and url extension for Chrome.

Just install it from Chrome store.

Then click right button on some page you need to save and choose option Copy page title and url marked by the icon of extension.

Both url and title will be copied to clipboard as one string.



Sometimes developers need to explore some JSON files. That can be quite tough and time comsuming. We can do it easier with command line tool jq.

First install it:

sudo apt updatesudo apt install -y jq

Run command:

jq '.' result.json

Result will be pretty nice looking



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;





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;