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 / e2e_graphrag.py
Last active June 21, 2026 16:27
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

@mosioc
mosioc / algebraic_effects.rs
Created December 28, 2025 19:59
Algebraic Effects in Rust
// ALGEBRAIC EFFECTS
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Clone)]
enum Effect {
Log(String),
GetRandom(i32, i32), // min, max
Pause(u32), // milliseconds