Author Archives: dmitriano

Switching to PHP 7.4 on Ubuntu 16.04

Some WordPress plugins stopped working with PHP 7.0 on my Ubuntu 16.04 server and I switched to PHP 7.4 with the following commands:

sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
sudo apt-get update
sudo apt-get install php7.4 php7.4-fpm php7.4-cli php7.4-mysql php7.4-dom php7.4-mbstring -y
service php7.4-fpm status
cd /etc/php/7.4/fpm/pool.d
sudo mv www.conf www.conf.dist
sudo mv ../../../7.0/fpm/pool.d/devnote.conf .
sudo service php7.0-fpm reload
sudo service php7.4-fpm reload
(more…)

An example of how r-value reference works in C++

An example of extending the lifetime of a temporary:

#include <iostream>

int main()
{
    int a = 1;
    int&& b = std::move(a);
    int&& c = b + 1;

    b = b + 1;
    c = c + 1;

    std::cout << a << b << c;
}

The output is:

223
(more…)

QObject::sender() is a slow function

I did not expect that its share of CPU usage in my app is 12.15%:

Why does it iterate over some collection? Isn’t there only one sender in a thread?

(more…)

Building QT 6.3.1 with OpenSSL for Windows

After various experimentation I was able to build QT 6.3.1 with OpenSSL for Windows with the following steps:

Extract archives with Bash:

tar -xzf ../distrib/openssl-1.1.1q.tar.gz
tar -xf ../distrib/qt-everywhere-src-6.3.1.tar.xz

Building OpenSSL 1.1.1q

Run the following commands with x64 Native Tools Command Prompt for VS 2022:

set PATH=%PATH%;C:\dev\PFiles\Strawberry\perl\bin
set PATH=%PATH%;C:\dev\PFiles\nasm-2.15.05
perl Configure VC-WIN64A
(more…)

Experimentation with OpenSSL and QT configuration on Windows

Building OpenSSL 1.1.1q with custom installation directory

Run the following commands with x64 Native Tools Command Prompt for VS 2022:

set PATH=%PATH%;C:\dev\PFiles\Strawberry\perl\bin
set PATH=%PATH%;C:\dev\PFiles\nasm-2.15.05
set MY_INSTALL_DIR=C:/dev/libs/OpenSSL
perl Configure VC-WIN64A --prefix="%MY_INSTALL_DIR%" --openssldir="%MY_INSTALL_DIR%"
(more…)

Mining NEOXA on HiveOS with 3GB cards

The key to the success in mining NEOXA on HiveOS is knowing pool parameters that can be stratum+tcp://minenice.newpool.pw:1120, for example:

(more…)

Handling messages from Binance Websocket streams

User Data Stream

To subscribe I query listen key:

POST /api/v3/userDataStream

connect to websocket wss://stream.binance.com:9443/stream and send the listen key with the following message :

{
    "id": 1,
    "method": "SUBSCRIBE",
    "params": [
        "<my listen key>"
    ]
}

When Binance accepts the subscription it sends:

{
    "id": 1,
    "result": null
}
(more…)

Using std::future as a coroutine in C++20

In C++20 it is possible to do this:

std::future<int> compute(as_coroutine) {
  int a = co_await std::async([] { return 6; });
  int b = co_await std::async([] { return 7; });
  co_return a * b;
}
 
std::future<void> fail(as_coroutine) {
  throw std::runtime_error("bleah");
  co_return;
}
 
int main() {
  std::cout << compute({}).get() << '\n';
 
  try {
    fail({}).get();
  } catch (const std::runtime_error &e) {
    std::cout << "error: " << e.what() << '\n';
  }
}
(more…)

Switching to a different thread with async/await in C#

The code below switches to a different thread when the execution of Main() is resumed at line 11:

internal class Program
{
    static async Task Main(string[] args)
    {
        try
        {
            HttpClient client = new HttpClient();

            Console.WriteLine($"Thread: {Thread.CurrentThread.ManagedThreadId}");
                
            HttpResponseMessage response = await client.GetAsync("https://developernote.com/");

            Console.WriteLine($"Thread: {Thread.CurrentThread.ManagedThreadId}");

            response.EnsureSuccessStatusCode();

            string responseBody = await response.Content.ReadAsStringAsync();

            Console.WriteLine($"Thread: {Thread.CurrentThread.ManagedThreadId}");

            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine("\nException Caught!");

            Console.WriteLine($"Thread: {Thread.CurrentThread.ManagedThreadId}");

            Console.WriteLine($"Message: {e.Message}");
        }
    }
}
(more…)

My experimentation with QML Repeater

I was able to define a Repeater that displays cryptocurrency market orders:

(more…)