Skip to content

Instantly share code, notes, and snippets.

View qookei's full-sized avatar
🤔
hmm

Kacper Słomiński qookei

🤔
hmm
  • Poland
  • 08:40 (UTC +02:00)
View GitHub Profile
@qookei
qookei / term.c
Created June 20, 2021 21:40
Simple Xlib-based terminal emulator
// Compile with: gcc term.c -o term -lX11 ...
#define _XOPEN_SOURCE 600
#include <X11/Xlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <ctype.h>
#define FMT_PUT(dst, len, c) {\
if(!(len) && check_bounds) goto end;\
*(dst)++ = (c);\
len--;\
ret++;\
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <span>
#include <cstdint>
#include <type_traits>
#include <cassert>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <string_view>
#include <elf.h>
struct symbol {
std::string_view name;
uintptr_t base;
@qookei
qookei / cc.c
Last active May 18, 2022 21:11
C with "classes"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#define __USE_GNU
#include <signal.h>
#include <ucontext.h>
#define OBJ_MAGIC_HIGH 0xDEADBEEF00000000
@qookei
qookei / bmpldr.h
Created August 4, 2020 21:08
Incomplete single header C BMP loader
#ifndef BMPLDR_H
#define BMPLDR_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#pragma once
#include <epoxy/gl.h>
#include <cassert>
#include <memory>
#include <numeric>
#include <type_traits>
template <GLenum Type, typename Ptr = void *>
struct buffer {
/*
* compile with: g++ gorbitsa.cpp -o gorbitsa -ftemplate-depth=99999999 -std=c++2a
* Tested with GCC 10.1, does *not* work with Clang 10
*/
#include <iostream>
#include <string_view>
#include <cctype>
#include <array>
#include <type_traits>
/*
Requires compiler with C++20 concept support (GCC 10.1/Clang 10 or newer)
*/
#include <unordered_map>
#include <concepts>
#include <iostream>
#include <variant>
#include <string>
#include <vector>