Skip to content

Instantly share code, notes, and snippets.

@rivten
rivten / t.vim
Last active September 25, 2020 12:30
t.vim a simple todo manager for vim
" t.vim by rivten
" ==============
" This is a VERY simple todo manager entirely written in vim
" This is based of the awesome CLI todo manager in python 't'
" The code is here : https://github.com/sjl/t
" This 'plugin' is the most simplistic you would expect.
" `:T` just displays the tasks.
" `:T my_task` to add a task
" `:T -f my_todo_id` to finish a task - `:Tf my_todo_id` is also available
" `:T -e my_todo_id my_new_task_name` to edit a task - `:Te my_todo_id my_new_task_name` is also available
// Compile this with clang offsetof_ub_test.c -fsanitize=undefined
#include <stdio.h>
#include <stdint.h>
#define offsetof_ub(st,m) ((uintptr_t)&(((st*)0)->m))
#define offsetof(st,m) __builtin_offsetof(st,m)
#define containerof(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - offsetof(type, member)))
#define containerof_ub(ptr,type,member)\
u32 ReadU32LittleEndian(u8* Stream)
{
u32 Result = 0;
Result += (u8)(*Stream);
++Stream;
Result += 256 * (u8)(*Stream);
++Stream;
Result += 256 * 256 * (u8)(*Stream);
++Stream;
@rivten
rivten / endianness_detection.cpp
Created March 18, 2018 15:18
Detect Endianness
bool IsLittleEndian(void)
{
u32 Int = 1;
u8* MemoryAddress = (u8*)&Int;
return(*MemoryAddress == 0x01);
}