Many devs think: setTimeout(() => console.log(“hi”), 0); runs immediately. It does NOT. 🔍 Why? It is put into the task queue, which only runs after: microtasks (Promise callbacks) current call stack render steps Example Promise.resolve().then(() => console.log(“promise”)); setTimeout(() => console.log(“timeout”), 0); // Output: // promise // timeout 💡 Why This Matters Debugging race conditions Handling […]
Day: December 6, 2025
HTML5 Input Validation — Why Your Patterns “Don’t Work”
HTML5 validation fails when: Wrong regex style Missing anchors Using lookaheads (not supported) Using unescaped characters ❌ Wrong <input pattern=”[A-Z]{3}-[0-9]+” /> ✔ Correct Always anchor: <input pattern=”^[A-Z]{3}-[0-9]+$” /> 💡 Life-Saving Detail HTML5 pattern must match the entire string.Not a substring — the whole value. This rule is rarely known and causes hours of debugging.
CSS Z-Index Hell — Why Elements Randomly Disappear (and the Real Fix)
Z-index doesn’t work the way most devs think.It depends on stacking contexts, not numbers. 🔥 The Real Causes position: relative creates a new stacking context transform creates a new stacking context opacity < 1 creates a new stacking context Parent stacking contexts override children You can set z-index: 999999 and STILL not see your element. […]
.NET Core JSON Serializer Pitfalls — Why Your Properties Don’t Serialize
System.Text.Json is fast……but very strict. Common Pain Points Missing getters Private setters PascalCase vs camelCase mismatch Ignored fields without [JsonInclude] Cycles now break serialization ✔ Life-Saving Fix Add: options.PropertyNameCaseInsensitive = true; options.ReferenceHandler = ReferenceHandler.IgnoreCycles; ✔ Hidden Trick For private setters: [JsonInclude] public string Name { get; private set; } This is rarely mentioned but solves […]
ASP.NET Core Middleware Order — Why Your App Breaks for No Reason
The #1 misunderstood part of ASP.NET Core is middleware order. ❌ Bad Order Example app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); Authentication runs BEFORE routing → user can’t be authorized → random 401s. ✔ Correct Order app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(…); 💡 Life-Saving Insight Routing must ALWAYS come first.Authorization must ALWAYS come after Authentication. Confusing ordering makes APIs randomly break.
SQL The “Too Many Indexes” Problem — Why Over-Indexing Slows Everything
Many devs think more indexes = faster queries.Nope. ⚠ Real Risks Inserts slow down Updates slow down Deletes slow down Database size explodes Memory grants skyrocket Locking increases ✔ The Life-Saving Rule Every index must support a query.If the query does NOT exist → the index should NOT exist. ✔ How To Check Query sys.dm_db_index_usage_stats: […]
SQL Parameter Sniffing — The REAL Fix Nobody Explains Properly
Most “solutions” online are myths.Here’s the real fix. 🧨 The Problem SQL Server caches a plan using the first parameter value. If first call is small dataset → plan optimized for smallIf next call is huge → BAD performance ✔ The Correct Fix (Rarely Understood) Use OPTIMIZE FOR UNKNOWN: SELECT * FROM Orders WHERE CustomerId […]
C# HttpClient Misuse — The Root of Random Slowdowns / DNS Failures
Developers still do this: var client = new HttpClient(); // ❌ NEVER do this Creating HttpClient per request causes: Port exhaustion DNS reuse issues Slowdown under load Socket exceptions ✔ The ONLY Correct Pattern builder.Services.AddHttpClient(); Or for minimal APIs: var client = httpClientFactory.CreateClient(); 💡 The Life-Saving Insight If you see: random timeouts slow downstream calls […]
C# Configuration Binding Hell — Why Your Options Return Null
Many devs struggle with strongly-typed configuration returning null unexpectedly. 🔥 Main Causes Missing services.Configure<T>() Wrong section name Mistyped property names Missing getters/setters Nested classes not matching JSON structure ✔ The Correct Pattern builder.Services.Configure<MySettings>( builder.Configuration.GetSection(“MySettings”)); public class MySettings { public string ApiKey { get; set; } } ✔ But Here’s the Hidden Trick Add validation to […]
C# Async “Hangs Forever” Problem — Why Task Never Completes Under Load
This is one of the most painful production issues:async calls sometimes never complete under high load. 🔍 Root Cause: ThreadPool Starvation + Sync-over-Async If your code blocks threads, the async continuations never get a chance to run. Task.Run(() => { Thread.Sleep(3000); // ❌ Blocks threadpool }); Eventually, under load: Tasks queue up ThreadPool can’t spawn […]
CSS Subgrid — The Most Misunderstood Layout Feature
Most devs don’t know that Grid can inherit layout from its parent grid. .child { display: grid; grid-template-columns: subgrid; } 🔥 Why It’s Huge Perfect alignment between parent & child Cleaner responsive layouts No duplicated breakpoints Layout consistency made easy
Service Workers — Offline-First Apps Made Easy
Service Workers let your site work offline, cache assets, and load instantly. navigator.serviceWorker.register(‘/service-worker.js’); ✨ What You Get ⚡ Near-instant load time 📦 Cached static assets 📡 Offline browsing 🔋 Reduced server load 💡 Combine with “cache-first” strategies for ultimate speed.
Debounce vs Throttle — The UI Performance Problem Everyone Gets Wrong
🎯 Debounce Trigger after user stops typing. Great for: Search boxes Auto-suggest Validation 🌀 Throttle Trigger every X ms, no matter what. Great for: Scroll events Resize events Mouse move Quick Example const debounced = debounce(fn, 300); const throttled = throttle(fn, 200); 💡 Using the wrong one leads to janky UI & wasted CPU.
Dependency Injection Performance — “AddTransient Everywhere” Is Not the Answer
Many APIs slow down because lifetime choices are wrong. ❌ Common Mistake Using Transient for heavy services: services.AddTransient<EmailService>(); ✔ Correct Use Singleton for stateless services: services.AddSingleton<IEmailSender, EmailService>(); 💡 Why? Fewer allocations Less GC pressure Faster resolving More consistent performance
ASP.NET Core Kestrel Limits — Avoid Flooding & Keep APIs Stable
Kestrel has built-in protection against floods, slow clients, and excessive headers. Key Settings in appsettings.json: “Kestrel”: { “Limits”: { “MaxRequestBodySize”: 1048576, “KeepAliveTimeout”: “00:00:30”, “RequestHeadersTimeout”: “00:00:30” } } 💡 Why This Matters Stops slow-loris attacks Reduces memory pressure Prevents API overload Ensures predictable scaling Bonus Enable HTTP/2 for better concurrency.
SQL Blocking vs Deadlocks — Most Developers Confuse Them
🔒 Blocking Queries wait for each other Slow performance Not fatal ✔ How to Fix Blocking Correct indexing Reduce long transactions Avoid row locks with better filters 💥 Deadlocks Two queries wait on each other SQL kills one session Returns error 1205 ✔ Fix Deadlocks Always access tables in SAME ORDER Keep transactions very […]
SQL SARGability — The REAL Reason Your Indexes Don’t Work
SARG (Search ARGument Able) is the biggest reason queries go from 20ms → 10 seconds. ❌ Non-SARGable WHERE YEAR(OrderDate) = 2024 This forces a full scan. ✔ SARGable Version WHERE OrderDate >= ‘2024-01-01’ AND OrderDate < ‘2025-01-01’ 💡 Why It Matters Enables index seeks Saves CPU Reduces IO dramatically
C# ThreadPool Starvation — Why Tasks Get “Stuck” in High Load
In high concurrency, ThreadPool starvation causes tasks to freeze for seconds. ⚠ The Symptoms Slow responses under load Random spikes Async operations timing out 😬 Common Cause Task.Run(() => { Thread.Sleep(2000); // ❌ Blocks the threadpool }); ✔ The Fix Use true async APIs: await Task.Delay(2000); 💡 Bonus Use ThreadPool.GetAvailableThreads to diagnose starvation.
Memory Leaks in C# — The Hidden Culprit: Event Handlers
Unsubscribed event handlers are one of the biggest real-world leak causes. publisher.SomeEvent += OnEvent; // stays forever if not removed ⚠ Why It Leaks The publisher holds a reference to your object GC can’t collect your object Memory keeps climbing ✔ The Fix Always unsubscribe: publisher.SomeEvent -= OnEvent; Or use weak events or IDisposable patterns. […]
C# Deadlocks Explained — Why ConfigureAwait(false) Saves Your Async Code
Deadlocks in async/await often come from sync-over-async and the UI/ASP.NET synchronization context. var data = GetDataAsync().Result; // ❌ Possible deadlock 🔥 Why This Happens The UI thread waits Async method tries to resume on the UI thread Both wait forever 😅 ✔ The Fix Use ConfigureAwait(false) in library code: await SomeLibraryCall().ConfigureAwait(false); 💡 Pro Tips Never […]
.NET Core Connection Pooling — The Hidden Performance Giant
Most API latency problems = opening too many SQL connections. 🚀 Fix Use a single pooled client: builder.Services.AddDbContext<AppDb>(options => options.UseSqlServer(connString, o => o.EnableRetryOnFailure())); ✨ Benefits ⚡ Fast connection acquisition 📉 Lower CPU 🧵 Stable high-load behavior 💡 BonusUse Max Pool Size=200 in connection string for heavy systems.
Minimal APIs Filters — Middleware Without the Middleware Cost
Filters allow cross-cutting logic without writing a full middleware. builder.Services.AddEndpointFilter<ValidationFilter>(); ⚡ Why They’re Great ⚙ Less overhead 🎯 Scoped to specific endpoints 🧽 Cleaner architectures 🔍 Perfect for validation, auth, logging
JavaScript Web Workers — Real Multithreading for Heavy Tasks
Web Workers allow JS to run CPU-heavy tasks off the main thread. const worker = new Worker(“worker.js”); worker.postMessage({ action: “process” }); 💥 Why Use Them 🧵 Prevent UI blocking 🚀 Faster data processing 📸 Smooth animations 🧩 Perfect for image, crypto & data tasks
HTML5 Lazy Loading Images — Zero-Effort Performance Gains
Lazy loading is now native in all modern browsers. <img src=”hero.jpg” loading=”lazy” /> 🚀 Why It’s Amazing 📉 Instant LCP improvements 🧠 Saves bandwidth ⚡ Faster page loads 🛠 No JS required
CSS Container Queries — The Future of Responsive Design
Media queries scale by viewport…Container queries scale by component. .card { container-type: inline-size; } @container (min-width: 450px) { .card { flex-direction: row; } } ✨ Why They’re a Big Deal 🎯 Component-level responsiveness 📦 No more giant breakpoint spaghetti 🧩 Perfect for design systems
SQL Window Functions — The Fastest Way to Do Ranking & Aggregates
Window functions eliminate messy subqueries and temp tables. SELECT UserId, Amount, RANK() OVER (ORDER BY Amount DESC) AS RankNo FROM Orders; ⚡ Why They’re Amazing 🚀 Blazingly fast 🧮 Ideal for analytics 🔍 Cleaner than GROUP BY hacks ✂ Replaces many procedural patterns
SQL Index Fragmentation — What Actually Matters (and What Doesn’t)
Most devs rebuild indexes far too often. ✔ What Matters 📉 Fragmentation < 30% → ignore 🔄 30–80% → reorganize 🔨 > 80% → rebuild ⚡ Better Approach Use sys.dm_db_index_physical_stats to target heavy tables only. SELECT index_type_desc, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, ‘LIMITED’); 💡 Pro Tip “Rebuild everything nightly” is anti-pattern — kills IO.
C# Encryption Done Right — AesGcm Instead of AES CBC
Most devs still use the outdated AES CBC mode.Use AesGcm for modern authenticated encryption. using var aes = new AesGcm(key); aes.Encrypt(nonce, data, ciphertext, tag); 🛡 Why It’s Better ✔ Authenticated ✔ Fast on modern CPUs ✔ Built to prevent tampering ✔ Recommended for APIs & tokens
C# Source Generators — Compile-Time Performance Boosters
Source Generators remove runtime reflection overhead by generating code during compilation. [MySerialize] public class Product { public string Name { get; set; } } 🚀 Benefits 🧵 Zero runtime reflection ⚙ Blazing-fast mappers & DTO serializers 💾 Smaller memory footprint 🧩 Perfect for AOT workloads (.NET NativeAOT)
C# Span & Memory — Zero-Allocation Performance Superpowers
Span<T> gives C# ultra-fast, stack-only slicing without copying memory. Span<char> slice = name.AsSpan(0, 3); ⚡ Why It Matters 🧠 Zero GC allocations 🚀 Safe low-level memory access 📉 Faster parsing, CSV handling, protocol processing ♻ Ideal for high-throughput APIs 💡 Pro Tip Combine with ReadOnlySequence<T> for pipelines.





