Installing Code::Blocks on Linux Mint

Check what version of Mint you have:

cat /etc/debian_version

This should be Buster for the following to work. If you are on Stretch, please refer to: https://wxstuff.xaviou.fr/article/debian-repository.html

Import repository key:

wget -O- https://apt.xaviou.fr/key.asc | sudo apt-key add -

Create repository list:

sudo vi /etc/apt/sources.list.d/codeblocks.list

And insert following text:

deb https://apt.xaviou.fr/stable/ buster main
deb-src https://apt.xaviou.fr/stable/ buster main

Update your installation

sudo apt-get update

Now you are ready to install Code::Blocks from the packet manager or from the command line.

sudo apt-get install codeblocks

Tinkering on what happened in 2019

2019 was a great year for the internet, but some elements are worry-some

Tim Berners-Lee launched the contract for the web. A good initiative. Certainly an answer to what happened with some big companies wanting to take control:

HTTPS everywhere – great for privacy. Downsides: most proxies are broken, network acceleration is back to basics widening the gap in between the western countries and third world countries. How are corporate firewalls handling it? Most of the time, there is no need to deliver data over HTTPS except for a single reason, privacy. Why in a hell is firefox showing a broken lock when a site is not HTTPS. It should be more like a spying eye. Please let users decide whether or not they want privacy. Anyway, as long as we do not control the keystore, there is no privacy.

Facebook stance on privacy. 2019 was the beginning of the fall of facebook. It will either be broken up or people will start to understand how it is abusing your data.

The demise of windows. Even on Azure, now there are more linux installations than windows installations. Only a few years keep us apart from an opensource windows for the public and a closed source version for the enterprise.

Do-not-track. Honestly, I do not understand why we need this. If I go to a web-site, I want content of this web-site. I do not want publicity, nor any other content that is not delivered from other sources as the one on the website. It is time for browsers to block all content from other sources than the URL we just typed in the address bar. The do-not-track would not be required.

WWW has to go. Honestly, I do not understand why we need this. As a sideline, some browsers will not show the parameters in the address bar unless I select it. People already do not understand how a browser works, so why hiding some of its core concepts? Goal, take the hand of your user so you can guide him/her to where you want. This lets me think of the early Microsoft that thought you, nobody will ever need HTML 4 as majority of users stick to 3.2, lets remove it from Internet Explorer Mac so we can force users to silverlight.
For those that do not understand, www is great for routing. A company might have multiple servers, such as mail, webmail, intranet, application1, ftp, … and then a also a server servicing www content.

DNS over HTTP. What the heck is going on? Why would we ever need this? Answer: you certainly can read the reasoning from those promoting it. Until all browsers, phones, operating systems, … will adopt it, it will create a dual speed internet. In the mean time, all those applications that are on iOS or play store will start to function differently than the google browser. (Yes, I should sell this idea to google, great way to force users to come back to them.)

HSTS. What the heck is going on? Why would we ever need this? After the history of certificates, green ‘costly’ certificates, demoting self signed certificates, now the browser is storing DNS entries and caching not only web-content but also web routing. Bye bye accelerating the web and imposing a new cache hell to web-developers.

Huawei gets blocked for the false reason. Why are other countries following suit? Where are the proofs? The US has been caught multiple times in spying, creating backdoors, tampering the BGP routes, imposing operators or the Swift network to spy into their systems, yet we are not blocking Cisco, Facebook, …. because of … maybe the US is not involved in any wars while the others are. This is all a huge lie.

Edward Snowden and Julian Assange. The last part of demonizing those that want the truth to be told and lies to be revealed. Poor guys who dared to tell the public what for large parts we knew already.

QUIC – (aka HTTP/3) a proprietary protocol by Google that wants you to use UDP for content streaming just like audio streaming. They only talk about the benefits. There are several downsides to it: it cannot be cached, if bundled with SSL, how are corporate firewalls going to handle it? It also adds complexity because retransmission is handled by the application and no longer by the network layer. In essence, it makes browsers bigger and more complex just for the interest of some of the big players such as Facebook and Google.

