HiveOS Web UI has Setup Minder Config button where I selected X16Rv2 algorithm for T-Rex miner:
(more…)Accessing a service credentials on Windows 10
I worked on some Windows app that registers a Windows service with a C++ code like this:
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, _T(SERVICE_NAME),
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RPCSS\0"), user_name, password);
where user_name and password are strings that are provided by the app user during the app install. Assuming the service name is MyService this creates a registry key HKEY_LOCAL_MACHINE\SECURITY\Policy\Secrets\_SC_MyService that is hidden by default and even administrator does not have a permission to read it and regedit does not show the content of HKEY_LOCAL_MACHINE\SECURITY key by default. But fortunately the access can be allowed by right clicking on HKEY_LOCAL_MACHINE\SECURITY and selecting Permissions or alternatively by running
Enable-TSDuplicateToken
in PowerShell. To list the content of the key I used the following command:
dir HKLM:\SECURITY\Policy\Secrets\_SC_MyService
My Android QT app crashes at qt_qFindChild_helper.
I have an Android QT app with more than has 14K active users at the moment of writing this post. The app is relatively stable, its crash rate is 0.34%:
(more…)Binding Docker container ports to the host on Ubuntu 18.04 inside Hyper-V on Windows 10
The binding did not work for me until I switched from Internal Virtual Switch to External Virtual Switch and while switching I were getting the following error:
[Window Title]
Virtual Switch Manager for MY-MACHINE
[Main Instruction]
Error applying Virtual Switch Properties changes
[Content]
Failed while adding virtual Ethernet switch connections.
[Expanded Information]
External Ethernet adapter 'Realtek PCIe GBE Family Controller' is already bound to the Microsoft Virtual Switch protocol.
until I switched Hyper-V Extensible Virtual Switch off on my network adapter properties page (after I created External Virtual Switch it switched on back):
(more…)Scanning the disk and testing the memory on Windows 10 PC.
My Windows 10 PC started to glitch a little bit and I scanned its disks with the following commands:
chkdsk C: /f /r /x
The type of the file system is NTFS.
Cannot lock current drive.
Chkdsk cannot run because the volume is in use by another
process. Would you like to schedule this volume to be
checked the next time the system restarts? (Y/N) y
This volume will be checked the next time the system restarts.
Measuring SQLite insertion performance with C++ code
I did a quick Google search on “SQLite performance” and found the following:
- What are the performance characteristics of sqlite with very large database files? (The performance degrades significantly when the database size riches 7GB).
- Some Russian article on habr.com. (To boost the insertion we insert by batches in a separate transactions, set synchronization mode to OFF or NORMAL and probably disable indices).
- Some old article on Database Speed Comparison.
- Appropriate Uses For SQLite (An SQLite database is limited in size to 140 terabytes)
- Faster bulk inserts in sqlite3? (You can also try tweaking a few parameters to get extra speed out of it. Specifically you probably want PRAGMA synchronous = OFF;)
- A trivial C++ example.
Then to benchmark SQLite performance by myself I used the following C++ code that inserts 1000 batches of 1000 000 rows to a single table with an integer primary key:
(more…)Adding interstitial ads to a QT application on Android platform
I keep working on my Lines Game and probably I try to make it the best Lines Game in the world, but there is some disappointing incident that prevents it from being the best and makes it a usual game that glitches a bit. To see the glitch in action download the beta version of the game.
Adding Interstitial Ads to a QT application on Android platform is an interesting and relatively exciting job. I learned the following facts while doing it:
- To build my app with Google Play Services I add com.google.android.gms:play-services-ads:18.1.1 dependency to build.gradle and add com.google.android.gms.version and com.google.android.gms.ads.APPLICATION_ID to the manifest.
- I do not specify additional permissions (uses-permission attributes INTERNET, WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE) required by ads, but they are detected automatically when I upload the app to Google Play store and the used is not prompted to allow them when the app starts.
- QT main thread (on which QML UI is run) is not Android UI thread. So I cannot call Java advertising API from QML or C++ directly, but all the calls should be queued with runOnUiThread method.
- To access Context required by Java advertising API I replace QtActivity with my own custom activity that implements all the advertising logic and forwards all the lifecycle events to original QtActivity.
- When the interstitial ad is open my activity is paused and stopped (onPaused / onStopped event handlers are called in Java and onApplicationStateChanged with Qt::ApplicationInactive / Qt::ApplicationSuspended respectively ) and when the interstitial ad is closed my activity is resumed but in different ways either with onRestart.
Updating my Google Play app settings.
I switched the advertising on at Store Presence->Pricing & Distribution page:
(more…)Parsing GUID in C++ with a regular expression
The code below demonstrates how to parse GUID in C++ using a regular expression:
#include <iostream>
#include <string>
#include <regex>
int main()
{
static const std::wregex regex(L"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
std::wstring sample = L"850fe1da-0ea6-c1a8-9810-0c1cece30698";
std::match_results<std::wstring::const_iterator> match;
if (std::regex_match(sample, match, regex))
{
std::wcout << L"matches" << std::endl;
}
else
{
std::wcout << L"does not match" << std::endl;
}
return 0;
}
A simple example demonstrating how std::forward works in C++
For example, std::forward comes to play if I implement a template container with two ‘insert‘ function overloads that take the parameters of type const T & and T && respectively. I implement all the private insertion logic with T&&, but when I need to know the original value type passed to ‘insert‘ method I use std::forward as shown in the example below:
#include <iostream>
#include <string>
class Value
{
public:
Value(const char * sz) : m_s(sz)
{
}
Value(const Value & other) : m_s(other.m_s)
{
std::cout << "copy constructor: " << m_s << std::endl;
}
Value(Value && other) : m_s(std::move(other.m_s))
{
std::cout << "move constructor: " << m_s << std::endl;
}
const std::string & ToString() const
{
return m_s;
}
private:
std::string m_s;
};