Thursday 10 October 2019

Getting along with qwt on Qt

Smooth experience with Qwt on Windows with Visual Studio.
  1. Build qwt on Windows: https://www.qtcentre.org/threads/66576-Installing-Qwt-with-MSVC-2015-64bit-compiler-on-Windows-(complete-instructions) — that works on VS-2019 as well.
  2. You will need QtDesigner with VS. Install a plugin: copy from qwt-6.1.4\plugins\designer\ to qt\5.13.1\msvc2017_64\plugins\designer\. Run qt\5.13.1\msvc2017_64\bin\designer.exe and see this at Help → About Plugins:
  3. You also need a plugin at QtCreator. It is a 32-bit app :( So you compile qwt for 32-bit, keep it fully separately from 64-bit one (i.e. unzip your qwt downloadable to a separate folder again, name it qwt-x86-6.1.4). Copy qwt-x86-6.1.4/plugins/designer/qwt_designer_plugin.dll to qt/Tools/QtCreator/bin/plugins/designer. Create a Widget application, go to a form and find this in the panel:
  4. Create a VS Qt project, then export a QtCreator project from it. Use both.

Friday 4 October 2019

Initialization in modern C++

Initialization in C++ is unreasonably hard. There are 19 ways to initialize an int, leading to quite different results depending on the case. Copying initialization is a bogus. Move semantics makes all that ever more harder: https://www.youtube.com/watch?v=PNRju6_yn3o.

There are improvements coming in C++20 though: https://habr.com/ru/company/jugru/blog/469465/ related to homogenizing curly-braced and parenthesis initializations. This funny stuff is also fixed: https://youtu.be/AgatxxXNwBM?t=390 (in a funny way as well).

My own rule of thumb so far:
  • always avoid copy initialization,
  • use curly-braced initialization everywhere,
  • don't use parenthesis initialization.
That shall remain even with the coming of (args) and {args} homogenization in C++20, as {} prevents narrowing conversions which you usually don't want.

Saturday 28 September 2019

C++ craftsman named arguments

We try to compensate for lack on named arguments in so many ways. Check one the lastest takes on a subject: https://www.youtube.com/watch?v=Grveezn0zhUCppCon 2018: Richard Powell “Named Arguments from Scratch”. The recent C++20 "designated initialization" doesn't help much, as you must remember the order of fields as declared in a corresponding struct. Other people try things around it, as well, such as calling functions using curly syntax: https://www.youtube.com/watch?v=L8eeDzTWEtU, or allowing default parameters in the middle of args list https://github.com/joboccara/Defaulted. So, there's a lot, and more: https://www.codeproject.com/Articles/1171605/Named-Cpp-Function-Parameters , https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/ etc.

But let's pull back. What if:

Monday 5 November 2018

USPTO patent filing

This link worked well for me: https://patentfile.org/filing-provisional-patent-at-uspto/. No account is required. Prepare $280 to pay one-time fee. Don't forget to save all the receipts during the process.

Sunday 28 October 2018

Hyper-V Ubuntu Enhanced Session — actually make it work

The typical situation is that after entering your creds for xorg session you only see a teal screen, and nothing else happens. In short — turn off autologin for your user, and the enhanced sessions will start to work. Oh my had I spent a time searching for a solution, surprisingly found it on youtube: https://www.youtube.com/watch?v=oPHqoLbNTP8. Just watch.

Also check this https://www.frodehus.dev/resize-disk-for-ubuntu-hyper-v-quick-create-image/ for disk sizes. And this: https://www.youtube.com/watch?v=pY9x9wx9mb4 for vm-tools.

Tuesday 9 October 2018

Chrome Plugins 101

1. Print innerHTML every 3 seconds

manifest.json

{
  "manifest_version": 2,
  "name": "Try me",
  "version": "0.3",
  "permissions": [
    "<all_urls>"
  ],
  "content_scripts": [{
    "js": [ "content-script.js" ],
    "all_frames": true,
    "run_at": "document_end",
    "matches": ["<all_urls>"]
  }]
}

content-script.js

window.setInterval(function() {
  alert(document.getElementsByTagName('html')[0].innerHTML);
}, 3000);

Monday 8 October 2018