Skip to content

Instantly share code, notes, and snippets.

View DBJDBJ's full-sized avatar
😬
Can't stop coding

dbj DBJDBJ

😬
Can't stop coding
View GitHub Profile
@DBJDBJ
DBJDBJ / intentional_api.md
Last active April 18, 2026 15:59
Intentional API

Intentional API

It's not a formally defined spec or standard — it's a design philosophy Kelsey Hightower champions, borrowed from intent-based networking (Cisco, etc.) and applied to APIs and infrastructure.

The core idea: you declare what you want, not how to get it. The system figures out the path.

Kubernetes is the canonical example — you declare desired state, the control loop reconciles reality to match it. You never say "start container on node X, then update the load balancer" — you say "I want 3 replicas of this."

Contrast with imperative APIs: "do this, then that, then handle this error case." Intent-based APIs absorb the operational complexity on the platform side.

@DBJDBJ
DBJDBJ / dbj_type_reductor.h
Last active August 19, 2025 01:55
c++ Type confusion stopper. A.k.a -- Reduce compound type to base type
// (c) 2019/2020 by dbj@dbj.org
// CC BY SA 4.0
//
// https://wandbox.org/permlink/h8BE47pvLlBMy7wy
// clang++ prog.cc -std=c++14
// OK for C++14, C++17, C++2a
//
// https://dbj.org/c-reduce-compound-to-base-type/
//
#include <iostream>
@DBJDBJ
DBJDBJ / dbj_defer_begin_end.h
Last active March 8, 2025 09:31
Defer and Begin/End. For any C version. With Gobolt demo and proof of concept.
#ifndef DBJ_DEFER_BEGIN_END_H
#define DBJ_DEFER_BEGIN_END_H
/*
comment this in to see the demo
#define DBJ_DEFER_BEGIN_END_DEMO 1
*/
/*
2025-MAR dbj@dbj.org https://godbolt.org/z/adYP4ach4
first seen it here https://youtu.be/QpAhX-gsHMs
/*
This is benchmarking of a collection of matrix multiplication algorithms.
Algorithms are kept as simple as possible. No structs are passed as arguments.
No "clever" "generic" matrix macros are used
Different compilers multiplied with different platforms multiplied selection
of data types yield a complex picture of benchmarking results.
Although here is strong hint for you: The simplest algorithm is the fastest.
@DBJDBJ
DBJDBJ / powerof.hta
Last active May 19, 2024 03:50
POWEROF.HTA
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
removing this makes HTA:APPLICATION fully functional
meta http-equiv="X-UA-Compatible" content="IE=edge"
to be tested ...
-->
@DBJDBJ
DBJDBJ / clean_all_the_linked_in_connections.md
Last active December 16, 2022 18:16
Clean All Your Linked IN Connections With A Script

Very big Warning:

If you do not know (or have a faintest clue) what is "Chrome Dev Console" please do not attempt deleting your LinkedIN connections using the script presented here.

Please consider purchasing a very powerfull but user friendly LINKED IN HELPER.

Or find a friend who can understand this text. Or just give up until you do. If not sure what are you doing here, please do not try on your own, anything described. Just leave.

Script to delete ALL connections on your LinkedIN account

@DBJDBJ
DBJDBJ / slab_and_handle.c
Last active September 17, 2022 21:47
https://stackoverflow.com/a/73755385/10870835 -- do not pass structs by value or by pointer
/*
(c) 2022 by dbj@dbj.org CC BY SA 4.0
Godbolt: https://godbolt.org/z/ne579e85f
The point is here we do not use naked pointer to pass the structs arround
we use handles to the preallocated slabs of the same struct
thus we do not suffer the perenial modern C dilema: should we pass the
structs by value or as pointers to them.
@DBJDBJ
DBJDBJ / modern_matrix
Last active November 18, 2021 16:56
Very simple but light and probably fast 2D array. C++17. Version 6. Types left in here, from std lib are in just for testing code. Used Visual Studio 2019 and clang-cl .
#define DBJ_MTX_TESTING
// (c) 2019-2021 by dbj@dbj.org
// License: CC BY SA 4.0
#include <assert.h>
#include <stdlib.h>
#include <string.h> // memcpy
namespace dbj::mtx {
@DBJDBJ
DBJDBJ / mohapatra_matrix_multiplication.h
Created September 10, 2021 06:23
mohapatra_matrix_multiplication transformed to ISO C
/*
made 2021 by dbj@dbj.org
https://godbolt.org/z/PjovPPoxf
*/
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define FOR(C, R) for (unsigned C = 0; C < R; ++C)
@DBJDBJ
DBJDBJ / dbj_strcmp.c
Created August 7, 2021 15:47
DBJ ISO C STRING COMPARE
// ----------------------------------------------
// (c) 2021 by dbj@dbj.org
// https://dbj.org/license_dbj
// https://godbolt.org/z/vaMMrvM85
// ----------------------------------------------
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>