Skip to content

Instantly share code, notes, and snippets.

View AdjWang's full-sized avatar
🎯
Focusing

AdjWang

🎯
Focusing
View GitHub Profile
@AdjWang
AdjWang / run_cmd.c
Last active April 11, 2024 13:38
Run a command through popen and get the output.
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
size_t get_line_size() {
// https://man7.org/linux/man-pages/man3/fgets.3p.html
const size_t kLineMax = 16384u;
size_t line_max;
@AdjWang
AdjWang / CMakeLists.txt
Last active December 13, 2023 16:52
GLAD with wgl
cmake_minimum_required(VERSION 3.8)
# .
# ├── CMakeLists.txt
# ├── GladWGL.cpp
# └── glad
# ├── include
# │   ├── KHR
# │   │   └── khrplatform.h
# │   └── glad
@AdjWang
AdjWang / shm_lru_cache.hpp
Last active October 12, 2023 08:46
A LRU cache sitting on shared memory. Requires boost.
// Derived from: https://www.boost.org/doc/libs/1_67_0/boost/compute/detail/lru_cache.hpp
// CXXFLAGS = -std=c++17 -Wall -Wextra -Werror -Wno-unused-parameter -fdata-sections -ffunction-sections (append -D__OWNER for owner)
// LDFLAGS = -lrt -lpthread -Wl,--gc-sections
#pragma once
#include <boost/optional.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/list.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/string.hpp>
@AdjWang
AdjWang / MessageBus.cs
Created March 16, 2023 08:10
Message passing using shared log API
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
namespace MessageBus
{
public abstract class MessageEndpoint
{
public MessageEndpoint(string id)
{