Skip to content

Instantly share code, notes, and snippets.

View Narrator's full-sized avatar

Kaushik Gnanaskandan Narrator

View GitHub Profile
@Narrator
Narrator / micro-sassy-noodle-soup.md
Created February 16, 2026 01:47
Detailed instructions on how to replicate my parenthetical brain (and hopefully generate some sweet-sweet dollar bucks).

Kaushik's Writing Style Guide

The Core Principle

Kaushik's voice is a thinking-out-loud narrator - someone who lets the reader watch ideas form, collide, contradict, and resolve in real-time. The writing should feel like a smart, self-aware friend explaining something at a whiteboard after two coffees: energetic, tangential, honest about what he knows and doesn't know, and incapable of being boring because the personality never turns off.

If it reads like a polished Medium article, it's wrong. If it reads like Kaushik talking to someone he respects and trusts, it's right.


@Narrator
Narrator / isolation.rs
Created February 6, 2026 18:28
Isolation in rust
// Shared fate: threads in one process
let data = Arc::new(Mutex::new(vec![]));
thread::spawn({
let data = data.clone();
move || {
let mut d = data.lock().unwrap();
panic!("oops"); // Mutex now poisoned for everyone
}
});
@Narrator
Narrator / coordination.rs
Created February 6, 2026 18:28
Coordination in rust
// High coordination: Mutex — consistent, slower
let counter = Arc::new(Mutex::new(0));
{
let mut c = counter.lock().unwrap(); // Wait for lock
*c += 1;
}
// Less coordination: Atomic — faster, limited operations
let counter = AtomicU64::new(0);
counter.fetch_add(1, Ordering::Relaxed); // No waiting
@Narrator
Narrator / locality.rs
Last active February 6, 2026 18:29
Locality in rust
// Local: in-memory HashMap — fast, not resilient
let sessions: HashMap<SessionId, Session> = HashMap::new();
// Server restart = all sessions lost
// Distributed: Redis cluster — slower, resilient
let session = redis.get(session_id).await?;
// Network hop, but survives server restarts
@Narrator
Narrator / granularity.rs
Last active February 6, 2026 18:40
Granularity in rust
// Coarse: one connection handles everything sequentially
fn handle_all(requests: Vec<Request>) {
for req in requests {
process(req); // Other threads sit idle
}
}
// Fine: each request is a separate task
for req in requests {
tokio::spawn(async move {
#!/bin/bash
# Get the number of CPU cores
NUM_CORES=$(nproc)
# Function to perform CPU-intensive calculations
cpu_stress() {
echo "Starting task on process $$"
start_time=$(date +%s.%N)
echo "scale=5000; a(1)*4" | bc -l > /dev/null