Skip to content

Instantly share code, notes, and snippets.

View ivankp's full-sized avatar

Ivan Pogrebnyak ivankp

View GitHub Profile
#include <thread>
#include <mutex>
#include <condition_variable>
class worker_thread {
std::thread thread;
std::mutex mx;
std::condition_variable cv;
bool start = false, done = true, stop = false;
public:
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
using std::cout, std::endl;
std::mutex mx_writer;
std::condition_variable
cv_need_to_write,
/* Melbus CDCHGR Emulator
* Program that emulates the MELBUS communication from a CD-changer (CD-CHGR) in a Volvo V70 (HU-xxxx) to enable AUX-input through the 8-pin DIN-contact.
* This setup is using an Arduino Nano 5v clone
*
* The HU enables the CD-CHGR in its source-menue after a successful initialization procedure is accomplished.
* The HU will remove the CD-CHGR everytime the car starts if it wont get an response from CD-CHGR (second init-procedure).
*
* Karl Hagström 2015-11-04
* mod by S. Zeller 2016-03-14
*
@ivankp
ivankp / test_gsl_multifit_linear.c
Last active May 8, 2018 07:24
Test of gsl_multifit_linear chi2
// gcc -Wall -g $^ -o $@ -lm -lgsl -lgslcblas
// https://www.gnu.org/software/gsl/doc/html/lls.html?highlight=gsl_multifit_linear#c.gsl_multifit_linear
#include <math.h>
#include <gsl/gsl_multifit.h>
#define nx 30
#define np 3
@ivankp
ivankp / enum_traits.hh
Created May 4, 2018 17:02
Enum traits library
#ifndef IVANP_ENUM_TRAITS_HH
#define IVANP_ENUM_TRAITS_HH
#include <cstring>
#include <string>
#include <array>
#include <stdexcept>
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/seq/for_each.hpp>