Skip to content

Instantly share code, notes, and snippets.

View corporatepiyush's full-sized avatar
🎯
Focusing

Piyush Katariya corporatepiyush

🎯
Focusing
View GitHub Profile
@corporatepiyush
corporatepiyush / gorustzig.md
Last active June 12, 2026 17:51
The only guide you will ever need to compare Go, Rust and Zig programming language in a great detail

Rust 1.95 vs Go 1.26 vs Zig 0.16 — Complete Comparative Guide

As of June 2026

Each section compares how the three languages approach the same concern, side by side. Tags: ⚡ Perf · 🔐 Safety · 🧹 DX · 🔍 Debug · 📦 Binary · 🔒 SecOps

Notes on reading this document: performance figures are from specific benchmarks, not guarantees — they vary with workload, input size, and hardware. Library names are current as of June 2026; ecosystems move. Where a language lacks a capability, that is stated plainly rather than softened.

@corporatepiyush
corporatepiyush / pl_comp.md
Created June 11, 2026 09:06
Programming language comparison

|Aspect |Odin (dev-2026-05) |Zig (0.16.0) |Rust (1.95+) |Go (1.26+) heavy unsafe |Java (25 LTS) |C# (.NET 11 preview / C# 15) | |-----------------------------------|-----------------------------------------------------------------------------------------------------------------

@corporatepiyush
corporatepiyush / datastar.md
Last active June 10, 2026 20:29
The Ultimate Guide - Datastar framework for building complex UI with SSE, PostgreSQL and MongoDB

Datastar Complex UI Development End to End Guide with PG and Mongo

Version: Datastar v1.0.x (latest stable) | Composable CSS: Tailwind CSS v4.x
Philosophy: Server-driven reactivity with declarative data-* attributes. No build step, no virtual DOM, ~10.7KB client.


Table of Contents

Quick Reference Cheatsheet — fast lookup for attributes, actions, SSE events & backend patterns

@corporatepiyush
corporatepiyush / AgentCompact.md
Last active June 10, 2026 07:48
AgentCompact

AGENT.md — Extreme Performance Reference (Compact Edition)

June 2026 · Java 25/26 · Go 1.26 · Rust 1.94 · Python 3.14 · Node 24 · Linux 7.0/6.18 LTS · PG 18.4 · MariaDB 12.3.2 LTS


Latency Numbers (2026 Hardware)

Operation Latency
@corporatepiyush
corporatepiyush / agent.md
Created June 8, 2026 13:33
Agent.md for CPU, IO and Memory optimizations

Core Objective: Treat every abstraction as a measurable, quantifiable cost. Prioritize mechanical sympathy, cache-line granularity, zero-allocation hot paths, kernel-boundary minimization, and compiler-friendly structures. Every byte of indirection, every cycle of branch misprediction, and every nanosecond of cache coherency traffic is a failure to respect the silicon. These principles apply universally—whether the runtime is a managed VM, a compiled binary with a GC, a borrow-checked systems language, or a native code generator.


Data Representation & CPU Cache Alignment

Mechanical Sympathy over Deep Hierarchies: Data must flow as contiguous byte streams. Prioritize flat arrays and dense vectors over deep object graphs, nested classes, or pointer-chasing models. A single pointer dereference can cost 100 ns from DRAM versus 1 ns from L1 cache. On x86-64, the L1 cache is 32–64 KB per core with 64-byte lines; on ARM64 (Neoverse V2), L1 is 64 KB with 128-byte lines. The hardware prefetcher loads

"""
The most atomic way to train and run inference for 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
@corporatepiyush
corporatepiyush / For.java
Created October 16, 2025 21:26
Optimizing For loops
import java.util.Random;
public class For {
static final int SIZE = 1_000_000;
public static void main(String[] args) {
int[] data = new int[SIZE];
Random rnd = new Random(42);
for (int i = 0; i < SIZE; i++) data[i] = rnd.nextInt(1000) - 500;
@corporatepiyush
corporatepiyush / Matmul.c
Last active October 16, 2025 08:11
Matrix Multiplication
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
// REQUIRED for the M1/Apple Silicon native BLAS implementation (Accelerate Framework)
// gcc -O3 -Wall -Wextra Matmul.c -o Matmul -lm -framework Accelerate
#include "cblas.h"
// --- Utility Functions ---
@corporatepiyush
corporatepiyush / bp-golang.md
Last active May 23, 2026 10:30
Top 100 Best Practices for Golang

Memory Management & Allocation

  1. Pre-allocate Slices with Known Capacity When the eventual size of a slice is known, pre-allocating with make([]T, 0, capacity) creates the underlying array a single time. This critical practice avoids multiple, inefficient reallocations and the expensive process of copying all existing elements to a new, larger array as you append data.

  2. Use the arena for Short-Lived Objects This is perfect for functions that create many temporary objects (like during a single request), as it can nearly eliminate GC pressure from that workload. or else you can also implement custom arena code. Custom Arena backed by mmap file function might help if you want storage for those value and gaurantees which comes with it if process fails or you need more space than allocated RAM size. If data persistence is not important, implementing arena with off-heap storage using unsafe package and pointers can be very beneficial as it is faster than GC heap (default) acce

@corporatepiyush
corporatepiyush / BufferPool.dart
Last active October 10, 2025 20:43
High Performace Application level Buffer Pool for Networking, Image Processing, Graphics, Game engines and File IO Tasks
/// @file A high-performance buffer pool implementation in Dart for managing TypedData.
/// @author Piyush Katariya
/// @version 1.5.0
library buffer_pool;
import 'dart:typed_data';
import 'dart:math';
import 'dart:ffi';
import 'package:ffi/ffi.dart';