Vol au vent minute
Ingrédients 400gr de filets de poulet 200gr de haché 300gr de champignons 100ml de lait 50ml de crème fraîche 3 c.a.s de farine fermentante 1 citron épices pour poulet Préparation confectionner de petites boulettes avec le haché découper les filets de poulet en petits dés les déposer dans le plat pour micro-ondes ajouter les épices […]
The Hidden Dangers of std::function and lambdas
Posté par Olivier dans Trucs & Astuces le 30 septembre 2019
Once upon a time, there was an active object which had callbacks using std::function.On the same day, a user of this object registered a callback function which, in its core, cancelled the registration. That callback was a lambda that aside of that took some reference in the current context.And guess what happened ? Here is […]
Making patch files
Posté par Olivier dans Trucs & Astuces le 7 mai 2019
Assume you have a library X, version 1.2.3, extracted in libX-1.2.3/ and that you have to integrate some fix in the build process. You would create a patch file that is applied before building that library. But how do you make the patch files depend on how you apply them. To start, you save the […]
Noix de Saint-Jacques au cidre
Ingrédients 500g de coquilles Saint-Jacques, nettoyées et prêtes à cuire 50g de beurre 2 échalotes hachées menu 40g de farine 150ml de cidre brut 50ml de lait 100g de champignons émincés sel et poivre moulu 250ml de crème fraîche épaisse persil haché pour la garniture Recette Dans le plat Ultra+, mettre le beurre et les échalotes. […]
Panic moments: Ubuntu wouldn’t boot properly after upgrade to Xenial
Posté par Olivier dans Trucs & Astuces le 13 août 2016
Xenial being released for quite some time now, I decided on a sunny Friday afternoon to do the big jump from Trusty to the latest greatest release. Used to the command line, I launch the "do-release-upgrade" command. 1500+ MB of packets to be downloaded, thousands to be upgraded, some new to be installed and about […]
Untabify from the Linux command line
Posté par Olivier dans Trucs & Astuces le 8 décembre 2015
Every now and then, we get some source file that has those nasty relics from a distant path, namely tabs instead of spaces to make indentation. Of course, you can load the affected files one by one in your favorite editor and provided that you can specify some kind of regular expression in a global […]
boost goodie to clamp numbers
Posté par Olivier dans Trucs & Astuces le 10 juin 2015
How do you clamp a number in a given range in C++ ? Classical way to do it is: double clamped = std::min(maxValue, std::max(minValue, value)) But why repeat this magic formula when boost has clamp() for you ? From now on, do: #include double clamped = boost::algorithm::clamp(value, minValue, maxValue)
Namespace, template typedef and operator overloads – The Evil trio
Posté par Olivier dans Trucs & Astuces le 10 juin 2015
What an unconfortable situation ? I had the following code which would not compile. // Range.h #include <boost/numeric/interval.hpp> #include <iostream> namespace App { template <typename T> using Range = boost::numeric::interval<T>; template <typename T> std::ostream& operator<<(std::ostream &os, const Range<T> &r) { … } } // namespace App // Filter.cpp #include "Range.h" #include <iostream> namespace App { […]
Moving an object that wraps a vector and an iterator on that vector
Posté par Olivier dans Trucs & Astuces le 27 août 2014
I recently stumbled upon code that looked very suspicious to me. Basically, it was a class which amongst other things held a vector and some iterators from that vector. Something like this: struct Wrapper { typedef std::vector<int> Data; Data data; Data::iterator active; Wrapper() : data(), active(data.end()) { } […]