Skip to content

Instantly share code, notes, and snippets.

View mosioc's full-sized avatar
🚀
Ascending - 36°N 64°E

Mehdi Maleki mosioc

🚀
Ascending - 36°N 64°E
View GitHub Profile
@mosioc
mosioc / llm-wiki.md
Created August 13, 2026 15:57 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@mosioc
mosioc / e2e_graphrag.py
Last active August 10, 2026 22:36
E2E GraphRAG engine; multi-hop relational paths + Louvain community detection
import networkx as nx
import numpy as np
import math
from dataclasses import dataclass, field
from typing import List, Dict, Tuple, Any
# --- core data structures ---
@dataclass
class Entity:
@mosioc
mosioc / PagedKVCache.py
Created June 21, 2026 15:09
vLLM demonstration - managing vram under the hood; Paged KV Cache and PagedAttention mechanism
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from typing import List, Optional
class PagedKVCache:
"""
advanced paged key-value cache manager for large language models.
simulates the memory management backend of frameworks like vllm.
@mosioc
mosioc / karteibox.ts
Created June 5, 2026 11:49
5-Box Leitner Spaced Repetition System - G5
// map of box index to the days interval array
const G5_INTERVALS = [1, 2, 5, 9, 14];
interface Flashcard {
id: string;
word: string;
definition: string;
box: number; // 1 to 5
nextReviewDate: Date;
}
@mosioc
mosioc / QueryCache.ts
Created May 26, 2026 09:29
Large-scale offline-first app with useLiveQuery + state management
type Listener = () => void;
type Unsubscribe = () => void;
interface CacheEntry<T> {
data: T;
listeners: Set<Listener>;
dbUnsubscribe: Unsubscribe | null;
subscriberCount: number;
}
@mosioc
mosioc / zustand-sheet.md
Last active June 22, 2026 19:38
Zustand cheat sheet

Zustand Cheat Sheet

A minimal, unopinionated state management library for React with a hooks-based API.


Core Concepts

  • Store: A single source of truth holding your application state
  • Hooks-based: Access state using hooks, no providers needed
@mosioc
mosioc / bun-sheet.md
Created January 23, 2026 15:47
Bun cheat sheet

Bun Cheat Sheet

Fast all-in-one JavaScript runtime and toolkit (bundler, test runner, package manager).


Core Concepts

What is Bun?

Bun is a modern JavaScript runtime built from scratch using Zig and JavaScriptCore (Safari's JS engine). It serves as a drop-in replacement for Node.js with significantly faster startup times and execution speed. Unlike Node.js which uses V8, Bun uses JavaScriptCore which contributes to its performance gains.

@mosioc
mosioc / deno-sheet.md
Created January 23, 2026 15:29
Deno cheat sheet

Deno Cheat Sheet

A modern, secure runtime for JavaScript and TypeScript built on V8, Rust, and Tokio.


Core Concepts

What is Deno?

@mosioc
mosioc / script-sheet.md
Created December 29, 2025 17:00
Shell scripting in Bash, Node.js, and Python cheat sheet

Shell Scripting Cheat Sheet: Bash, Node.js, and Python

Quick reference for writing scripts in Bash, Node.js, and Python with practical examples and explanations.


Core Concepts

Script Anatomy