Need running totals, rankings, or moving averages? Window functions do it in one query without complex self-joins or cursors. The Old Painful Way – Self-Join: — Calculate running total of sales SELECT o1.OrderDate, o1.Amount, (SELECT SUM(o2.Amount) FROM Orders o2 WHERE o2.OrderDate
Author: ErcanOPAK
.NET Core: Use Minimal APIs to Create Lightweight Endpoints Without Controllers
Creating a controller, action method, and routing just to return simple JSON? Minimal APIs in .NET 6+ let you define endpoints in 3 lines. Traditional Controller Way: [ApiController] [Route(“api/[controller]”)] public class ProductsController : ControllerBase { private readonly IProductService _productService; public ProductsController(IProductService productService) { _productService = productService; } [HttpGet] public async Task GetAll() { var products […]
.NET Core: Use IMemoryCache for Lightning-Fast Data Access Without Redis
Hitting database for same data 1000 times per second? IMemoryCache stores frequently-accessed data in RAM for instant access. Setup: // Program.cs or Startup.cs builder.Services.AddMemoryCache(); Basic Usage: public class ProductService { private readonly IMemoryCache _cache; private readonly ApplicationDbContext _db; public ProductService(IMemoryCache cache, ApplicationDbContext db) { _cache = cache; _db = db; } public async Task GetProductAsync(int […]
Git: Find and Remove Sensitive Data from Entire Repository History
Accidentally committed API keys or passwords? Deleting the file in a new commit doesn’t remove it from history. Here’s how to purge it completely. ⚠️ The Problem: # You committed config.json with API key git add config.json git commit -m “Add config” git push # Then realized mistake and deleted it git rm config.json git […]
Git: Undo Last Commit Without Losing Changes (3 Different Scenarios)
Committed too early or to wrong branch? Here’s how to undo commits without losing your work, depending on whether you’ve pushed or not. Scenario 1: Undo Last Commit (Not Pushed Yet) # Keep changes in working directory (most common) git reset –soft HEAD~1 # Now your changes are uncommitted, ready to re-commit # Use case: […]
AJAX: Use Axios Interceptors to Automatically Retry Failed Requests
Network hiccups causing failed API requests? Axios interceptors can automatically retry failed requests before showing errors to users. Install Axios: npm install axios The Basic Retry Interceptor: import axios from ‘axios’; // Configure retry axios.interceptors.response.use( response => response, // Success – return as is async error => { const config = error.config; // If no […]
JavaScript: Use Optional Chaining to Prevent ‘Cannot Read Property of Undefined’ Errors
Your app crashes with “Cannot read property ‘name’ of undefined”? Optional chaining (?.) safely accesses nested properties without try-catch blocks. The Error-Prone Old Way: const user = getUserData(); // Might return null // ❌ This crashes if user is null/undefined const name = user.profile.name; // TypeError: Cannot read property ‘profile’ of undefined // ❌ Traditional […]
HTML5: Use Picture Element for Responsive Images (Better Than srcset)
Serving same 4K image to mobile users? Picture element lets you serve different images per device, saving 80% bandwidth and loading 3x faster. The Old Way – One Image for All: <img src=”hero-4k.jpg” alt=”Hero” /> <!– Problems: – Mobile downloads 5MB 4K image – Only displays 800px wide on phone – Wasted 80% of bandwidth […]
CSS: Create Smooth Skeleton Loading Screens with Pure CSS (No JavaScript)
Loading spinners look outdated. Modern sites use skeleton screens that show content placeholders while data loads. Pure CSS, no libraries needed. The Basic Skeleton: .skeleton { background: linear-gradient( 90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75% ); background-size: 200% 100%; animation: loading 1.5s infinite; border-radius: 4px; } @keyframes loading { 0% { background-position: 200% 0; } […]
Windows 11: Bring Back Classic Right-Click Context Menu Permanently
Tired of the simplified Windows 11 right-click menu that hides all useful options behind “Show more options”? Get the full Windows 10 menu back. The Problem: Windows 11 right-click menu shows: – Cut, Copy, Paste – Rename, Delete – “Show more options” → Opens full menu Extra click needed for: – Send to – Open […]
Windows 11: Disable Bing Search in Start Menu to Get Instant Local Results
Start Menu searches taking 5 seconds because Windows is searching Bing? Disable web search to get instant local file/app results. The Annoying Problem: You type “calc” in Start Menu Windows searches: 1. Local apps (0.1 seconds) 2. Bing web search (5 seconds loading…) 3. Shows web results you don’t want Result: 5 second delay just […]
AI Prompt: Analyze Contracts and Legal Documents to Find Hidden Fees and Unfair Terms
Signing a lease, employment contract, or service agreement? AI can highlight hidden fees, unfair clauses, and red flags you might miss. The Contract Analysis Prompt: I need help analyzing a legal contract before signing. **Document Type:** [e.g., Apartment Lease, Employment Contract, Service Agreement, Phone Plan] **Full Contract Text:** [Paste entire contract here] **What I Need:** […]
AI Prompt: Transform Any Recipe to Match Your Dietary Restrictions and Available Ingredients
Found the perfect recipe but you’re vegan, gluten-free, or missing half the ingredients? AI can adapt any recipe to your needs while keeping it delicious. The Recipe Adaptation Prompt: I need help adapting a recipe to my dietary needs and available ingredients. **Original Recipe:** [Paste entire recipe here – ingredients and instructions] **Dietary Restrictions:** [e.g., […]
AI Prompt: Diagnose Home Repair Issues with Photos and Get Step-by-Step Fix Instructions
Strange noise from your HVAC? Leak under the sink? Use AI to diagnose and get repair instructions without calling an expensive technician. The Diagnostic Prompt Template: I need help diagnosing and fixing a home repair issue. **The Problem:** [Describe what’s wrong: noise, leak, not working, etc.] **Location:** [Where: kitchen sink, basement furnace, bedroom ceiling, etc.] […]
Docker: Clean Up Disk Space by Removing Unused Images and Containers
Docker eating 50GB of disk space? Old images, stopped containers, and dangling volumes pile up fast. One command reclaims it all. Check Current Disk Usage: docker system df # Output: TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 47 12 28.5GB 18.2GB (63%) Containers 89 5 10.2GB 9.8GB (96%) Local Volumes 23 8 2.3GB 1.1GB (47%) Build […]
Kubernetes: Force Delete Stuck Pods in Terminating State Instantly
Pod stuck in “Terminating” state for hours? Kubernetes is waiting for graceful shutdown that will never complete. Force delete it properly. The Problem: # Pod stuck forever kubectl get pods NAME STATUS AGE stuck-pod-abc123 Terminating 3h # Normal delete doesn’t work kubectl delete pod stuck-pod-abc123 # Still shows Terminating… Why Pods Get Stuck: When deleting […]
WordPress: Limit Login Attempts Without Plugins Using .htaccess
Brute force bots hammering wp-login.php with 1000s of password attempts? Block them at Apache level before they even reach WordPress. The Plugin-Free Solution: Add to .htaccess in WordPress root: # Limit wp-login.php access to specific IPs <Files wp-login.php> Order Deny,Allow Deny from all Allow from YOUR_IP_ADDRESS Allow from YOUR_OFFICE_IP </Files> Replace YOUR_IP_ADDRESS with your actual […]
WordPress: Speed Up Admin Dashboard by Disabling Heartbeat API
WordPress admin panel sluggish and using 100% CPU? The Heartbeat API polls your server every 15 seconds for autosave and notifications, eating resources. What Heartbeat Does: Every 15 seconds: – Check for new comments – Check for plugin updates – Autosave post drafts – Notify about other users editing same post – Trigger scheduled tasks […]
Photoshop: Fix Blurry Text After Transform with This One Setting
Scaled or rotated text looks blurry and pixelated? Photoshop’s transform interpolation is set wrong. One checkbox fixes it permanently. The Blurry Text Problem: 1. Create text layer 2. Ctrl+T to transform 3. Scale up 200% 4. Text looks jagged and blurry Why? Photoshop is treating vector text like pixels! The Permanent Fix: Edit → Preferences […]
Photoshop: Batch Resize 1000 Images in 30 Seconds Without Actions
Need to resize hundreds of images for web? Skip the tedious Actions panel – Image Processor is faster and requires zero setup. The Old Tedious Way: 1. Create Action 2. Record resize steps 3. File → Automate → Batch 4. Configure 10+ settings 5. Hope it works = 10 minutes setup + easy to mess […]
Visual Studio: Stop Debugger from Stepping Into .NET Framework Source Code
Debugging your code but accidentally stepping into framework methods like String.Format() or Linq internals? This wastes precious debugging time. The Annoying Problem: var users = GetUsers(); var result = users.Where(u => u.IsActive).ToList(); // Press F11 here // Debugger jumps into: // → Enumerable.cs (framework code) // → Buffer.cs // → List.cs // You just wanted […]
HTML5 Web Workers: Run JavaScript in Background Thread Without Freezing UI
Heavy JavaScript computation freezing your webpage? Web Workers run code in a separate thread, keeping your UI responsive. The UI Freezing Problem: // ❌ BAD: Blocks UI for 5 seconds function processLargeData() { const data = Array.from({ length: 10000000 }, (_, i) => i); const result = data .filter(n => n % 2 === 0) […]
SQL: When CTEs Kill Performance and You Should Use Temp Tables Instead
Common Table Expressions (CTEs) make queries readable but can cause performance disasters when SQL Server evaluates them multiple times. The CTE Performance Trap: — ❌ BAD: CTE evaluated 3 times! WITH RecentOrders AS ( SELECT CustomerId, OrderDate, Total FROM Orders WHERE OrderDate >= DATEADD(month, -1, GETDATE()) — Complex calculation that takes 5 seconds ) SELECT […]
SQL Indexing: Why Your Query Ignores Indexes and Scans 10 Million Rows Instead
Created an index but your query still takes 30 seconds? SQL Server might be ignoring it due to implicit conversions, functions, or wildcard positioning. Index Killer #1 – Functions on Indexed Columns: — Index exists on CreatedDate CREATE INDEX IX_Orders_CreatedDate ON Orders(CreatedDate); — ❌ BAD: Index ignored, full table scan SELECT * FROM Orders WHERE […]
C# String Interpolation: Use $”” for Readability, StringBuilder for Performance
Building strings in loops? String interpolation is clean but creates a new string on every concatenation. Here’s when to use what. The Readability Winner: // Old way – hard to read string message = “User ” + userName + ” (ID: ” + userId + “) logged in at ” + timestamp; // Modern way […]
LINQ Performance Trap: Why .Any() Is 10,000x Faster Than .Count() > 0
Using .Count() > 0 to check if a collection has items? You’re forcing LINQ to enumerate the entire collection just to answer a yes/no question. The Performance Killer: var users = dbContext.Users.Where(u => u.IsActive); // BAD: Counts ALL active users first if (users.Count() > 0) { Console.WriteLine(“We have active users”); } // Database query generated: […]
C# Pattern Matching: Replace Complex If-Else Chains with Switch Expressions
Nested if-else statements making your code unreadable? C# 9+ switch expressions with pattern matching can reduce 50+ lines to 10. The Old Nightmare: public decimal CalculateDiscount(Customer customer, Order order) { if (customer == null) return 0; if (customer.IsPremium) { if (order.Total > 1000) return order.Total * 0.20m; else if (order.Total > 500) return order.Total * […]
C# Records: Immutable Data Classes with Built-In Value Equality (C# 9+)
Tired of writing boilerplate Equals, GetHashCode, and ToString methods? C# records do it automatically with better performance. Old Way – Traditional Class: // BAD: 60+ lines for simple data class public class Person { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } […]
C#: Async/Await Common Mistakes That Kill Performance (And How to Fix Them)
Using async/await everywhere doesn’t automatically make your code faster – it can actually make it slower if done wrong. Here are the critical mistakes. Mistake 1: Async All The Way Down (Unnecessarily): // BAD: Unnecessary async overhead public async Task GetUserIdAsync(string username) { return await Task.FromResult(_cache.Get(username)); // Why async? } // This creates a Task, […]
C# Performance: Use Span and Memory to Eliminate Array Allocations
Processing large arrays or strings eating up memory? Span<T> lets you work with slices of memory without allocating new arrays. The Problem – Traditional Approach: // BAD: Creates new array on every call public byte[] ProcessChunk(byte[] data, int start, int length) { byte[] chunk = new byte[length]; // Heap allocation Array.Copy(data, start, chunk, 0, length); […]



























