Skip to content

Instantly share code, notes, and snippets.

View iemelyanov's full-sized avatar

Igor Yemelyanov iemelyanov

View GitHub Profile
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <time.h>
#define i8 int8_t
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>
#include <csignal>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@iemelyanov
iemelyanov / aiosrv.rs
Created March 23, 2023 10:12
Rust async server
use libc::{EPOLLIN, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD};
use std::collections::HashMap;
use std::io;
use std::io::ErrorKind;
use std::net::TcpListener;
use std::os::unix::io::AsRawFd;
use std::ptr;
macro_rules! syscall {
($fn: ident ( $($arg: expr),* $(,)* ) ) => {{
@iemelyanov
iemelyanov / ast_visitor.rs
Created March 23, 2023 10:08
Rust ast, visitor
mod ast0 {
enum BinOp {
Add,
Sub,
Mul,
Div,
}
enum Variable {
A,
use std::fmt::Display;
#[derive(Clone, Copy, PartialEq, Eq)]
enum Token {
Minus,
Plus,
Mul,
Div,
Num(i32),
Eof,
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
struct paddr_val {
uint64_t paddr;
uint64_t val;
};
int paddr_val_cmp(const void *a, const void *b)
@iemelyanov
iemelyanov / marksweep.cpp
Created January 22, 2022 12:32
C++ mark & sweep toy gc
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <variant>
#include <vector>
typedef int64_t i64;
typedef uint64_t u64;
typedef float f32;
typedef double f64;
@iemelyanov
iemelyanov / calc.cpp
Last active August 13, 2021 09:21
Impl simple calc for play with C++
/*
=======
Grammar
=======
Syntax
------
expression → literal
@iemelyanov
iemelyanov / aiosrv.c
Last active November 5, 2022 15:09
aiosrv.c
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
@iemelyanov
iemelyanov / Makefile
Created October 3, 2017 19:54 — forked from divan/Makefile
Make help
.PHONY: help
# This is a code for automatic help generator.
# It supports ANSI colors and categories.
# To add new item into help output, simply add comments
# starting with '##'. To add category, use @category.
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)