Skip to content

Instantly share code, notes, and snippets.

@uucidl
uucidl / test_metal_with_sdl2.c
Created November 11, 2018 21:42
Testing metal on my macs. My dear Mac Mini does not support it
#include "SDL2.framework/Headers/SDL.h"
#define sdl2_guard(__expr) \
if ((__expr) != 0) { \
fprintf(stderr, "SDL Error: '%s'\n", SDL_GetError()); \
assert(0); \
}
#include <assert.h>
@uucidl
uucidl / traverse_children.ion
Last active December 9, 2018 09:48
Traversing Hierarchies
// Depth first traversal algorithm.
//
// (credit to Alexander Stepanov in Elements Of Programming)
//
// One of the benefits is that the visitor can implement pre or post traversal algorithms, and combine them in one single piece.
//
// @generic in T, the node value type
func traverse_children_recursively(tree_root: T*, step_visitor: func(step: TraversalStep, node: T*))
{
step_visitor(TraversalStep_PRE, tree_root);
@uucidl
uucidl / ibbq-thermometer-protocol.md
Last active December 1, 2024 13:57
ibbq-thermometer-protocol

Example devices

  • Inkbird IBT-2X
  • Inkbird IBT-4XS
  • EasyBBQ FCCID: FCC ID 2AI4MPRO3 (SHENZHEN HYPERSYNES CO.,LTD Smart Wireless Thermometer PRO3)

Properties

  • @ConnectTimeout: 60 seconds
  • @BatteryPollingInterval: 5 minutes

The iBBQ is a Bluetooth LE Gatt Device

@uucidl
uucidl / bitwise-notes-62.md
Created February 20, 2019 10:24
bitwise-notes.md

Bitwise Day 62: Indexed Arrays

Per worked 20h since Day 61.

How do we get a good story for dynamic arrays? What we called stretchy bufs (buf_... API)

Added many new intrinsics to gen_intrinsic:

  • apush, kadd, kdget, kdel
  • hget, hdel
@uucidl
uucidl / compilation_times.md
Last active May 8, 2025 14:49
Notes about compilation time

When building programs with user interfaces*, there are parts that cannot be tested formally with either types or automated tests, because they require a human to test how things "feel."

In that context, long compile times lengthen the build-evaluate feedback loop to a point that harms quality.

  • also note that APIs are user interfaces. So this harms way more than just programs with GUIs.

@url: https://www.youtube.com/watch?v=dnz6y5U0tFs Here he find it normal to build 1M loc of scheme code in 16minutes. "respectable compile time" (It used to be 4min!)

@url: tool by Aras https://github.com/aras-p/ClangBuildAnalyzer

@uucidl
uucidl / wm.el
Created April 5, 2020 09:12 — forked from pervognsen/wm.el
Dynamic tiling window manager for Emacs (inspired by dwm/awesome/xmonad for Linux)
(require 'cl)
(defstruct wm-window buffer (point 0) (start 0) (hscroll 0) dedicated)
(defvar wm-windows)
(defvar wm-windows-alist)
(defvar wm-focus)
(defvar wm-workspace 0)
(defvar wm-workspaces nil)
(defvar wm-layout 0)
@uucidl
uucidl / real_mode_boot.c
Last active May 23, 2020 08:56
legacy bios bootsector
// -*- mode: c ; c-file-style: "k&r" -*-
// x86 boot sector.
//
// Once you execute this program you will get a series of disk images, which you can try in qemu:
// qemu -drive file=boot.img,format=raw
//
// and burn to a usb stick using something like rufus or dd
#include <assert.h>
#include <stdlib.h>
@uucidl
uucidl / 01_materials.md
Last active August 5, 2020 09:10
Let's make a simple USB audio driver for xHCI hosts and Audio Class 1.0

If you develop drivers (Software) for USB peripherals then you may only need to read chapters, 4 - Architectural Overview 5 - USB Data Flow Model 9 - USB Device Frame Work, and 10 - USB Host Hardware and Software.

You probably also need to know xHCI. The host-side USB spec.

@uucidl
uucidl / uu-re-link.el
Last active October 10, 2020 19:20
Let Emacs simulate Acme by creating clickable regexp links in the buffer.
#define case(__x__) break; case __x__
#define fallthrough(__x__) case __x__
#define otherwise break; default
#include <assert.h>
#include <stdio.h>
int main(int argc, char **argv) {
switch(argc) {
case(0): printf("surprising\n");