Skip to content

Instantly share code, notes, and snippets.

@royratcliffe
royratcliffe / va.h
Last active May 9, 2026 09:37
va-nargs
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: 2026, Roy Ratcliffe, Northumberland, United Kingdom
*/
/*!
* \file va.h
* \brief Header file for variadic argument counting macros.
* \details This file contains macros for counting the number of variadic
* arguments passed to a macro. It can count up to 63 arguments and returns the
# Download LVGL library using FetchContent (after project declaration)
# See https://lvgl.io/docs/open/7.11/porting/project for more details on integrating LVGL into a project
include(FetchContent)
FetchContent_Declare(lvgl
GIT_REPOSITORY https://github.com/lvgl/lvgl.git
GIT_TAG master # or specify a specific tag or commit
)
FetchContent_MakeAvailable(lvgl)
math.randomseed(os.time() + os.clock() * 100000)
--- Performs an in-place Fisher-Yates shuffle on the given array.
-- This function implements the Fisher-Yates shuffle algorithm.
-- It randomly shuffles the elements of the array in place, ensuring
-- that each permutation of the array is equally likely.
-- @tparam {[number]=any} arr The array to shuffle.
function fisher_yates_shuffle(arr)
-- No need to shuffle if the array has less than 2 elements.
if #arr < 2 then return end
FROM mcr.microsoft.com/devcontainers/base:noble
# The Microsoft dev container automatically makes the user `vscode`.
#
# ``` bash
# vscode ➜ ~ $ id
# uid=1000(vscode) gid=1000(vscode) groups=1000(vscode)
# ```
#
USER vscode
@royratcliffe
royratcliffe / 80-can.link
Last active April 29, 2026 11:56
raspberrypi
@royratcliffe
royratcliffe / Kbuild
Last active June 3, 2025 12:32
kbuild
obj-m += foo.o
@royratcliffe
royratcliffe / 80-can.link
Last active January 12, 2026 11:50
Infineon AURIX
@royratcliffe
royratcliffe / .gitignore
Last active February 13, 2026 18:16
Python
# Ignore Python virtual environment directories.
/.venv/
cmake_minimum_required(VERSION 3.25)
project(polyinterp)
add_executable(polyinterp polyinterp.cpp)
@royratcliffe
royratcliffe / uniq.lua
Last active April 28, 2024 15:42
Unique Lua Pairs
--- Unique pairs.
-- @module uniq
-- @author Roy Ratcliffe <roy@ratcliffe.me>
-- @copyright 2023, 2024
-- @license MIT
local _M = {}
local unpack = table.unpack or unpack -- Lua 5.1 compatibility
--- Answers the next index and unique value.
-- See [Semantics of the Generic `for`](https://www.lua.org/pil/7.2.html) for