Skip to content

Instantly share code, notes, and snippets.

#include <cstdint>
#include <fmt/format.h>
int main()
{
union {
uint32_t i;
uint8_t a[4];
struct { uint32_t lsb:6, m:20, msb:6; } b;
};
@xentec
xentec / enum.hpp
Last active October 4, 2017 07:02
#pragma once
#include <optional>
#include <map>
/*
#define <GENERATOR>(XX) \
XX(OK, 0) \
XX(ERROR, 1) \
XX(..., ...) \
#!/bin/sh -e
for DEV; do true; done # get last argument
TMPDIR="$(mktemp -d "/mnt/$(basename "$DEV").XXXX")"
mount $* "$TMPDIR"
echo "Mounting $DEV on $TMPDIR"
(cd "$TMPDIR" && su "$SUDO_USER")
@xentec
xentec / caman.cpp
Last active June 5, 2018 21:31
Quick & Dirty™ tool to manage a certificate authority
// Compile with
// c++ caman.cpp -o caman -std=c++17 -O3 -I/usr/include/botan-2/ -lbotan-2 -lstdc++fs
/* Use like
* caman example.org # generate 'example.org' cert authority
* caman example.org www mail # generate certs for {www,mail}.example.org
* caman example.org legacy/a:RSA:2048 # a RSA cert for legacy.example.org
* caman example.org uk.example.net/c:UK # certs for foreign TLD
* caman example.org highend/a:Ed25519/h:SHA-3(512)/d:2y
*/
diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index 4ba13f8bf6..80bcb150eb 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -357,9 +357,10 @@ package() {
rm -f "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi*
find "$pkgdir" -name 'ffi*.h' | xargs rm -f
- mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/lib
- mv "$pkgdir"/usr/lib/*-gdb.py \
@xentec
xentec / setup-cross-cc.sh
Last active February 6, 2025 19:49
Alpine Linux cross-compiler setup script
#!/bin/sh
CTARGET="$1"
if [ -z "$CTARGET" ]; then
program=$(basename $0)
echo "usage: $program TARGET_ARCH"
return 1
fi
# get abuild configurables
From c728af08c9321f1a0618674e462adc8e96327370 Mon Sep 17 00:00:00 2001
From: xentec <[email protected]>
Date: Sat, 11 Feb 2017 15:00:43 +0000
Subject: [PATCH 1/2] main/libasr: replace res_randomid() impl. with call to
arc4random() from libcrypto
Fixes recursive call loop which causes a stack overflow in opensmtpd.
---
main/libasr/00-use-openbsd-res_randomid.patch | 953 ---------------------
main/libasr/0001-Fix-NETDB_SUCCESS-value.patch | 25 +
diff --git a/abuild.in b/abuild.in
index f56ac03..b7e3dcc 100644
--- a/abuild.in
+++ b/abuild.in
@@ -1048,7 +1048,7 @@ trace_apk_deps() {
case "$parch" in
$CBUILD_ARCH) ;;
- $CARCH | $CTARGET_ARCH) apkroot="--root $CBUILDROOT" ;;
+ $CARCH | $CTARGET_ARCH) apkroot="--root $CBUILDROOT --arch $CTARGET_ARCH" ;;

Keybase proof

I hereby claim:

  • I am xentec on github.
  • I am xentec (https://keybase.io/xentec) on keybase.
  • I have a public key whose fingerprint is 33DA 03D6 EFDF 5269 0D81 D9E2 0561 CC35 E802 CB0E

To claim this, I am signing this object:

#include <functional>
#include <stack>
struct Scope
{
using Callback = std::function<void()>;
Scope() = default;
Scope(Callback cb)
{