Skip to content

Instantly share code, notes, and snippets.

View palacaze's full-sized avatar

Pierre-Antoine Lacaze palacaze

View GitHub Profile
@palacaze
palacaze / container.hpp
Created April 21, 2022 09:32
Container utilities
#pragma once
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <numeric>
#include <utility>
#include <vector>
/**
@palacaze
palacaze / make-appimage.sh
Created November 19, 2021 10:00
build an appimage
#!/usr/bin/env bash
# Dir of the script
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd - P)"
readonly dist_dir="${script_dir}/../dist"
# Source common options to tweak the script
user_config_file="${script_dir}/foo-buildenv.conf"
if [[ -f "${user_config_file}" ]]; then
source "${user_config_file}"
@palacaze
palacaze / tcp-reader.cpp
Last active April 20, 2021 21:53
Async Tcp reader base class
#include <string_view>
#include <pal/core/cast.hpp>
#include <pal/core/print-helpers.hpp>
#include <pal/core/container/container.hpp>
#include "tcp-reader.hpp"
namespace pal::tcp {
Reader::Reader(const std::string &name, Config conf)
: m_logger{log::get(name)}
@palacaze
palacaze / interrupt-handler.hpp
Last active November 2, 2023 21:10
C++ Interrupt handler using ASIO
#pragma once
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
#include <asio.hpp>
#include <asio/signal_set.hpp>
namespace system {
@palacaze
palacaze / set.hpp
Last active June 25, 2021 15:24
A set based on a sorted vector
#pragma once
#include <algorithm>
#include <functional>
#include <vector>
namespace pal {
template <typename Key,
typename Compare = std::less<Key>,
typename Allocator = std::allocator<Key>>
@palacaze
palacaze / variant-fsm.cpp
Created February 25, 2021 10:04
Variant based state machine
// state machine that handes processing of data
struct Fetch {};
struct Stop {};
struct StartProcessing {
SamplePtr sample;
};
struct WaitProcessed {
SamplePtr sample;
std::string json_path;
};
@palacaze
palacaze / make-debian-iso.sh
Created February 25, 2021 08:28
A script to create a preseeded Debian ISO
#!/bin/bash
# This script creates a Preseeded Debian buster ISO installer.
# The preseeded file must have been filled beforehand.
debian_iso_url="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.4.0-amd64-netinst.iso"
debian_preseed_cfg="$(dirname "$0")/debian-buster-preseed.cfg"
debian_iso_file="$(basename ${debian_iso_url})"
debian_iso_preseeded="preseeded-${debian_iso_file}"
@palacaze
palacaze / sh
Last active December 21, 2015 14:55
emerge packages with gentoo as a user in any dir
#!/usr/bin/env sh
# destination directory
DIR=/home/pal/code/deps/clang
# clang as default compiler
CC=clang CXX=clang++ \
PORTAGE_TMPDIR=$DIR/var/tmp \
EMERGE_LOGDIR=$DIR/var/log \
PORT_LOGDIR=$DIR/var/log/portage \