Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Author: ErcanOPAK

Windows

Windows 11: Use God Mode to Access All Settings in One Folder

- 14.02.26 - ErcanOPAK comment on Windows 11: Use God Mode to Access All Settings in One Folder

Tired of hunting through Settings app? God Mode creates folder with every Windows setting in one place. Enable God Mode: 1. Right-click Desktop → New → Folder 2. Name it exactly: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C} 3. Press Enter Folder icon changes and opens to show 300+ settings organized by category! What’s Inside: Administrative Tools Backup and Restore Color […]

Read More
AI

AI Prompt: Create Excel Formulas from Description of What You Want to Calculate

- 14.02.26 - ErcanOPAK comment on AI Prompt: Create Excel Formulas from Description of What You Want to Calculate

Excel formulas syntax confusing? Describe what you want in plain English, get working formula. The Prompt: Create Excel formula for: I have: – Column A: Product names – Column B: Prices – Column C: Quantities sold I want in Column D: Total revenue (price × quantity), but only for products starting with “Pro-” If quantity […]

Read More
AI

AI Prompt: Generate SQL Queries from Plain English Descriptions

- 14.02.26 - ErcanOPAK comment on AI Prompt: Generate SQL Queries from Plain English Descriptions

Know what data you need but struggling with SQL syntax? AI writes the query for you. The Prompt: Write SQL query for this: Database: Ecommerce Tables: Users (id, name, email), Orders (id, user_id, total, created_at) I need: Top 10 customers by total order value in last 30 days Also explain what each part does. AI […]

Read More
AI

AI Prompt: Debug Code by Explaining Error Message in Plain English

- 14.02.26 - ErcanOPAK comment on AI Prompt: Debug Code by Explaining Error Message in Plain English

Cryptic error messages confusing you? AI explains what they mean and how to fix them. The Prompt: I got this error in [language/framework]: [Paste full error message and stack trace] Please explain: 1. What this error means in plain English 2. What likely caused it 3. How to fix it with code example 4. How […]

Read More
Docker

Docker: UseHealthCheck to Auto-Restart Unhealthy Containers

- 14.02.26 - ErcanOPAK comment on Docker: UseHealthCheck to Auto-Restart Unhealthy Containers

Container running but app inside crashed? Add HEALTHCHECK to auto-detect and restart failed containers. Add to Dockerfile: FROM node:18 WORKDIR /app COPY . . # Check if app responds on port 3000 HEALTHCHECK –interval=30s –timeout=3s –retries=3 \ CMD curl -f http://localhost:3000/health || exit 1 CMD [“node”, “server.js”] What Happens: Every 30 seconds, Docker runs health […]

Read More
Kubernetes

Kubernetes: Use kubectl top to Monitor Real-Time Resource Usage

- 14.02.26 - ErcanOPAK comment on Kubernetes: Use kubectl top to Monitor Real-Time Resource Usage

Want to see CPU/Memory usage without installing monitoring tools? kubectl top shows real-time stats. Node Resource Usage: kubectl top nodes # Output: # NAME CPU MEMORY # node-1 45% 2.5Gi # node-2 23% 1.8Gi Pod Resource Usage: kubectl top pods # Or specific namespace: kubectl top pods -n production # Sort by CPU: kubectl top […]

Read More
Wordpress

WordPress: Show Different Menus to Logged-In vs Logged-Out Users

- 14.02.26 - ErcanOPAK comment on WordPress: Show Different Menus to Logged-In vs Logged-Out Users

Want different navigation for members vs visitors? WordPress has built-in conditional menu display. Create Two Menus: Appearance → Menus 1. “Public Menu” (for visitors) 2. “Member Menu” (for logged-in users) Add to functions.php: function conditional_menu() { if (is_user_logged_in()) { wp_nav_menu(array(‘theme_location’ => ‘member-menu’)); } else { wp_nav_menu(array(‘theme_location’ => ‘public-menu’)); } } In header.php, replace: <?php wp_nav_menu(); […]

Read More
Wordpress

WordPress: Add Custom Login Logo Without Plugin Using functions.php

- 14.02.26 - ErcanOPAK comment on WordPress: Add Custom Login Logo Without Plugin Using functions.php

