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

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;
}

 

Hotspot detection

How to set-up hotspot.

Firefox URL: http://detectportal.firefox.com/success.txt

Google Chrome URL: connectivitycheck.gstatic.com/generate_204

Edge URL:

Internet Explorer URL:

Opera URL:

Chomium URL: chrome.google.com

Dolphin URL: