Skip to content

Instantly share code, notes, and snippets.

View nezvers's full-sized avatar

Agnis Aldiņš "NeZvērs" nezvers

View GitHub Profile
@nezvers
nezvers / Program.cs
Created February 13, 2026 22:34 — forked from tomhawkin/Program.cs
C# port of MicroGPT
// This is a C# port of @karpathy microgpt python script (https://gist.github.com/karpathy/8627fe009c40f57531cb18360106ce95)
// It's the closest I could get using C#.
// Use with caution as it could be wrong, but it does seem to get similar outputs
namespace MicroGpt;
public class Value(double data, Value[]? children = null)
{
private readonly Value[] _children = children ?? [];
private Action _backward = () => { };
@nezvers
nezvers / microgpt.py
Created February 13, 2026 22:29 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@nezvers
nezvers / carve.c
Created December 1, 2025 09:05
Binary extraction in C
#include <stdio.h>
void carve_file(const char *input_file, const char *output_file, size_t start_byte, size_t end_byte){
FILE *file_in = NULL;
FILE *file_out = NULL;
file_in = fopen(input_file, "rb");
if (!file_in) {
printf("Failed to open input file - %s\n", input_file);
goto defer;
@nezvers
nezvers / nob_raylib.c
Last active November 9, 2025 22:26
nob.h template for raylib with fetch (Cmake style) using only C & Curl/Wget
#define NOB_IMPLEMENTATION
// #define NOB_STRIP_PREFIX
#define NOB_WARN_DEPRECATED
#include "nob.h" // https://github.com/tsoding/nob.h
#include <stdio.h>
#include <string.h>
#define PROJECT_NAME "NoBuild_Raylib"
#define BUILD_FOLDER "build/"
@nezvers
nezvers / timer.c
Last active October 18, 2025 11:05
High precision timer/clock (Windows, Linux)
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
#endif
static double timer_start = 0.0;
@nezvers
nezvers / SDL3 + Dear ImGui CMake.txt
Last active August 20, 2025 06:46
SDL3 + Dear ImGui CMake
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
# SDL3 ______________________________________________
FetchContent_Declare(
sdl3
cmake_minimum_required(VERSION 3.28)
include(FetchContent)
set(ProjectName RaylibTemplate)
project(${ProjectName} LANGUAGES C CXX)
# Raylib _______________________________________
FetchContent_Declare(
raylib
DOWNLOAD_EXTRACT_TIMESTAMP OFF
@nezvers
nezvers / SDL3 Cmake template.txt
Last active April 9, 2025 11:47
SDL3 Cmake template
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(PROJECT_NAME Sdl3Template)
project(${PROJECT_NAME})
# ?
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.12)
include(FetchContent)
set(PROJECT_NAME SfmlTemplate)
project(${PROJECT_NAME} VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.28)
include(FetchContent)
# NAME
set(PROJECT_NAME RaylibTemplate)
project(${PROJECT_NAME} LANGUAGES C)
set(CMAKE_C_STANDARD 99)
# set(CMAKE_CXX_STANDARD 17)