Binary search algorithm, find the index of a given key

It’s been a while since I’ve been writing on the blog, so I’ve decided to start being more active and since it’s been almost 15 years since I’ve studied this in University, it can also be a good refreshment course for me as well as anyone else looking into refreshing their memory or learning.

Binary search is a very useful algorithm, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array.

Site to site with OpenVPN with TLS and FirewallD on Debian

So I needed to setup a site to site transport between our two datacenters, so our internal network will be able to communicate between the two datacenters easily.

There are a lot of ways to setup site to site VPN link between two networks, in our case let’s take a look at one way using OpenVPN.

This is quite long tutorial so get yourself a bit comfortable so we can get started.

Confirm before executing shutdown/reboot command on linux

I was rushing to leave and was still logged into a server so I wanted to shutdown my laptop, but what I didn’t notice is that I was still connected to the remote server. Luckily before pressing enter I noticed I’m not on my machine but on a remote server. So I was thinking there should be a very easy way to prevent it from happening again, to me or to anyone else.

Compiling Redis Desktop Manager on Debian

So I’ve used redis desktop manager in the past, but suddenly I can’t use it anymore it’s not compiling on debian, and there are no packages for the application. So I decided to find a way to to compile it on my machine, which uses Debian Stretch.

Codility - OddOccurrencesInArray

A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.

Codility - CyclicRotation

A zero-indexed array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is also moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7]. The goal is to rotate array A K times; that is, each element of A will be shifted to the right by K indexes.