marcelpetrick
Retrospective view at 2018
The first month of 2019 already passed. And we passed it with flying colors!
But let’s have a look at 2018 – a year full of challenges and success: I’ve worked full-time, organized and participated in advanced courses for Python and in Requirements Engineering (officially: IREB Requirements Engineering Foundation Level-approved) and pursued a new employment as software engineer.
And I wrote some software in my spare-time, as you can see in the graph for the public github-repositories. The gaps in the commits can be explained with the birth of my daughter and the time where I acquired the new job and moved nearly 900 km across the country. Yay! Nice personal projects were and are Cullendula and the Daily Coding Challenges, which I solve mostly with fully Unit-tested Python (3).
More new, hands-on knowledge was gained in the area of CMake and Qt-charts.
Well – 2018 was great. Let me make 2019 greater! 💪
Pick a random reviewer
Most teams have a certain code-review-process. But most of the time there is no “round robin”-implementation who will be the reviewer, but the coder itself should select the reviewer. Because of domain-knowledge, etc. And then you her lots of times “I am currently busy. Not me!”
Solution: random and fair selection via bash.
1 2 3 4 5 6 7 8 |
#!/bin/bash # initialize the array array=(MSA MBH HGA GSC MPE NLE RNI MLA) size=${#array[@]} index=$(($RANDOM % $size)) echo "Mister ${array[$index]} is your candidate as reviewer. Congratulations!" echo "In case you picked yourself - just rerun ;))" |
Current version of the script can be found at: https://github.com/marcelpetrick/bashCollection/blob/master/randomReviewer.sh
Inspired by a stack-overflow answer.
find the fattest files of certain type
1 |
$ find . -name "*.LSimg" -exec ls -al {} \; | sort -nr -k5 >> listOfFattestFiles.txt |
creates something like
1 2 3 4 |
-rw-r--r-- 1 mpe 1049089 323707001 Mai 29 2018 ./a.LSimg -rw-r--r-- 1 mpe 1049089 21342433 Mai 29 2018 ./b/c.LSimg -rw-r--r-- 1 mpe 1049089 21342432 Mai 29 2018 ./e.LSimg .. |
Fixing ~crappy~ no-good Qt-includes
How to locate all includes of that style:
1 |
#include <QtWidgets/qcombobox.h> |
with proper
1 |
#include <QtWidgets/QComboBox> |
Fired up https://regex101.com/ and set it to PHP and created an expression, which matches:
starting with slash, then a q, then characters, then . then h
1 |
\/[qQ][a-zA-Z]+\.h |
(Replace & check has to be done by YOU ;))
Fix whitespace
Sometimes there is too much whitespace and tabs in my last commit.
In former times I used a VisualStudio-plugin, but this is not helpful there. So I wrote a small script (see on my github) which:
• replaces all tabs with four spaces
• removes all trailing whitespace
• converts line-endings to CRLF
I invoke it on the list of all changes files in my last commit in the git-repo with:
1 |
$ git diff --name-only HEAD~1 HEAD | xargs -L1 ../removeTrailing.sh |
(first part gives you a list of changed files and then feeds it to the script for execution)
Overview of author-activities for the git-repo
If some ‘sophisiticated’ tool like git-stats is too cumbersome to configure, just do some git-log and shell-magic:
1 2 3 4 5 6 7 |
$ git log --format='%aN' | sort | uniq -c | sort 4 Hans Wurst 6 Klaus Blume 6 Bernd Meier 26 Marcel Petrick 32 Ali Baba 37 Linus Torvalds |
Ok, just noticed that git has something built-in:
1 |
$ git shortlog -sn |
from: https://coderwall.com/p/pek-yg/git-statistics-for-repo-per-author – Thanks Marcin Olichwirowicz!
Enable Profiling on Windows even with Meltdown-patches
1 2 |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverride /t REG_DWORD /d 3 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverrideMask /t REG_DWORD /d 3 /f |
Helped with Visual Studio 2015. Should also work for 2013 and 2017.
Cppdepend: measure defects (code smells), cyclomatic complexity …
As every one knows: I am a fan of objective measurements in the quality and quantity of code. Another nice statistics-generator for such a task is: cppdepend (trial is free for the first month).
It can detect some mistakes and deviations from common coding guidelines (like MISRA) and supports your judgment with some figures.
Cullendula for instance has the estimated development effort of 13 days (right now, v0.4.1) and a technical debt-rating of A. Which is great! 🙂
Qt5: connect: How to use ‘connect’ in case the slot has less parameters than the signal
Task is to connect from one signal with one parameter to a slot with zero parameters. With the “old” Qt4-way of connect it works like this
1 |
connect(object1, SIGNAL(signal(int param)), object2, SLOT(slot())) |
But what if I want to use the type-safe Qt5-connects?
The documentation just mentions the cases with:
* connect to default parameters in slot
* and (for example) using the above-mentioned way of the string-based connect.
My idea was to use a lambda to fix this:
1 |
connect(object1, &Object1::signal, [this](int) { slot(); } ); |
But it turned out in in this thread that
1 |
connect(&object1, &ClassObject1::signal, &object2, &ClassObject2::slot); |
is possible! 🙂
new section: page for “TIL – today I learned”
TIL or real post? Questions over questions.
Sometimes some newly acquired enlightenment is too “small” or my new knowledge is just the start for the future journey. Or just some news.
Then I think that a full fledged post is a bit “breaking a butterfly on a wheel”. Therefore I introduced the page: TIL – today I learned.
*tadaa*