Skip to content

Instantly share code, notes, and snippets.

View fbaeuerlein's full-sized avatar

Florian Bäuerlein fbaeuerlein

  • Freelancing Software Developer
  • Bavaria, Germany
View GitHub Profile
@fbaeuerlein
fbaeuerlein / .clang-format
Last active September 4, 2020 07:40
My favorite .clang-format settings
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
@fbaeuerlein
fbaeuerlein / .clang-tidy
Last active June 9, 2024 10:52
A general clang-tidy configuration file
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,-modernize-use-trailing-return-type'
WarningsAsErrors: true
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: google
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
@fbaeuerlein
fbaeuerlein / thermal_fit.py
Created May 27, 2019 07:11
Python fitting of Steinhart-Hart equation for thermal resistors (returns the temperature for specified resistance)
# Details:
# https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation
# https://de.wikipedia.org/wiki/Steinhart-Hart-Gleichung
# Fitting of the four coefficient equation
import csv
import numpy
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
@fbaeuerlein
fbaeuerlein / exprtk_sprintf.cpp
Last active February 11, 2019 19:53
adding sprintf to exprTK for number to string conversion and formatting
#include <string>
#include <cassert>
#include <iostream>
#include "exprtk/exprtk.hpp"
/**
* @brief class containig a generic funtion for formatting numbers with snprintf
*
* Uses the igeneric_function overload for strings
@fbaeuerlein
fbaeuerlein / config_example.cpp
Last active February 11, 2019 19:55
Config-Class that supports adding of config item member functions during compile time with macros and uses C++ member initialization order to read and release the document on construction
#include <iostream>
#include <string>
// uses the initialization ordering of c++ to construct members, based on previously created member (document)
// that will be released within the constructor body
// http://en.cppreference.com/w/cpp/language/initializer_list
// this is what should be released after initialization was done
@fbaeuerlein
fbaeuerlein / normal_distribution_density.cpp
Created March 12, 2014 09:38
calculate normal distribution density for n-dimensional eigen covariance matrix or scalar
template<size_t Dimension>
const double normalDistributionDensity(const Eigen::Matrix<double, Dimension, Dimension> & cov,
const Eigen::Matrix<double, Dimension, 1> & mu, const Eigen::Matrix<double, Dimension, 1> & x )
{
const Eigen::Matrix<double, Dimension, 1> d = mu - x;
// calculate exponent
const double e = -0.5 * d.transpose() * cov.inverse() * d;
// get normal distribution value
@fbaeuerlein
fbaeuerlein / time_measurement.cpp
Created March 12, 2014 09:36
scope guard like class for measuring duration (from construction to destruction)
#include <boost/chrono/chrono_io.hpp>
class MeasureDuration
{
public:
MeasureDuration(const std::string & name = "unknown" )
{
_duration = 0;
_name = name;
@fbaeuerlein
fbaeuerlein / Lemon_min_cost_flow_circulation.cpp
Last active June 18, 2019 16:01
Solve the min cost flow circulation problem with Lemon CycleCanceling
#include <lemon/smart_graph.h>
#include <lemon/lgf_reader.h>
#include <lemon/lgf_writer.h>
#include <lemon/list_graph.h>
#include <lemon/cycle_canceling.h>
#include <lemon/preflow.h>
using namespace lemon;
typedef ListDigraph Graph;
@fbaeuerlein
fbaeuerlein / Lemon_Preflow.cpp
Last active March 31, 2017 08:56
Solving the Maximum Flow Problem with LEMON Preflow Algorithm
#include <lemon/smart_graph.h>
#include <lemon/lgf_reader.h>
#include <lemon/lgf_writer.h>
#include <lemon/list_graph.h>
#include <lemon/cycle_canceling.h>
#include <lemon/preflow.h>
using namespace lemon;
typedef ListDigraph Graph;