I saw such question on SO. There was no solution with RegEx so… I was bored I think.

public static boolean isValid(String ip) {
    boolean isvalid;
    isvalid = ip.matches(
            "(([0-9]|[0-9]{0,2}|1[0-9]*{0,2}|2[0-5][0-5]|0{0,3}).){3}" +
    return isvalid;

Continue reading

You can work with SQL queries in Qt and SQL in many different ways, here I will show you how I came up with a working method. To keep things simple, I am not going to use any UI to print or edit queries. It will be just source code and stdout, as a database engine I will use SQLite3.

After you created your project, edit project.pro and locate line:

QT       += core

Modify this line by adding `sql`:

QT       += core sql

Since now, when you compile your project, QtSql module will be linked to the project:

g++ -Wl,-O1 -Wl,-O1,--sort-common,--as-needed,-z,relro -o QtSql main.o   -lQt5Sql -lQt5Core -lpthread

Continue reading

This blog is also available in .onion domain. Both blogs have different databases, DB users and passwords, different WordPress configurations, and as a result, they have different data in DB column.

After publishing a new post here, I do not want to manually copy posts from here to there and I want images from b.agilob.net to be available in .onion to avoid any clearnet connections. To do so, the content of each post must be scanned for ‘/‘ and this string must be replaced with ‘http://agiloblulimjeqlq.onion/‘.

Continue reading

There are two ways to set clan as your default compiler in Qt-Creator. One way will set LLVM as default in Qt-Creator for you only and the other one will set LLVM as default for your project, so everyone cloning/forking your repo will use clang too. If you want clang as default only for you, go in Qt-Creator to Tools -> Options -> Build & Run -> Kits select your default kit, I have `Desktop` and set Compiler to CLang. Continue reading

Just a simple tutorial to show you how to add static code analysis plugin in QtCreator on Liunx.
Start by downloading plugin dedicated to QtCreator from here.

Unpack .zip and you will get two directories which you have to copy to /usr/lib/qtcreator/plugins/. You can copy only libQtcCppcheck.so, if you don’t need Russian translation.

cp lib/qtcreator/plugins/libQtcCppcheck.so /usr/lib/qtcreator/plugins/

Continue reading

Factors Measured in Usability Testing

The most common factors measured in usability testing include:

  • Effectiveness: a user’s ability to successfully use a website to find information and/or accomplish tasks
  • Efficiency: a user’s ability to quickly accomplish tasks with ease and without frustration
  • Satisfaction: how satisfied the user is with site
  • Error frequency and severity: how often users make errors while using the system, how serious the errors are, and how users recover from the errors
  • Memorability: a user’s ability to remember enough to use the site effectively after his or her first visit

Continue reading

Recently we got many new top-level domains like .international, .berlin etc, so older regular expressions are no longer valid.
Below you can see a list of valid domains; an address may contain . (dot), – (minus) and .subdomain (domain may contain many sub-domains). A domain must end with a letter, it cannot be . (dot) or a number.

  • site.international
  • site.international.com
  • site.ac.uk
  • site.org
  • site.babia-gora.pl
  • site.pl

Email address may contain a delimiter like – or + and . (dot), it might contain numbers and for sure contain letters. Below is a list of valid email addresses:

  • info9@agilob.net
  • in-fo@site.international
  • in.fo@site.ac.uk
  • in+fo@site.babia-gora.pl
  • 1in-+fo2@site.babia-gora.pl

A regular expression to match gTLD domains can look like this:


and regular expression to match emails in domains above like this:


Code to test those regexpes:

package regexp;
import java.util.ArrayList;
public class RegExpMatcher {
    public static void main(String[] args) {
        ArrayList domains = new ArrayList<>();
        boolean matches;
        System.out.println("Matching domains: ");
        for (int i = 0; i < domains.size(); i++) {
            matches = domains.get(i).matches("^[A-Za-z0-9][A-Za-z0-9.-]*\.*[A-Za-z]$");
            if (matches == true) {
                System.out.println(domains.get(i) + " matches");
            } else {
                System.err.println(domains.get(i) + " doesn't match");
        System.out.println("nnMatching email addresses: ");
        ArrayList emails = new ArrayList&lt;&gt;();
        for (int i = 0; i < emails.size(); i++) {
            matches = emails.get(i).matches("[A-Za-z0-9-+.]*@[A-Za-z0-9][A-Za-z0-9.-]*\.*[A-Za-z]$");
            if (matches == true) {
                System.out.println(emails.get(i) + " matches");
            } else {
                System.err.println(emails.get(i) + " doesn't match");


Matching domains: 
site.international matches
site.international.com matches
site.ac.uk matches
site.org matches
site.babia-gora.pl matches
site.pl matches

Matching email addresses: 
info9@agilob.net matches
in-fo@site.international matches
in.fo@site.ac.uk matches
in+fo@site.babia-gora.pl matches
1in-+fo2@site.babia-gora.pl matches

One liner:

pass=`cat /dev/urandom | head -2 | tr -cd 'a-zA-Z0-9!@#$%^&*()_+-=][';/.,'`; echo ${pass:4:30}

function in .bashrc:

    password=`cat /dev/urandom | head -2 | tr -cd 'a-zA-Z0-9!@#$%^&*()_+-=][';/.,'`;
    echo ${password:4:30}

Continue reading

[Qt C++] – Transparent, dynamically generated from text tray icon

#include <QApplication>
#include <QSystemTrayIcon>
#include <QPixmap>
#include <QPainter>
#include <QFont>
int main(int argc, char *argv[])
    QApplication app(argc, argv);
    QPixmap pixmap(20, 20); // small size should work fine on every platform
    pixmap.fill(Qt::transparent); // set transparency of the icon
    QPainter painter(&pixmap);
    int size = 15;  // size 15 looks nice on KDE and GNOME
    QFont font("", size);
    QString theText = "3"; // this will be the text in the system tray icon
    painter.drawText(QPoint(5, size+1), theText);
    QSystemTrayIcon *tray = new QSystemTrayIcon();
    return app.exec();

Continue reading