Skip to content

Instantly share code, notes, and snippets.

View leok7v's full-sized avatar

Leo Kuznetsov leok7v

View GitHub Profile
@leok7v
leok7v / backend.h
Last active July 4, 2026 19:12
bitnet.metal
#ifndef BN_BACKEND_H
#define BN_BACKEND_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
@leok7v
leok7v / Privacy-Policy-for-im.ai-App.txt
Last active March 23, 2026 20:14
Privacy Policy for im.ai App
The im.ai App does not collect, transmit, or share any personal user information or data.
All app functionality occurs locally on the device.
We do not use third-party analytics, advertising, or data mining tools.
@leok7v
leok7v / map_test.c
Created November 29, 2025 07:42
map_test.c (see map.h/map.c)
#include "map.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#define TEST_INT_PAIR(name, T, v1, v2) \
static void map_test_##name(void) { \
struct name map_of(T, T); \
struct name m = {}; \
bool ok = map_alloc(&m, 0); assert(ok); \
@leok7v
leok7v / map.c
Last active November 29, 2025 07:43
Simple (almost trivial) map. Subset of C++ std::map good enough to limited usage for str::map<std::string,something> replacement
#include "map.h"
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#undef MAP_DUMP_CONVERT
@leok7v
leok7v / proquint.c
Created November 21, 2025 19:14
Identifiers that are Readable, Spellable, and Pronounceable
/* This file is part of proquint: http://github.com/dsw/proquint .
See License.txt for copyright and terms of use. */
/*
Convert between proquint, hex, and decimal strings.
Please see the article on proquints: http://arXiv.org/html/0901.4016
Daniel S. Wilkerson
*/
#include "proquint.h"
@leok7v
leok7v / PlatformView.swift
Created October 2, 2025 01:05
Platform Independent unifying Platform[Web]View templates using ViewRepresentable to minimize/reduce #if #else #endif in SwiftUI code
import SwiftUI
/// Platform Independent unifying ViewRepresentable template to minimize #if #else #endif in SwiftUI code
#if canImport(UIKit)
import UIKit
public typealias _BaseView = UIView
public typealias PlatformViewRepresentable = UIViewRepresentable
#else
import AppKit
@leok7v
leok7v / UIWebView.swift
Created September 30, 2025 03:42
Swift.WebView polyfill
import SwiftUI
import WebKit
import Foundation
import SwiftUI
//import Foundation
#if os(iOS)
import UIKit
typealias OSWindow = UIWindow
typealias OSView = UIView
@leok7v
leok7v / arrays.c
Created September 26, 2025 04:08
growing arrays on heap and stack with bounds checks
#include <alloca.h>
#include <assert.h>
#include <limits.h> // INT_MAX
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h> // malloc/calloc/realloc/free
#include <string.h> // memcpy
@leok7v
leok7v / gpu.c
Last active September 14, 2025 19:18
Metal/Vulkan GPU count and VRAM detection (gpu.h/gpu.c)
/* File: gpu.h */
#pragma once
#ifndef GPU_H
#define GPU_H
#ifdef __cplusplus
extern "C" {
#endif
#include "etc.h"
@leok7v
leok7v / array.c
Last active September 12, 2025 00:44
Simple std::vector replacement in C
struct _array {
void* data;
int count;
int capacity;
};
#define array_of(type) { \
type* data; \
int count; \
int capacity; \