28. February 2024

qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.

After the installation of QtCreator on Linux you might get following error messag when launching the application:

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

This application failed to start because no Qt platform plugin could be initialized. 
Reinstalling the application may fix this problem.

It is likely one of libraries required by xcb is missing.

To resolve this problem find libxcb.so and run ldd to identify the missing library.

find ~/Qt -name libqxcb.so -exec ldd {} \; | grep "not found"

Install the missing dependency. E.g.:

sudo apt-get install libxcb-cursor0

22. April 2021

How to run Linux GUI application on Windows WSL2 with MobaXterm and Windows Terminal

MobaXterm is a great software that allows running applications from Linux on Windows in a nice integrated way without the need of installing extra XServer.

MobaXterm has also support for WSL2 which makes it easy to launch Linux GUI applications from Linux on Windows.

After installation of Linux distribution like Ubuntu or openSUSE on WSL2, you will find new sessions with the prefix WSL in MobaXterm. Simply click the session label and a new terminal will be automatically configured to talk to the local XServer.

Now you can start any GUI command, e.g. xeyes.

The same XServer from MobaXterm can be used also from other terminals and shells like Windows Terminal. It’s sufficient to export environment variable DISPLAY in the Linux WSL2 session:

export DISPLAY=127.0.0.1:0.0
xeyes

Note: xeyes are part of x11-apps, you can install them by command

sudo apt install x11-apps

19. April 2021

How to do an ICMP ping of a Service in Kubernetes

When moving software to the cloud you may encounter a component that relies on good old ICMP ping.

The problem is that Kubernetes does not support ICMP ping between services. Nigel Poulton described reasons in his post.

But what if the software depends on ICMP ping because it’s hardcoded since days of the pre-cloud era?

One way to solve the problem and make ICMP ping between Service working in Kubernetes is to use the following trick which has two steps:
– open TCP tunnel which forwards a port of service to localhost
– define host alias in /etc/hosts pointing to 127.0.0.1

The trick is based on the simple idea that you can ping localhost and talk to the port with local address which is then forwarded to the desired address.

Commands to add ICMP ping to service “myservice”:

socat tcp-listen:8000,reuseaddr,fork tcp:myservice:8000
echo "127.0.0.1 myservice" >>/etc/hosts

Test:

ping myservice
nc -z myservice 8000

The solution is definitely not 100% bullet-proof, but it can be a good workaround until the software is fixed.

24. March 2021

How to download binary file in Rust by reqwest

reqwest in Rust allows you to download file. The question is how to store the file on the filesystem. There are several examples on the internet where authors are calling .text() which will result in a corrupted file on the filesystem because text() is decoding UTF-8 characters.

Here is an example of how to download a binary file and store content in a file on the local file system.

File download.rs:

use std::io::Cursor;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

async fn fetch_url(url: String, file_name: String) -> Result<()> {
    let response = reqwest::get(url).await?;
    let mut file = std::fs::File::create(file_name)?;
    let mut content =  Cursor::new(response.bytes().await?);
    std::io::copy(&mut content, &mut file)?;
    Ok(())
}

#[tokio::main]
async fn main() {
    fetch_url("https://georgik.rocks/wp-content/uploads/sianim.gif".to_string(), "siriel.gif".to_string()).await.unwrap();
}

File Cargo.toml:

[package]
name = "download"
version = "0.1.0"
authors = ["Georgik.Rocks"]
edition = "2018"

[dependencies]
reqwest = "*"
tokio = { version = "1", features = ["full"] }

[[bin]]
name = "download"
path = "download.rs"

To build the example type following:

cargo run

4. August 2019

How to download invalid or self-signed HTTPS certificate without OpenSSL by using Google Chrome

When you need to acquire a public server certificate in PEM format from a web server and you do not have OpenSSL tools then you can use one “hidden” feature of Google Chrome.

Just open HTTPS URL in Google Chrome. You’ll see an error:

Your connection is not private.
NET::ERR_CERT_COMMON_NAME_INVALID

Do not click on Advanced or Reload.

Just click letters NET::ERR_CERT_COMMON_NAME_INVALID and PEM certificate will appear directly in the browser.

Now you can copy PEM encoded chain and paste it to your text editor.