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

Tuesday 27 March 2018

Change an author of the last commit in both origin and remote

Only if it isn't too late ;)

git commit --amend --author "John Doe <john.doe@protonmail.ch>" --no-edit
git push origin <your_branch_name> --force