Skip to content

Instantly share code, notes, and snippets.

View qookei's full-sized avatar
🤔
hmm

Kacper Słomiński qookei

🤔
hmm
  • Poland
  • 20:39 (UTC +02:00)
View GitHub Profile
#pragma once
#include <epoxy/gl.h>
#include <cassert>
#include <memory>
#include <numeric>
#include <type_traits>
template <GLenum Type, typename Ptr = void *>
struct buffer {
@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
@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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <string_view>
#include <elf.h>
struct symbol {
std::string_view name;
uintptr_t base;
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <span>
#include <cstdint>
#include <type_traits>
#include <cassert>
#include <cstring>
#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 <vector>
#include <string>
#include <algorithm>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
@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>
from bdfparser import Font # https://github.com/tomchen/bdfparser
# Character 0 (NUL) was changed from 0x0000 to 0x0020 (space)
# Character 255 (NBSP) was changed from 0x00A0 to 0x0020 (space)
cp437_mapping = [
0x0020, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
(use-modules (ice-9 textual-ports) (srfi srfi-1) (ice-9 string-fun))
(define (read-all-lines)
(let ([line (get-line (current-input-port))])
(if (eof-object? line)
'()
(cons line (read-all-lines)))))
(define WORD->DIGIT
'(("one" . "1")