Skip to content

Instantly share code, notes, and snippets.

@IMelker
IMelker / ObjectCounter.h
Created September 23, 2020 08:52
[Cpp] Class counter for object instances by inheritance(gcc)
//
// Created by imelker on 23.09.2020.
//
#ifndef OBJECTCOUNTER_H_
#define OBJECTCOUNTER_H_
#include <cstdio>
#define USE_COUNTER
@IMelker
IMelker / currenttime.hpp
Last active October 22, 2020 08:42
Get current time since epoch
#include <chrono>
#include <iomanip>
template <typename Clock>
class CurrentTime
{
template<struct tm* represent(const time_t *)>
static std::string utc() {
using namespace std::chrono;
auto timer = Clock::to_time_t(Clock::now());
@IMelker
IMelker / scope_exec.hpp
Last active May 17, 2021 06:39
RAI Initializer for C style inits
#ifndef SCOPEEXEC_H_
#define SCOPEEXEC_H_
#include <type_traits>
template <typename OnCreate, typename OnExit, class Enable = void>
class ScopeExec {
using OnCreateResultType = typename std::result_of_t<OnCreate(void)>;
public:
explicit ScopeExec(OnCreate onCreate, OnExit onExit)
@IMelker
IMelker / download_unpack_rpm.sh
Last active January 11, 2022 08:38
Download rpm of exact version from yum and unpack it
#!/bin/bash
BINARY=$1
VER=$2
echo "Find ${BINARY} package with version ${VER}"
RPM_VER=`yum -v list ${BINARY} --show-duplicates | grep ${VER} | grep -oP "${VER}-\w{40}"`
echo "Founded: ${RPM_VER}"
echo "Downloading rpm ${BINARY} with version ${VER}"
@IMelker
IMelker / svn_monit.py
Created December 8, 2022 14:46
SVN updates monitor to discord weboohook
from time import sleep
import requests
import os.path
import sys
import pprint
import svn.local
import svn.remote
@IMelker
IMelker / bitrate_estimator.hpp
Created July 21, 2023 07:42
Bayesian bitrate estimator
#include <cmath>
#define INITIAL_WINDOW_MS 500
#define NONINITIAL_WINDOWS_MS 150
#define UNCERTAINTY_SCALE 10.0f
#define UNCERTAINTY_SYMMETRY_CAP 0.0f
#define ESTIMATE_FLOOR_KBPS 0.0f
class BitrateEstimator {
public: