C++

“If Microsoft ever does applications for Linux it means I’ve won.”

Written by  on September 23, 2016

~ Linus Torvalds

I’ve given Visual Studio Code for Linux as prebuilt rpm-package a try. I don’t know what I expected ten minutes ago, but I am definitely under-whelmed! Another editor with syntax-highlighting, code-completion, integrated git-support and the ability to add “extensions” for all kinds of stuff. But: do I miss the trick or how do I start build binaries? (edith: possible via some “we need another build-configuration-system..”-JSON).

vscode

OK, it was fun to test, but now back to my favorite IDE* ๐Ÿ˜‰ gedit & gcc on the terminal can do the same, so I don’t see any reason to use VS Code.ย  Maybe for Go or one of the other languages, but not C++.

*QtCreator

aseprite: how to build @ Linux

Written by  on August 31, 2016

What should i say? I was searching for a more sophisticated GIF-editor to create more smooth animation-loops. Then I saw aseprite. Binaries require “donation”, so why not build it yourself since it is OSS? Sadly there were no clear official hints on how to build on Linux.
Turns out this guide is giving the correct directions:

Estimate quickly the ‘size’ of the project

Written by  on August 9, 2016

Nothing in comparison to SLOCCount or other tools, but sometimes you just need a ‘value‘ ๐Ÿ˜‰


103 ./main.cpp
90 ./map.cpp
35 ./map.h
63 ./mapitem.cpp
29 ./mapitem.h
122 ./mapprocessor.cpp
27 ./mapprocessor.h
79 ./mapreader.cpp
23 ./mapreader.h
571 total

edith 20160819: sort the result before counting for a much nicer appearance ๐Ÿ˜‰

C/C++-comments

Written by  on July 13, 2016

One of my heroes (Linus Torvalds) published some days ago some rant about the “correct” style of comments.
Honestly, I agree 100%! And from my POV his version c is my preferred one: for single lines and blocks of comments.

(c)
// This can be a single line. Or many. Your choice.

Had some severe discussions about this topic in past dev-teams while negotiation some “best practices/style-guide”.

Reasons:
* you can quickly comment/uncomment sections of code without worrying where the “begin” and where the “end” is
* if you used /* .. */ then “uncommenting” could result in commenting something else, because of nested comment-parts
* only drawback: comments last until the end of the line

QtScrobbler (final cut)

Written by  on October 22, 2015

Just to close the topic: I finished what I planned for the forked QtScrobbler-project. I changed the workflow, so that if you did not provide correct credentials for your favourite submission-site (last.fm, libre.fm ..), then the progress-dialog will be closed and you will see immediately the error in the ui (not just log). Because before the user could wait until the cows come home – and I found this really annoying, especially when I set up QtScrobbler on a new system, mistyped or forgot to set the credentials at all.
Besides: also cleaned the code a little bit with the help of cppcheck ๐Ÿ˜‰

The repository: https://github.com/marcelpetrick/QTScrobbler

All in all it was a nice experience: set up GitHub, clone the repository, work into a medium large project, try to fix an error without breaking the remaining functionality ..
I do not fully agree to the original code of conduct for style and includes. But as long as it is comprehensive ..

cppcheck pt. II

Written by  on October 4, 2015

It’s quite funny if you want to use the current version of your favorite static code analysis-tool, then realize that no OS-binary is availabe, then think “why not create it yourself like you did it with older versions?” (qmake && make ..), then realize your current clang-version does not support the missing c++11-features (cbegin/cend), then you realize you are not allowed upgrade your local compiler ..

To put it in a nutshell:

Yes, this leaves you without the gui, but still better than nothing.

side note: I also found the cppcheck-plugin for QtCreator-project on sourceforge (new since august 2015?), but since the contributor provides just Win and Linux binaries, but neither source nor OSX-binaries, I have to wait. But looks promising.

edit 20151005:
Only fifteen hours after my request the russian mastermind behind the project built an OSX-dylib for the cppcheck-plugin and offered it to me for testing. After update from QtCreator 3.42 to 3.5, copying the plugin, activating it and setting the path to the homebrew-1.70-cppcheck, everything works! No more switching between the cppcheck-output and QtCreator, just fix the issues! *feels good*

QtC_cppcheck

edit 20151006:
Now it is officially available. Enjoy!

My first (?) offical fork?

Written by  on October 2, 2015

I want to fix several smaller, but annoying issues with QtScrobbler. Originally hosted on sourceforge, but development was discontinued in 2013. I mean: it worked. I used it for years with my upgraded SANSA clips.
So I forked the project to github, upgraded the whole project to the current Qt-version (5.5) and fixed immediately some ‘klein-klein’. But now I am too tired …

Simple grid-layouter

Written by  on September 22, 2015

How to layout a given number of thumbnails N of picW x picH into m columns and n rows in a given page (pageW x pageH) so that the “to be applied” scale is maximal? All thumbnails yield the same dimensions, reordering is not allowed, rotation neither. If the chosen scale is maximized, then the result will have the biggest possible thumbnails. I need this for the contactSheet-script, because currently it uses fixed column-sizes and I don’t want to figure this out manually each time the wanted page- or thumbnail-size or the amount of thumbnails changes.

layout

I am aware, that this is some kind of well known bin-packing problem, but just after implementing the very first naive approach I figured out that there is maybe(?) no closed equation possible: just iterating over all possible cases. Maybe I missed something, but the current approach would look like the following. I will move this from C++/Qt to sh soon, because this will become part of contactSheet-script which I apply to every set of scanned film ๐Ÿ˜‰

By the way: the sketch has been done with draw.io, because I stopped using Dia

Qt: normalized signal-slot-connections

Written by  on July 13, 2015

While writing my last post I remembered a tool I run at least once for every project I touch (do, finish, ..): ‘normalize’.
Originally I stumbled about it while reading Marc Mutz’ blog. The downside is: currently the original download-location is not available anymore .. I will try to fix this.

The effect behind normalised signal-slot-connections is that for the whole project every connect will use the same style. No additional whitespace, no const, no unneeded variable-names, .. perfect.
Invoke it with “normalize –modify PROJECTPATH”. Without the flag it will just show the “to be changed sections”.
Never seen any downside effects.

edit: Working download-URL added!

part II: Remove multiple whitespace-lines from a file

Written by  on May 7, 2015

I was so annoyed that the simple idea with sed did not worked like I wanted, that I wrote a short full-fledged Qt-appp for it. Code follows. Just compile the main.cpp. Usage is also explained in the header of the file.
I know it’s like to break a butterfly on a wheel, but I need this functionality since I don’t want to do such a boring task like code-styling by myself ..

Update: first version had a small glitch! Found after applying it to some bigger files.