Category Archives: Programming

UI, UX and how users see world

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

[Java] regular expression to match emails and domains works with gTLD

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:

^[A-Za-z0-9][A-Za-z0-9/.-]*\.*[A-Za-z]$

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

[A-Za-z0-9-+/.]*@^[A-Za-z0-9][A-Za-z0-9/.-]*\.*[A-Za-z]$

Code to test those regexpes:

package regexp;
 
import java.util.ArrayList;
 
public class RegExpMatcher {
 
    public static void main(String[] args) {
        ArrayList domains = new ArrayList<>();
        domains.add("site.international");
        domains.add("site.international.com");
        domains.add("site.ac.uk");
        domains.add("site.org");
        domains.add("site.babia-gora.pl");
        domains.add("site.pl");
 
        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;();
        emails.add("info9@agilob.net");
        emails.add("in-fo@site.international");
        emails.add("in.fo@site.ac.uk");
        emails.add("in+fo@site.babia-gora.pl");
        emails.add("1in-+fo2@site.babia-gora.pl");
 
        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");
            }
        }
    }
}

Output:

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

Simple random password generator in bash

One liner:

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

function in .bashrc:

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

Continue reading

Transparent, dynamically generated from text tray icon in Qt and C++

[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);
 
    painter.setFont(font);
 
    QString theText = "3"; // this will be the text in the system tray icon
    painter.drawText(QPoint(5, size+1), theText);
 
    QSystemTrayIcon *tray = new QSystemTrayIcon();
    tray->setIcon(QIcon(pixmap));
    tray->show();
 
    return app.exec();
}

Continue reading

Solution to SQLException: No suitable driver found for jdbc:mysql

Just a quick fix.

Instead of:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
con = DriverManager.getConnection(url, user, password);

You should have:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
 
try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
    System.err.println(ex.getMessage());
}
con = DriverManager.getConnection(url, user, password);

Continue reading

[Prolog] Logical Voting Assistant

I had to write a voting assistant in Prolog as a part of my module – AI.  I really enjoyed programming in Prolog and you can see my code in its repository.

The code is fully documented and it shouldn’t be hard to follow. It was my first application in Prolog, so don’t be mad at me when you see some crap there…

Continue reading

AberPizza in Java

AberPizza – simple cash register for small pizzerias. Application made as a first year, second semester assignment.

Application has a built-in database of products and prices, can add those product to an order, give discount in GBP or in percentage of the whole order.

Bills are stored in XML files and can be loaded into the application to print receipt.

Continue reading

WordLadder generator/finder

I had to write this application as a university project.

The task was to generate a word ladder, which starts and ends on provided words. Both words have to be in a dictionary.

Every single step in the ladder must only differ in one character from the word before. The aim of the word-ladder is to find the shortest path from start word to end word in the whole graph.

Continue reading