Skip to content

Instantly share code, notes, and snippets.

@maxrt101
maxrt101 / generator.h
Last active October 24, 2023 13:46
Implementation of range(), enumerate() and zip(), similar in functionality to corresponding python functions
/* generator.h v1.0 by maxrt101
* Header that provides functionality similar to python's generators,
* including implementations for range(), enumarate() and zip()
*/
#ifndef _MRT_UTILS_GENERATOR_H_
#define _MRT_UTILS_GENERATOR_H_ 1
#include <exception>
#include <functional>
@maxrt101
maxrt101 / serialization.hh
Last active September 29, 2023 00:25
Binary Serializer/Deserializer for C++ structs
/* serialization.hh v1.2 by maxrt101
* Serializer/Deserializer for C++ objects
* To make class serializable, add MAKE_SERIALIZABLE() macro inside it's declaration
* and pass all fields into it.
*/
#ifndef _MRT_SERIALIZATION_H_
#define _MRT_SERIALIZATION_H_ 1
#include <cstdio>
@maxrt101
maxrt101 / hexdump.cc
Created March 2, 2023 03:04
Hexdump function
#include <cstring>
#include <cctype>
#include <cstdio>
void hexdump(const unsigned char* data, size_t size, int cols) {
int can_print = 1;
size_t count = 0;
char* buf = new char[cols];
while (can_print) {
@maxrt101
maxrt101 / generate_combinations.py
Last active August 10, 2022 00:18
Generate password-like symbol combinations of arbitrary length
#!/usr/bin/env python3
# combination generator by maxrt101
import itertools
import hashlib
import sys
def generate(digits: int, src: list) -> list:
return list(itertools.product(*([src] * digits)))
@maxrt101
maxrt101 / task_log.py
Created March 17, 2022 23:29
TaskLog(Progress Meter)
# TaskLog by maxrt101
from dataclasses import dataclass
from enum import Enum
import threading, queue, time
class State(Enum):
SUCCESS = 0
FAILED = 1
STARTING = 2
@maxrt101
maxrt101 / hexdump.c
Last active March 17, 2022 23:30
Hexdump
/* hexdump.c by maxrt101 */
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>