Blocking certain countries to access open source repositories such as sourceforge or github? Who is deciding what? Who is the bad guy and who is the good guy? Its like saying, lets starve a population to death because we don’t like its leaders.

Privacy as a technology concept or privacy by human rights

There are some legitimate reasons why we want to intercept privacy. I give some examples: parents controlling their children, networks that block bad content, companies wanting to protect their interests, countries that want to apply their legislation.

We should not give the right to big companies to control your content and at the same time propose solutions that make controlling by the one who is entitled to control impossible. Putting new protocols in place because you do not agree with what certain governments are doing is not the right thing to do.

Protocols are open and should be easily adopted by all players of the market. Yes, one can develop and propose an enhancement, but being a major player in the market does not mean that you are allowed to impose your choices. Please play it nice. It is not because there are bad offenders in the world that you should become a bad offender of a different kind.

Bash tricks

Colouring grep output, modifying welcome message.

Reference on colours.

Some ways to do it

grep --color=always
grep --color -E 'pattern|$' file
grep --color 'pattern\|$' file
egrep --color 'pattern|$' file
export GREP_OPTIONS='--color=always' 

Alternatively, use ack. No file required, recursive by default.

ack -i pattern

The ultimate solution, use ack --cathy! Do not forget to install it first.

sudo apt-get install ack

Hardware information

Interesting article can be found here.

In summary, following commands will give you interesting details:

inxi -Fxz
lshw -short
lshw -C cpu
lspci -v -s 00:02.0
dmidecode -t memory
lshw -short -C memory

Upgrade MySQL from 5.1 to 5.5 on CentOS 6.x

Check installed version of mysql

rpm -qa | grep mysql

Enable the remi repository by modifying the enabled flag in the repo file:

vi /etc/yum.repos.d/remi.repo

After that, perform upgrade and verify new version. (several methods included below…)

yum -y update mysql*
rpm -qa | grep mysql
mysql --version
mysql -u root -p


Using PhpMyAdmin to administer a remote server

Imagine the following set-up:

Local machine with Debian 9/10, or Ubuntu, or Linux Mint.

Local machine with MySQL server (which would be MariaDB in this case) and with PhpMyAdmin. One can access http://localhost/phpmyadmin.

In order to access a remote server, we need to do the following:

sudo vi /etc/phpmyadmin/config.inc.php

Add following lines at the end:

$i++;
$cfg['Servers'][$i]['host'] = '10.10.10.11';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'rootpassword';
$cfg['Servers'][$i]['auth_type'] = 'config';

In case you want to provide a default language, add following after the blowfish section:

$cfg['Lang'] = 'en';

(I didn’t see any useful improvement in putting this, just mention it for those that want their server to behave independently of their locale setting.)

On the remote server, you will need to allow the root user to connect and to open the firewall port on 3306. Please modify the network segment from which remote access is allowed and the rootpassword in below script to suit your configuration.

Script for CentOS 6.x

iptables -A INPUT -i eth0 -p tcp -s 192.168.0.0/24 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'rootpassword';

In case you want to connect to a remote server with MySQL< 5.5, you will have to do an upgrade to version 5.5. Otherwise, the latest phpMyAdmin won’t connect. See separate post.

C++ rant

Please consider the following standard C++ program.

#include <iostream>
using namespace std;
main(){
  cout << "Hello, World!";
  return 0;
}

What is wrong with this?

  1. ¬†include statement: we are including a header or a piece of source code, why isn’t it called iostream.h?
  2. using namespace std: if standard, it could be omitted and considered standard because it has not been mentioned.
  3. main function: why there are no parameters in it
  4. return statement: do we assume the function has been defined as int….

Ideal version, in my opinion…. but opinions are subjective

#include <iostream.h>

int main(int argc, char *argv[], char *env[]){
  cout << "Hello, World!";
  return 0;
}