Skip to content

Instantly share code, notes, and snippets.

@tautologicc
tautologicc / coro.c
Last active December 18, 2022 02:50
Reentrant coroutines in C, using Duff's device
#include <stdio.h>
// Adapted from https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
#define CORO_BEGIN(state) \
switch (*(state)) { \
case 0:
#define CORO_YIELD(state, value) \
do { \
@tautologicc
tautologicc / pre.css
Created January 15, 2023 16:41
Simple presentations in HTML
.slide {
border: 1px solid currentColor;
break-before: always;
display: flex;
flex-direction: column-reverse;
margin-bottom: 3rem;
margin-top: 3rem;
max-width: 35rem;
padding: 3rem;
}
@tautologicc
tautologicc / git-bump
Last active August 6, 2023 01:36
Bump a project version.
#!/bin/sh
# git-bump <command> - bump a project version
USAGE="[init|major|minor|patch|premajor|preminor|prepatch]"
SUBDIRECTORY_OK=1
. "$(git --exec-path)/git-sh-setup"
set -eu
<!DOCTYPE html>
<html lang="pt">
<title>Flordle</title>
<style>
:root {
--cell-size: 64px;
--cell-gap: 8px;
}
*,
@tautologicc
tautologicc / wb_alloc.h
Created September 22, 2023 18:43 — forked from WilliamBundy/wb_alloc.h
A single-file header allocation library for C (probably bugs out in C++, sorry)
/* This is free and unencumbered software released into the public domain. */
/* Check the bottom of this file for the remainder of the unlicense */
/* wb_alloc.h
*
* Three custom allocators that can (hopefully) safely allocate a very large
* amount of memory for you. Check the warnings below for an explanation
*
* Version 0.0.1 Testing Alpha
*/
@tautologicc
tautologicc / apihash.c
Created October 4, 2023 00:47 — forked from rad9800/apihash.c
Using macros and constexpr to make API hashing a bit more friendly
#include <Windows.h>
#include <winternl.h>
#pragma comment(linker, "/ENTRY:entry")
// Define hashing algorithm to use
#define HASHALGO HashStringDjb2
// Define how large you'd like cache to be
#define CACHE 50
@tautologicc
tautologicc / gui.md
Created October 4, 2023 15:44 — forked from vurtun/gui.md

Graphical User Interfaces

For the last few weeks I spend some time coding, writing and cleaning up my notes from almost a year since I published nuklear.

Basically this is a possible implementation for a graphical user interface builder backend with support for an immediate mode style API. So it provides a way to define non-mutating UI state, an immediate mode style API for dynamic UI components (lists,trees,...) and a combination of both.

The core implementation is ~800 LOC without any kind of default widgets or extensions. At first this seems quite counter intuitive. However since the inherent design allows for lots of different ways to define any widget like buttons it does not make sense to provide a specific default implementation. The way this code was architectured furthermore removes the need for style/skinning configurations used in Nuklear since widget painting is just calling a small

Graphical User Interfaces

Last time I wrote a little bit about my current GUI research progress. There are some things that were misunderstood so I want to clarify some fundamental design decisions and finally write up some current problems and their solutions.

First up I want to clarify a component is not another term for what is usually refered to as widget. Instead wigets in this implementation are made out of n >= 1 components. Components themself are just rectangles with attributes left, right, top, bottom, center_x, center_y, width and height some behavior flags and an optional surface to draw into. For example a scroll regions is made up out of at least three

@tautologicc
tautologicc / api.txt
Created November 18, 2023 21:14 — forked from pervognsen/api.txt
This is a brief comment on this article on API design principles:
https://gist.github.com/vurtun/192cac1f1818417d7b4067d60e4fe921
I've called that style of API a coroutine, iterator, state machine, push/pull or client/server API
depending on what seems most appropriate for the context, but they are all variants of the same idea.
It's particularly superior in many cases as an alternative to callback-based APIs, which are the more
common way of providing this kind of fine-grained interleaving between library code and user code.
Callbacks can still be superior in usability for context-free operations like memory allocation,

API Design: Coroutines APIs (Janurary-2017)

I am currently dealing with a lot of libraries at work. Both third party as well as libraries written or being currently in process of being written by me. I absolutely love writing and working with libraries. Especially if they present or bring me to either a new or different approach to solve a problem. Or at least provide a different view.

Over time I noticed however that quite regulary we had to decide that we cannot use a third party library. Often it is the usual reason.