Search
Lessons (28)
- Python and Math Foundations with Runnable Examples
… It is a geometric score, not a probability of correctness. python from math import sqrt def cosine(left …
- What to Learn in AI, and in What Order
… 2. Math you can use: Learn vectors and matrices, probability, averages and variance, derivatives, and the idea of …
- Code Smells & Refactoring
… return Math.PI shape.r 2; case "square": return shape.side 2; } } // ✅ Each shape knows how to compute …
- Dynamic Programming
… coin of coins) { if (coin <= a) dp[a] = Math.min(dp[a], dp[a - coin] + 1); } } return dp …
- Two Pointers & Sliding Window
… update best using the window [left, right] best = Math.max(best, right - left + 1); } return best; } How to …
- Structural Patterns: How to Connect Objects
… Array.from({ length: 100 000 }, () = ({ x: Math.random() 1000, y: Math.random() 1000, type: getTreeType("oak", "oak.png …
- Binary Search
… lo, hi] is not empty const mid = lo + Math.floor((hi - lo) / 2); if (sorted[mid] === target) return …
- Arrays & Strings
… for (const n of nums) { min = Math.min(min, n); max = Math.max(max, n); sum += n; } return …
- DSA Interview Patterns Cheat Sheet
… O(log n) or O(1) Binary search, math Example: intervals (merge overlapping meetings) js function mergeIntervals(intervals …
- Resilience Patterns
… throw error; const backoff = Math.min(maxMs, baseMs 2 (attempt - 1)); const jitter = Math.random() backoff; // spread clients …
- Count, for_each, Functions, and Stable Identities
… merge for tag maps, and cidrsubnet for subnet math. hcl locals { common tags = { ManagedBy = "Terraform", Team = "platform" } tags …
- Concurrency, Resilience & Distributed Workflows
… const delay = Math.min(30 000, 250 2 attempt); const jittered = delay (0.5 + Math.random()); await sleep …
- JavaScript Language Fundamentals
… Node.js also still supports the older CommonJS ( require ). js // math.js export const PI = 3.14159; export …
- O — Open/Closed Principle
… number { const best = Math.max(0, ...this.rules.filter((r) = r.appliesTo(cart)).map((r) = r.discount(cart …
- L — Liskov Substitution Principle
… Square extends Rectangle In maths, a square is a rectangle. So inheritance seems natural: js class Rectangle { setWidth …
- Developer Learning Plan and Document-Assistant Capstone
… units Week 2 Vectors, probability, metrics Run the math exercises Calculate similarity, precision, and recall Week 3 Training …
- Trees & Binary Search Trees
… empty tree return 1 + Math.max(height(node.left), height(node.right)); // combine } // Count nodes const count = (node …
- Heaps & Priority Queues
… No node objects needed: For the node at index i Formula --- --- Parent Math.floor((i - 1) / 2) Left …
- A WhatsApp OTP Is Only Single Use If You Make It So
… string { return randomInt(0, 1 000 000).toString().padStart(6, '0'); // CSPRNG, never Math.random() } function hashOtp(code …
- Big-O Notation Made Simple
… m = -Infinity; for (const x of arr) m = Math.max(m, x); return m; } // O(n) space: builds …
- Frontend Testing Strategy
… number }[], discount = 0) { const subtotal = items.reduce((sum, item) = sum + item.price item.qty, 0); return Math.round …
- Code Profiling
… toSummaryRow); logger.info({ customerId, orderCount: orders.length, durationMs: Math.round(performance.now() - startedAt), }, "order summary completed"); return summary …
- TypeScript in Practice
… Circle Square null) { if (shape === null) return 0; // equality narrowing if ("radius" in shape) return Math.PI shape …
- Behavioral Patterns II: Chain, Template, Iterator, Mediator, Memento, Visitor
… yield song; } shuffled() { const copy = [...this.songs].sort(() = Math.random() - 0.5); yield copy; } } const playlist = new Playlist …
- Node.js and Express
… console.log( ${req.method} ${req.originalUrl} ${res.statusCode} ${Math.round(performance.now() - start)}ms ); }); next(); }); // Route-level: only …
- Domain-Driven Design: Tactical Patterns
… Money { return new Money(Math.round(this.cents factor), this.currency); } equals(other: Money) { return this.cents === other …
- Python Fundamentals
… Threads release the GIL while waiting CPU-bound (math, image processing) multiprocessing / ProcessPoolExecutor Separate processes, separate GILs Heavy …
- Caching & Redis
… max 100 requests per minute per user const key = rate:${userId}:${Math.floor(Date.now() / 60000)} ; const count …