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()) { } […]
Poireaux à la crème
Ingrédients 800 g de blancs de poireaux 3 jaunes d’oeufs 20 g de farine 20 g de crème fraiche 4 c. à soupe de jus de citron 4 brins de persil 50 g de beurre sel, poivre Préparation Nettoyez les poireaux, coupez-les en deux dans la longueur puis posez en botte sur une planche et […]
Rôti de dindonneau au boursin et poires caramélisées
Ingrédients 1 rôti de dindonneau (ou de dinde) de 1,2 kilo 3 boursins au poivre herbes de Provence 3 cuillères à soupe de crème fraiche épaisse 1 grosse brique de crème entière (33cl) 2 cuillères à soupe de fond de veau 1 boîte de poires William au sirop sucre beurre Préparation Cuire le rôti au […]
C++ Thread synchronization pitfall: using a barrier to synchronize a thread start
Posté par Olivier dans Trucs & Astuces le 20 novembre 2013
The context: You want to create a worker thread. Before the main thread goes on, you want to ensure that the worker thread starts. Using a boost::barrier seems like a good idea.
Installing Google Play enabled firmware on Arnova 7b G3
Posté par Olivier dans Trucs & Astuces le 7 octobre 2013
Some time ago, our daughter bought an Arnova 7b G3 tablet. Although the device is very well done, its primary disadvantage is that it does not include Google Play. As a consequence, it is only possible to install new applications from the rather limited AppsLib. What she wanted was to be able to install applications […]