Want immutable objects but constructors with 10 parameters are ugly? Use init accessors. Old Way – Constructor Overload Hell: public class Person { public string Name { get; } public int Age { get; } public string Email { get; } public Person(string name, int age, string email) { Name = name; Age = age; […]
Day: February 13, 2026
C#: Use Index and Range Operators for Cleaner Array Slicing
Array slicing with loops or LINQ is verbose. C# 8+ has Python-like syntax. Old Way: var numbers = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Get last element var last = numbers[numbers.Length – 1]; // 9 // Get last 3 elements var lastThree = numbers.Skip(numbers.Length – 3).ToArray(); // […]
C#: Use Null-Coalescing Assignment to Simplify Lazy Initialization
Checking if null before initializing is verbose. Use ??= operator for clean lazy initialization. Old Verbose Way: private List _cache; public List GetCache() { if (_cache == null) { _cache = new List(); } return _cache; } Clean Way: private List _cache; public List GetCache() { _cache ??= new List(); return _cache; } // If […]
SQL: Use CHAR Instead of VARCHAR for Fixed-Length Columns to Save Space
Storing 2-letter country codes as VARCHAR(50)? Use CHAR for fixed-length data to optimize storage. When to Use CHAR: — Always exactly 2 characters CountryCode CHAR(2) — ‘US’, ‘UK’, ‘FR’ — Always exactly 1 character IsActive CHAR(1) — ‘Y’ or ‘N’ — Fixed format PhoneArea CHAR(3) — ‘555’, ‘212’, ‘415’ When to Use VARCHAR: — Variable […]
SQL: Use CROSS APPLY Instead of Subqueries for Better Performance
Correlated subqueries run once per row. CROSS APPLY runs more efficiently and is easier to read. Slow Subquery: SELECT c.CustomerName, (SELECT TOP 1 OrderDate FROM Orders o WHERE o.CustomerId = c.Id ORDER BY OrderDate DESC) AS LastOrderDate FROM Customers c; — Runs subquery for EVERY customer Fast CROSS APPLY: SELECT c.CustomerName, o.OrderDate AS LastOrderDate FROM […]
.NET Core: Use Required Modifier to Force Property Initialization
Tired of null reference exceptions because someone forgot to set a property? Make it required. Old Problem: public class User { public string Name { get; set; } // Can be null! public string Email { get; set; } // Can be null! } var user = new User(); // Compiles fine Console.WriteLine(user.Name.Length); // NullReferenceException! […]
.NET Core: Use Global Using Directives to Avoid Repeating Imports
Typing the same using statements in every file? Declare them globally once. Create GlobalUsings.cs: // GlobalUsings.cs global using System; global using System.Collections.Generic; global using System.Linq; global using System.Threading.Tasks; global using Microsoft.EntityFrameworkCore; Now these namespaces are available in ALL files automatically! Your Other Files: // ProductService.cs // No using statements needed! public class ProductService { private […]
Git: Use git restore to Unstage Files Without Losing Changes
Accidentally staged files you didn’t mean to commit? git restore unstages them without deleting changes. Unstage Specific File: # Staged config.json by mistake git add config.json # Unstage it (keeps changes in working directory) git restore –staged config.json Unstage All Files: git restore –staged . Discard Changes (Careful!): # Unstage AND discard changes git restore […]
Git: Use git bisect to Find Which Commit Introduced a Bug
Bug appeared somewhere in last 100 commits but don’t know where? Git bisect does binary search to find the exact commit. Start Bisect: # Mark current commit as bad git bisect start git bisect bad # Mark last known good commit (e.g., a week ago) git bisect good abc1234 Git Checks Out Middle Commit: # […]
AJAX: Use Fetch with Signal to Cancel Requests When User Navigates Away
User navigates away but old fetch requests keep running in background. Cancel them properly with AbortController. Setup: const controller = new AbortController(); fetch(‘/api/data’, { signal: controller.signal }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => { if (error.name === ‘AbortError’) { console.log(‘Request cancelled’); } }); // Cancel when user leaves page window.addEventListener(‘beforeunload’, () => { […]
JavaScript: Use structuredClone() to Deep Copy Objects
JSON.parse(JSON.stringify()) is clunky and breaks on Dates/Functions. Use structuredClone() instead. Old Unreliable Way: const original = { name: ‘John’, date: new Date() }; const copy = JSON.parse(JSON.stringify(original)); console.log(copy.date); // String, not Date! ❌ New Built-In Way: const original = { name: ‘John’, date: new Date(), nested: { deep: { value: 42 } } }; const […]
HTML5: Use details and summary Tags for Native Accordions
No JavaScript or libraries needed for accordions. HTML5 has native collapsible elements. Basic Accordion: <details> <summary>Click to expand</summary> <p>Hidden content here. Shows when user clicks.</p> </details> Open by Default: <details open> <summary>Already expanded</summary> <p>Content visible on load.</p> </details> Style It: summary { cursor: pointer; font-weight: bold; padding: 10px; background: #f0f0f0; } summary:hover { background: #e0e0e0; […]
CSS: Use :has() Selector to Style Parent Based on Child
Always wanted to style parent based on what’s inside? CSS :has() makes it possible – no JavaScript needed. Example – Highlight Card If It Has Sale Badge: /* Style card differently if it contains .sale badge */ .card:has(.sale) { border: 3px solid red; background: #fff3f3; } More Examples: /* Form with errors gets red border […]
Windows 11: Use Voice Typing to Write Without Keyboard
Type faster by talking. Windows 11 voice typing is surprisingly accurate. Activate: Press Win + H anywhere you can type Features: Automatic punctuation (says “comma” or “period”) Works in any app (Word, Notepad, browser) Multiple languages supported Offline mode available Voice Commands: “New line” – Press Enter “Delete that” – Remove last word “Go to […]
Windows 11: Use Focus Sessions to Block Distractions with Pomodoro Timer
Need focused work time? Windows 11 has built-in Pomodoro timer with DND mode. Enable: Clock app → Focus Sessions tab Features: Set work duration (25, 45, or custom minutes) Auto-enables Do Not Disturb Breaks reminders Spotify integration (plays focus music) Daily/weekly progress tracking During Session: Notifications silenced automatically Timer visible in system tray Microsoft To […]
AI Prompt: Generate Regex Patterns with Explanation and Test Cases
Struggling with regex syntax? AI writes the pattern and explains how it works. The Prompt: Create a regex pattern that matches: – US phone numbers in formats: (555) 123-4567, 555-123-4567, 5551234567 Provide: 1. The regex pattern 2. Explanation of each part 3. 5 test cases (3 valid, 2 invalid) 4. Code example in JavaScript AI […]
AI Prompt: Convert Handwritten Notes Photo to Formatted Markdown
Took handwritten meeting notes on paper? AI transcribes and formats them into clean digital text. The Prompt: Transcribe this handwritten note image into clean Markdown format: [Upload photo of handwritten notes] Requirements: – Fix any unclear words (best guess) – Organize into bullet points or numbered lists – Use headers for main topics – Bold […]
AI Prompt: Analyze Email Thread and Summarize Action Items by Person
Long email chains with scattered tasks? AI extracts who needs to do what. The Prompt: Analyze this email thread and create action items organized by person: [Paste entire email thread] Format: **John:** – [ ] Task 1 (due: date if mentioned) – [ ] Task 2 **Sarah:** – [ ] Task 3 **No owner assigned:** […]
Docker: Use .dockerignore to Speed Up Builds and Reduce Image Size
Copying node_modules, .git, and cache files into images wastes time and space. Exclude them with .dockerignore. Create .dockerignore in project root: node_modules npm-debug.log .git .gitignore *.md .env .vscode .idea **/*.log **/dist **/bin **/obj Impact: Without .dockerignore: – Build time: 45 seconds – Image size: 850 MB (includes node_modules) With .dockerignore: – Build time: 8 seconds […]
Kubernetes: Use kubectl diff Before Applying Changes to Preview Impact
Applying YAML changes blindly is risky. Preview exactly what will change first. Before Applying: # See what kubectl apply will change kubectl diff -f deployment.yaml # Output shows: # – Lines being removed # + Lines being added # ~ Lines being modified Safe Workflow: # 1. Check diff kubectl diff -f deployment.yaml # 2. […]
WordPress: Disable Post Revisions to Reduce Database Bloat
WordPress saves every draft edit as revision. Posts with 100+ revisions bloat your database. Limit Revisions in wp-config.php: // Keep only last 3 revisions define(‘WP_POST_REVISIONS’, 3); // Or disable completely define(‘WP_POST_REVISIONS’, false); Add above /* That’s all, stop editing! */ line. Clean Existing Revisions: Install “WP-Optimize” plugin → Database tab → Remove all post revisions […]
WordPress: Disable XML-RPC to Block Brute Force Attacks
XML-RPC is exploited for DDoS and brute force attacks. Most sites don’t need it – disable for security. Add to .htaccess: # Block xmlrpc.php <Files xmlrpc.php> Order Deny,Allow Deny from all </Files> Or Use Plugin: Install “Disable XML-RPC” plugin (one-click disable) Check If You Need It: XML-RPC is only needed for: Jetpack plugin Mobile apps […]
Photoshop: Use Camera Raw Filter for Quick Professional Color Grading
Color grading doesn’t require 10 different adjustment layers. Camera Raw Filter has everything in one place. Apply to Any Layer: Filter → Camera Raw Filter (or Ctrl+Shift+A) Quick Adjustments: Basic: Exposure, Contrast, Highlights, Shadows in one panel Color Grading: Split toning for highlights/shadows separately Curves: RGB curves with precise control HSL: Adjust specific color ranges […]
Photoshop: Use Adjustment Layers Instead of Directly Editing to Stay Non-Destructive
Adjusting brightness/contrast directly on layers destroys original pixels. Use Adjustment Layers to edit non-destructively. Wrong Way: Image → Adjustments → Brightness/Contrast (Permanent change, can’t undo later) Right Way: Layer → New Adjustment Layer → Brightness/Contrast (Can adjust anytime, original untouched) Benefits: Change settings anytime – double-click adjustment layer Toggle on/off to see before/after Delete adjustment […]
Visual Studio: Use Code Cleanup on Save to Auto-Format Code
Manually fixing formatting issues wastes time. Let Visual Studio auto-format every time you save. Setup: Tools → Options → Text Editor → Code Cleanup → Check “Run Code Cleanup profile on Save” Choose profile: Full Cleanup What It Does: // Before save (messy): public void test(){int x=5;var y=10;Console.WriteLine(x+y);} // After save (clean): public void Test() […]
CSS: Use aspect-ratio Property Instead of Padding Hack
Maintaining aspect ratios with padding-bottom: 56.25% trick is outdated. Use aspect-ratio property. Old Way: .video-container { position: relative; padding-bottom: 56.25%; /* 16:9 ratio */ height: 0; } .video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } New Way: .video-container { aspect-ratio: 16 / 9; } That’s it! Works for any […]
Windows 11: Snap Windows into Layouts with One Click
Manually resizing windows to fit side-by-side? Snap Layouts does it automatically. How: Hover mouse over Maximize button → Grid of layouts appears → Click desired layout Or Use Keyboard: Win + Z → Shows snap layouts → Arrow keys to select → Enter Layouts Available: – 2 windows (50/50) – 3 windows (33/33/33) – 4 […]
Windows 11: Never Lose Clipboard History Again with Built-in Manager
Copied something important but copied something else over it? Windows 11 stores clipboard history. Enable: Settings → System → Clipboard → Turn on “Clipboard history” Use: Press Win + V to see last 25 copied items Click any item to paste it. Pin frequently used items to keep them forever. Pro Tip: Works across devices […]
AI Prompt: Generate Realistic Test Data for Development
Need 100 fake users for testing? AI generates realistic test data instantly. The Prompt: Generate 50 realistic user records as JSON with: – First name, last name – Email (use fake domains) – Phone number (US format) – Address (real US cities, fake street addresses) – Birthday (ages 18-80) – Account balance (random $0-$10,000) Make […]
AI Prompt: Simplify Legal Documents into Plain English
Can’t understand your rental agreement or terms of service? AI translates legalese into normal language. The Prompt: Explain this legal text in simple terms a 10-year-old would understand: [Paste legal paragraph] Highlight any: – Important obligations I’m agreeing to – Risks or penalties – Red flags I should know about Example: Legal: “Party A hereby […]





