Want branded login page? Add custom logo with a few lines of code – no plugin needed. Add to functions.php: function custom_login_logo() { echo ‘<style type=”text/css”> #login h1 a { background-image: url(‘ . get_stylesheet_directory_uri() . ‘/images/logo.png); background-size: contain; width: 300px; height: 100px; } </style>’; } add_action(‘login_enqueue_scripts’, ‘custom_login_logo’); Change Logo URL: function custom_login_url() { return home_url(); […]

Read More
Photoshop

Photoshop: Use Blend If to Remove White/Black Backgrounds Without Selecting

- 14.02.26 - ErcanOPAK comment on Photoshop: Use Blend If to Remove White/Black Backgrounds Without Selecting

Magic wand selection leaving halos? Blend If removes backgrounds based on brightness – no selection needed. Remove White Background: 1. Double-click layer to open Layer Style 2. Find “Blend If” section at bottom 3. Drag This Layer white slider left 4. White pixels become transparent! For Smoother Transition: Hold Alt while dragging to split slider […]

Read More
Photoshop

Photoshop: Use Layer Comps to Save Multiple Design Variations in One File

- 14.02.26 - ErcanOPAK comment on Photoshop: Use Layer Comps to Save Multiple Design Variations in One File

Creating multiple mockup versions in separate files? Layer Comps saves different layer visibility/position states in one PSD. Create Layer Comp: Window → Layer Comps → Click ‘Create New Layer Comp’ icon Choose What to Save: Visibility (which layers are on/off) Position (where layers are located) Appearance (layer styles) Use Case Example: Designing website header with […]

Read More
Visual Studio

Visual Studio: Use Multi-Caret Editing to Change Multiple Lines at Once

- 14.02.26 - ErcanOPAK comment on Visual Studio: Use Multi-Caret Editing to Change Multiple Lines at Once

Editing same text on multiple lines one by one is tedious. Multi-caret lets you edit all simultaneously. Add Carets: Hold Alt + Click where you want additional cursors Or Select Multiple: 1. Select text 2. Press Ctrl+D repeatedly to select next occurrence 3. Type to change all at once Example: // Change all ‘firstName’ to […]

Read More
C#

C#: Use init Accessor to Create Immutable Objects Without Constructor Boilerplate

- 13.02.26 - ErcanOPAK comment on C#: Use init Accessor to Create Immutable Objects Without Constructor Boilerplate

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; […]

Read More
C#

C#: Use Index and Range Operators for Cleaner Array Slicing

- 13.02.26 - ErcanOPAK comment on 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(); // […]

Read More
C#

C#: Use Null-Coalescing Assignment to Simplify Lazy Initialization

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
SQL

SQL: Use CHAR Instead of VARCHAR for Fixed-Length Columns to Save Space

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
SQL

SQL: Use CROSS APPLY Instead of Subqueries for Better Performance

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
Asp.Net Core

.NET Core: Use Required Modifier to Force Property Initialization

- 13.02.26 - ErcanOPAK comment on .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! […]

Read More
Asp.Net Core

.NET Core: Use Global Using Directives to Avoid Repeating Imports

- 13.02.26 - ErcanOPAK comment on .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 […]

Read More
Git

Git: Use git restore to Unstage Files Without Losing Changes

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
Git

Git: Use git bisect to Find Which Commit Introduced a Bug

- 13.02.26 - ErcanOPAK comment on 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: # […]

Read More
Ajax

AJAX: Use Fetch with Signal to Cancel Requests When User Navigates Away

- 13.02.26 - ErcanOPAK comment on 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’, () => { […]

Read More
JavaScript

JavaScript: Use structuredClone() to Deep Copy Objects

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
HTML

HTML5: Use details and summary Tags for Native Accordions

- 13.02.26 - ErcanOPAK comment on 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; […]

Read More
CSS

CSS: Use :has() Selector to Style Parent Based on Child

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
Windows

Windows 11: Use Voice Typing to Write Without Keyboard

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
Windows

Windows 11: Use Focus Sessions to Block Distractions with Pomodoro Timer

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
AI

AI Prompt: Generate Regex Patterns with Explanation and Test Cases

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
AI

AI Prompt: Convert Handwritten Notes Photo to Formatted Markdown

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
AI

AI Prompt: Analyze Email Thread and Summarize Action Items by Person

- 13.02.26 - ErcanOPAK comment on 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:** […]

Read More
Docker

Docker: Use .dockerignore to Speed Up Builds and Reduce Image Size

- 13.02.26 - ErcanOPAK comment on 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 […]

Read More
Page 20 of 69
« Previous 1 … 15 16 17 18 19 20 21 22 23 24 25 … 69 Next »

Posts navigation

Older posts
Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (860)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (449)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (860)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com