Checking scroll position with events is inefficient. Intersection Observer detects when element enters viewport. Setup: const loadMoreTrigger = document.getElementById(‘load-more’); const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { loadMoreData(); // Fetch next page } }); }); observer.observe(loadMoreTrigger); async function loadMoreData() { const response = await fetch(‘/api/posts?page=’ + currentPage); const data = […]
Author: ErcanOPAK
JavaScript: Use Nullish Coalescing (??) to Handle Only Null/Undefined
|| operator treats 0 and ” as falsy. ?? only checks null/undefined. Problem with ||: const count = 0; const display = count || 10; // Returns 10 (wrong!) // 0 is falsy, so falls back to 10 Solution with ??: const count = 0; const display = count ?? 10; // Returns 0 (correct!) […]
HTML5: Use datalist for Autocomplete Input Without JavaScript
Building autocomplete manually with JavaScript is complex. Datalist provides native autocomplete. HTML: <input list=”browsers” name=”browser” placeholder=”Choose browser”> <datalist id=”browsers”> <option value=”Chrome”> <option value=”Firefox”> <option value=”Safari”> <option value=”Edge”> <option value=”Opera”> </datalist> User types, browser shows matching suggestions. No JavaScript needed! Features: – Filters as user types – Can still type custom value – Fully accessible – […]
CSS: Use Custom Properties (CSS Variables) for Dynamic Theming
Changing colors throughout CSS is tedious. CSS variables centralize values for easy updates. Define Variables: :root { –primary-color: #3498db; –secondary-color: #2ecc71; –font-size-base: 16px; –spacing-unit: 8px; } Use Variables: button { background: var(–primary-color); font-size: var(–font-size-base); padding: calc(var(–spacing-unit) * 2); } Dynamic Theming: /* Light theme (default) */ :root { –bg-color: white; –text-color: black; } /* Dark […]
Windows 11: Use Task Manager Performance Tab for Real-Time System Monitoring
System slow but don’t know why? Task Manager Performance tab shows real-time resource usage. Open: Ctrl+Shift+Esc → Performance tab What You See: – CPU usage per core – Memory usage (RAM) – Disk read/write speed – Network usage – GPU usage (if gaming/rendering) Find Bottleneck: CPU 100%: CPU bottleneck Memory 90%+: Need more RAM Disk […]
Windows 11: Use Widgets for Quick Info Without Opening Apps
Opening apps to check weather or calendar is slow. Widgets show info at a glance. Open Widgets: Win+W or click widgets icon in taskbar Available Widgets: – Weather forecast – Calendar events – To-Do tasks – News feed – Stock prices – Sports scores – Photos memories – Traffic info Customize: Click “+” to add […]
AI Prompt: Create Comprehensive README for GitHub Project
README writing is tedious. AI creates professional documentation from your code. The Prompt: Create README.md for this project: Project description: [Brief description] Main files: [List key files] Tech stack: [Languages/frameworks] Purpose: [What it does] Include: – Project title with badges – Description – Features list – Installation steps – Usage examples – Configuration options – […]
AI Prompt: Summarize YouTube Video from Transcript
Long video but need quick summary? AI extracts key points from transcript. Get Transcript: Use YouTube transcript feature or browser extension The Prompt: Summarize this video transcript: [Paste transcript] Provide: 1. 3-sentence summary 2. Key points (bullet list) 3. Main takeaways 4. Timestamps for important sections (if mentioned) 5. Action items (if tutorial/how-to) Format for […]
AI Prompt: Brainstorm Creative Solutions to Business Problems
Stuck on business challenge? AI generates creative approaches you might not consider. The Prompt: I’m facing this business challenge: [Describe problem in detail] Our constraints: – Budget: [amount] – Timeline: [timeframe] – Team size: [number] – Must avoid: [limitations] Generate 10 creative solutions: 1. Include unconventional approaches 2. Mix of low-cost and premium options 3. […]
Docker: Use Multi-Stage Builds to Reduce Final Image Size by 90%
Including build tools in final image wastes space. Multi-stage builds separate build and runtime. Single-Stage (Large): FROM node:18 WORKDIR /app COPY . . RUN npm install # Includes dev dependencies RUN npm run build CMD [“node”, “dist/server.js”] # Result: 1.2 GB (includes npm, build tools) Multi-Stage (Small): # Stage 1: Build FROM node:18 AS builder […]
Kubernetes: Use ConfigMaps to Store Configuration Separately from Pods
Hardcoding config in containers requires rebuilding images. ConfigMaps separate config from code. Create ConfigMap: kubectl create configmap app-config \ –from-literal=API_URL=https://api.example.com \ –from-literal=MAX_RETRIES=3 Use in Pod: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 envFrom: – configMapRef: name: app-config Change config without rebuilding image – just update ConfigMap! Update ConfigMap: […]
WordPress: Use WP_Query Instead of query_posts for Custom Loops
query_posts() breaks main query and causes issues. WP_Query is the proper way to create custom loops. Wrong Way (Don’t Use): query_posts(‘cat=5&posts_per_page=10’); // Breaks pagination, conflicts with main query Right Way: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘category__in’ => array(5) ); $custom_query = new WP_Query($args); if ($custom_query->have_posts()) { while ($custom_query->have_posts()) { $custom_query->the_post(); the_title(); […]
WordPress: Use add_image_size() to Create Custom Thumbnail Sizes
WordPress default thumbnail sizes don’t fit your design? Create custom sizes. Add to functions.php: // Create custom thumbnail size add_image_size(‘custom-thumb’, 400, 300, true); // Parameters: name, width, height, crop (true/false) // Multiple sizes add_image_size(‘hero-image’, 1920, 600, true); add_image_size(‘product-thumb’, 300, 300, true); add_image_size(‘blog-featured’, 800, 400, true); Use in Templates: the_post_thumbnail(‘custom-thumb’); // Or get URL: $url = […]
Photoshop: Use Layer Styles to Add Drop Shadow, Glow, Stroke Non-Destructively
Adding effects with filters is permanent. Layer Styles are editable anytime. Add Layer Style: Right-click layer → Blending Options → Check effects you want Popular Effects: – Drop Shadow: Adds depth – Inner/Outer Glow: Neon effects – Stroke: Outline around layer – Bevel and Emboss: 3D effect – Gradient Overlay: Color gradient on layer Benefits: […]
Photoshop: Use Clipping Masks to Apply Adjustments to Single Layer
Adjustment layer affecting all layers? Clip it to apply to only one layer below. Create Clipping Mask: 1. Add adjustment layer above target layer 2. Alt+Click between the two layers 3. Adjustment only affects layer below! Or: Right-click adjustment layer → Create Clipping Mask Visual Indicator: Arrow pointing down = clipped to layer below Example: […]
Visual Studio: Attach to Process for Debugging Running Applications
Need to debug app that’s already running? Attach debugger instead of restarting from VS. Steps: 1. Debug → Attach to Process (Ctrl+Alt+P) 2. Find your process (e.g., MyApp.exe, w3wp.exe for IIS) 3. Click Attach Debugger attaches to running process – breakpoints work immediately! Common Use Cases: – Debug production issues on server – Debug Windows […]
C#: Use Tuple Deconstruction in foreach for Dictionary Iteration
Dictionary foreach with KeyValuePair is verbose. Tuple deconstruction makes it clean. Old Verbose Way: var scores = new Dictionary { [“Alice”] = 95, [“Bob”] = 87, [“Charlie”] = 92 }; foreach (KeyValuePair kvp in scores) { Console.WriteLine($”{kvp.Key}: {kvp.Value}”); } Clean Deconstruction: foreach (var (name, score) in scores) { Console.WriteLine($”{name}: {score}”); } // Or with types: […]
C#: Use var Pattern in Switch Expressions for Type Matching
Checking object types with multiple if-else is messy. Switch expressions with type patterns are cleaner. Old If-Else Chain: object obj = GetData(); if (obj is string s) { Console.WriteLine($”String: {s.Length} chars”); } else if (obj is int i) { Console.WriteLine($”Number: {i * 2}”); } else if (obj is List list) { Console.WriteLine($”List: {list.Count} items”); } […]
SQL: Use TRY_CAST Instead of CAST to Avoid Conversion Errors
CAST throws error on invalid data. TRY_CAST returns NULL instead – safer for user input. CAST – Throws Error: SELECT CAST(‘123’ AS INT); — Works: 123 SELECT CAST(‘abc’ AS INT); — Error: Conversion failed! — Query crashes, returns nothing TRY_CAST – Returns NULL: SELECT TRY_CAST(‘123’ AS INT); — Returns: 123 SELECT TRY_CAST(‘abc’ AS INT); — […]
SQL: Use ISNULL vs COALESCE Correctly for Best Performance
Both replace NULL values but work differently. ISNULL is faster, COALESCE is more flexible. ISNULL – SQL Server Specific: — Takes exactly 2 arguments, returns first if not null SELECT ISNULL(MiddleName, ”) AS MiddleName FROM Users; — Faster – compiled inline — Data type from first argument COALESCE – ANSI Standard: — Takes 2+ arguments, […]
.NET Core: Use BackgroundService for Long-Running Tasks
Need background job in your ASP.NET app? BackgroundService is built-in – no Hangfire or Quartz needed. Create Background Service: public class EmailCleanupService : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { // Do work await CleanupOldEmails(); // Wait 1 hour await Task.Delay(TimeSpan.FromHours(1), stoppingToken); } } private async Task CleanupOldEmails() { // […]
.NET Core: Use IConfiguration.GetValue for Type-Safe Config Reading
Parsing config strings manually is error-prone. GetValue handles conversion automatically. Manual Parsing (Error-Prone): // appsettings.json: “MaxRetries”: “3” var maxRetries = int.Parse(_config[“MaxRetries”]); // NullReferenceException if key missing! // FormatException if value is not a number! Type-Safe GetValue: var maxRetries = _config.GetValue(“MaxRetries”, defaultValue: 5); // Returns 3 if exists // Returns 5 if missing or invalid // […]
Git: Use git blame -L to See Who Changed Specific Lines
Whole file blame is overwhelming. See only who changed specific lines you care about. Blame Specific Line Range: # See who changed lines 50-60 git blame -L 50,60 file.js # See who changed from line 100 to end git blame -L 100,+1000 file.js Ignore Whitespace Changes: # Ignore commits that only changed indentation git blame […]
Git: Use git commit –fixup to Easily Amend Older Commits
Found a typo in commit from 5 commits ago? –fixup marks it for automatic squashing later. Create Fixup Commit: # Find commit hash to fix git log –oneline # abc1234 Add user authentication # def5678 Add email validation ← Want to fix this # Make your fix, then: git add . git commit –fixup def5678 […]
AJAX: Use URLSearchParams to Build Query Strings Cleanly
Manually concatenating query strings is error-prone. URLSearchParams handles encoding and formatting automatically. Messy Manual Way: const query = ‘?name=’ + encodeURIComponent(name) + ‘&email=’ + encodeURIComponent(email) + ‘&age=’ + age; fetch(‘/api/users’ + query); // Easy to forget encoding, messy to read Clean URLSearchParams Way: const params = new URLSearchParams({ name: ‘John Doe’, email: ‘john@example.com’, age: 30 […]
JavaScript: Use replaceAll() Instead of regex.replace() for Simple Text Replacement
Replacing all occurrences with regex is overkill. replaceAll() is simpler and more readable. Old Regex Way: const text = “Hello World, Hello Universe”; const result = text.replace(/Hello/g, “Hi”); // “Hi World, Hi Universe” // Easy to mess up – forget ‘g’ flag and only first is replaced! New replaceAll() Way: const text = “Hello World, […]
HTML5: Use dialog Element for Native Modals Without JavaScript Libraries
Bootstrap modals require heavy JavaScript. HTML5 dialog element is native, lightweight, and fully accessible. HTML: <dialog id=”myDialog”> <h2>Modal Title</h2> <p>Modal content here</p> <button onclick=”closeDialog()”>Close</button> </dialog> <button onclick=”openDialog()”>Open Modal</button> JavaScript: function openDialog() { document.getElementById(‘myDialog’).showModal(); } function closeDialog() { document.getElementById(‘myDialog’).close(); } // Close on backdrop click myDialog.addEventListener(‘click’, (e) => { if (e.target === myDialog) myDialog.close(); }); Features: […]
CSS: Use clamp() for Responsive Font Sizes Without Media Queries
Setting font sizes for mobile, tablet, desktop with media queries is tedious. clamp() does it automatically. Old Way – Multiple Media Queries: h1 { font-size: 24px; } @media (min-width: 768px) { h1 { font-size: 32px; } } @media (min-width: 1200px) { h1 { font-size: 48px; } } New Way – One Line: h1 { font-size: […]
Windows 11: Use Quick Settings to Toggle Wi-Fi, Bluetooth Without Opening Settings
Opening Settings app to toggle Wi-Fi is slow. Quick Settings panel gives instant access to common toggles. Open Quick Settings: Click Wi-Fi/Sound/Battery icons in system tray Or press Win + A Quick Toggles Available: Wi-Fi on/off Bluetooth on/off Airplane mode Battery saver Night light Focus assist Screen brightness slider Volume slider Customize: Click pencil icon […]





























