Skip to content

Instantly share code, notes, and snippets.

View sigman78's full-sized avatar

sigman sigman78

View GitHub Profile
@sigman78
sigman78 / opnsense-to-truenas-acme-cert.md
Last active December 20, 2025 04:56
Instructions how to automate OpnSense -> TrueNas (CE) ACME certificate propagation

Prerequisites

ACME plugin is set and configuted @ opnsense to acquire SSL cert

Instructions

TrueNas

  • Create user 'certdeploy' with home directory (i.e. /mnt/tank/home/certdeploy)
  • Give necessary permissions to run midclt
  • Upload script ui-cert-deploy.sh to certdeploy home directory, give exec permissions
@sigman78
sigman78 / setup-truenas-ui-cert.sh
Created December 20, 2025 04:41
Script to setup SSL cert files to TrueNas, assign to GUI and restart it
#!/bin/sh
set -eu
# Usage:
# opnsense-ui-cert.sh /path/to/fullchain.pem /path/to/privkey.pem [name_prefix]
#
# Example:
# opnsense-ui-cert.sh /mnt/tank/certs/opnsense-ui/fullchain.pem /mnt/tank/certs/opnsense-ui/privkey.pem opnsense_ui
FULLCHAIN="${1:-}"
@sigman78
sigman78 / concat.cpp
Last active January 17, 2024 23:43
custom concat for strings and string_views
#include <iostream>
#include <string>
#include <string_view>
namespace impl {
template<typename T>
concept StringLike = requires(T t) {
{ t.data() } -> std::convertible_to<const char*>;
{ t.size() } -> std::convertible_to<std::size_t>;
template<typename T> struct type_id_impl {
static int* loc() {
static int i;
return &i;
}
}
template<typename T> type_id_t type_id() {
return (type_id_t)&type_id_impl<T>::loc;
}

Using O2D to Program Duck PCBs

Special Thanks to KacKLaPPen23 and iNViSiBiLiTi for making this guide possible and being generally excellent people!

Programming Duck PCBs with O2D is a notoriously shitty experience.

Luckily with O2D 1.10 and this guide it will be less shitty!

Prerequisites

@sigman78
sigman78 / strong.cpp
Created September 28, 2021 19:26
Strongeesh typedefs in C++17
#include <iostream>
struct UserName { std::string name; };
struct Password { std::string pwd; };
template<typename T>
auto peek(const T& packed) {
static_assert(std::is_aggregate_v<T>, "Should be struct");
// we can further enforce T to have single field with
const auto& [value] = packed;
@sigman78
sigman78 / constexpr_tuple.cpp
Created September 19, 2019 09:26
easy tuple on variadics
#include <utility>
#include <cstdio>
template <typename ... Ts>
constexpr auto tuple(Ts&& ... ts)
{
return [...ts = std::forward<Ts>(ts)](auto&& f) { return f(ts...);};
}
template <unsigned I, typename T, typename ... Ts>
@sigman78
sigman78 / rethrow.cpp
Created August 16, 2019 17:08
nested exceptions abuse
#include <exception>
#include <stdexcept>
#include <cstdio>
#include <sstream>
#include <iostream>
template<class Ctx, class...Args>
void rethrow(Ctx&& context, Args&&... args)
{
// build an error message
@sigman78
sigman78 / cstr.h
Created May 16, 2019 14:39
constexpr cstr mockup
constexpr const char* end_of(const char* s) {
while (*s != 0) ++s;
return s;
}
struct cstr {
const char* b_;
const char* e_;
constexpr cstr(const char* s)
@sigman78
sigman78 / float_opt.cpp
Created May 7, 2019 12:18
Draft of optional{float} for safe nan usage
#include <cmath>
#include <limits>
struct float_opt
{
float value_ = std::numeric_limits<float>::quiet_NaN();
explicit float_opt(float v): value_(v) {}
constexpr float_opt() = default;