Below you can find a list of my blog posts. Some of the most used keywords found in posts:

#snippet 4 #academic 3 #strings 2 #string 2 #counter 1 #ubuntu18 1 #binary-counter 1 #combinations 1 #heap 1 #permutation 1 #xor 1 #xorswap 1 #variables 1 #swapping 1 #32bit 1 #embedded 1 #c 1 #fast-sqrt 1 #sqrt 1 #files 1 #apache2 1 #mysql 1 #cron 1 #bash 1 #backup 1

Latest posts:

These days, while setting up a new server, in the evening, while being a bit tired I mananged to destroy 2 days' work, simply because I had no backup solution installed. Simply not wanting to pay more on a backup solution, since I have a VPS and it's very handy and cheap, I've decided to build my own backup solution, simple, effective and free :) The only things I needed to backup were actual files and some of the MySQL databases. To be able to follow my tutorial 100%, you will need the following:...

These days I needed to implement in an embedded algorithm a simple RMS (Root Mean Squre) calculation over an analog-to-digitally converted signal. My most eager and resource consuming problem was, after the efficient accumulation of data (calculating the sum of squares), I needed to extract the square root. After a couple of Google searches, I found the Newtonian method for calculating the square root pretty effective, and I also found a C-implementation that I'm sharing with you (credits go...

Generating all k-combinations of n elements can be done in various ways. Here I'm preseting to you, for academic purpose, the binary counter method. First of all, let's calculate how many k-combinations of n exists: /* Calculates kCn kCn = n!/(k! * (n-k)!) */ unsigned int total_combinations(int n, int k) { //error if (k > n) { return 0; } unsigned int c = 1; //final result //check which one is greater,...

Generating permutations can sometimes be a difficult task. The number of permutations is given by the factorial of the total number of elements: unsigned int total_permutations(unsigned int n) { unsigned int p = 1; for (int i = 2; i <= n; i++) { p *= i; } return p; } The function above only works to a n of about 12 on 32bit machines before the result exceeds that. So for n equals 12 we have about 479.001.600!!! permutations possible. For sure, that takes a lot of time to process. Anyhow,...

While not recommeded to be used in modern programming, this simple method allows swapping the values of 2 variables without the need of the third. Some caution should be taken into consideration, because this method works as long as both the variables that needed to be swapped are different (read: occupy different memory). void xorSwap(int *a, int *b) { *a = *a ^ *b; *b = *b ^ *a; *a = *a ^ *b; } This is the simplest variant of the xorSwap. Several...