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

Kubernetes

Kubernetes: Liveness vs Readiness Probes – Don’t Kill Your Traffic

- 21.02.26 - ErcanOPAK comment on Kubernetes: Liveness vs Readiness Probes – Don’t Kill Your Traffic

If your pod is ‘Alive’ but not ‘Ready’ to serve traffic (e.g., still loading cache), K8s might send traffic to a black hole. Use Readiness Probes. readinessProbe: httpGet: path: /health/ready port: 8080 initialDelaySeconds: 5

Read More
Wordpress

WordPress: Hide Version Number to Stop Bot Scanners

- 21.02.26 - ErcanOPAK comment on WordPress: Hide Version Number to Stop Bot Scanners

Hackers use botnets to scan for specific WP versions with known vulnerabilities. Removing the version meta tag is a simple security win. remove_action(‘wp_head’, ‘wp_generator’);

Read More
Wordpress

WordPress: Disable Heartbeat API to Reduce CPU Usage

- 21.02.26 - ErcanOPAK comment on WordPress: Disable Heartbeat API to Reduce CPU Usage

The Heartbeat API sends AJAX calls every 15-60 seconds. On busy sites, this can spike CPU usage and slow down the admin dashboard. add_action(‘init’, function() { wp_deregister_script(‘heartbeat’); }, 1);

Read More
Photoshop

Photoshop: High-End Retouching with Frequency Separation

- 21.02.26 - ErcanOPAK comment on Photoshop: High-End Retouching with Frequency Separation

Retouching skin without losing texture is hard. Frequency separation splits your image into ‘Texture’ and ‘Color’ layers. The Method: Keep the skin pores on the high-frequency layer and the skin tones on the low-frequency layer. This allows you to smooth colors without making faces look like plastic.

Read More
Photoshop

Photoshop: The Power of Camera Raw Filter for Instant Photo Surgery

- 21.02.26 - ErcanOPAK comment on Photoshop: The Power of Camera Raw Filter for Instant Photo Surgery

Don’t mess with individual adjustment layers. Camera Raw Filter is the ‘Swiss Army Knife’ of photo editing. The Move: Filter -> Camera Raw Filter. Use the ‘Masking’ tool to select only the sky or subject (AI-powered) and adjust exposure/clarity separately.

Read More
Visual Studio

Visual Studio: Master Conditional Breakpoints to Debug Complex Loops

- 21.02.26 - ErcanOPAK comment on Visual Studio: Master Conditional Breakpoints to Debug Complex Loops

Stopping at every iteration in a loop of 1000 items is a nightmare. Conditional breakpoints let you pause only when a specific state is met. The Fix: Right-click a breakpoint -> ‘Conditions’. Enter a C# expression like user.Id == 542 or items.Count > 10. Why? It saves hours of ‘F5-spamming’ and allows you to catch […]

Read More
C#

C#: Use Utf8JsonReader for Maximum JSON Parsing Performance

- 21.02.26 - ErcanOPAK comment on C#: Use Utf8JsonReader for Maximum JSON Parsing Performance

JsonSerializer.Deserialize is convenient but allocates. Utf8JsonReader parses JSON with zero allocation. Standard Way (Allocates): var user = JsonSerializer.Deserialize(json); // Creates User object + all strings + intermediates Utf8JsonReader (Zero-Allocation): using System.Text.Json; var reader = new Utf8JsonReader(jsonBytes); string name = null; int age = 0; while (reader.Read()) { if (reader.TokenType == JsonTokenType.PropertyName) { var propertyName = […]

Read More
C#

C#: Use Local Functions for Helper Methods That Don’t Need Class Scope

- 21.02.26 - ErcanOPAK comment on C#: Use Local Functions for Helper Methods That Don’t Need Class Scope

Private helper methods used by only one method pollute class scope. Local functions keep helpers truly local. Without Local Function: public class Calculator { public int Calculate(int[] numbers) { var valid = FilterValid(numbers); return Sum(valid); } private int[] FilterValid(int[] numbers) => numbers.Where(n => n > 0).ToArray(); private int Sum(int[] numbers) => numbers.Sum(); // These helpers […]

Read More
C#

C#: Use Expression-Bodied Members for Concise Property and Method Syntax

- 21.02.26 - ErcanOPAK comment on C#: Use Expression-Bodied Members for Concise Property and Method Syntax

Full method/property syntax is verbose for simple operations. Expression-bodied members reduce boilerplate. Properties: // Old way public string FullName { get { return FirstName + ” ” + LastName; } } // Expression-bodied (C# 6+) public string FullName => FirstName + ” ” + LastName; Methods: // Old way public int Add(int a, int b) […]

Read More
C#

C#: Use Channels for Producer-Consumer Patterns

- 21.02.26 - ErcanOPAK comment on C#: Use Channels for Producer-Consumer Patterns

BlockingCollection works but Channels provide modern async producer-consumer with backpressure support. Setup: using System.Threading.Channels; // Create channel with capacity var channel = Channel.CreateBounded(100); Producer: async Task ProduceAsync(ChannelWriter writer) { for (int i = 0; i < 1000; i++) { await writer.WriteAsync($"Item {i}"); await Task.Delay(10); } writer.Complete(); // Signal no more items } Consumer: async Task […]

Read More
SQL

SQL: Use Computed Columns for Automatic Calculated Values

- 21.02.26 - ErcanOPAK comment on SQL: Use Computed Columns for Automatic Calculated Values

Calculating values in application code requires logic duplication. Computed columns calculate automatically in database. Create Computed Column: CREATE TABLE Orders ( OrderId INT PRIMARY KEY, Quantity INT, PricePerUnit DECIMAL(10,2), — Computed column (calculated automatically) TotalPrice AS (Quantity * PricePerUnit), — Persisted (stored, can be indexed) TotalWithTax AS (Quantity * PricePerUnit * 1.1) PERSISTED ); Automatic […]

Read More
SQL

SQL: Use Window Functions for Running Totals and Ranking

- 21.02.26 - ErcanOPAK comment on SQL: Use Window Functions for Running Totals and Ranking

Calculating running totals or row rankings with self-joins is complex. Window functions do it elegantly. Running Total: SELECT Date, Amount, SUM(Amount) OVER (ORDER BY Date) AS RunningTotal FROM Sales ORDER BY Date; — Output: — 2024-01-01 100 100 — 2024-01-02 150 250 — 2024-01-03 200 450 Rank Within Groups: SELECT Department, EmployeeName, Salary, RANK() OVER […]

Read More
Asp.Net Core

.NET Core: Use Endpoint Filters for Clean Request/Response Pipeline

- 21.02.26 - ErcanOPAK comment on .NET Core: Use Endpoint Filters for Clean Request/Response Pipeline

Middleware affects all endpoints. Endpoint Filters apply logic only to specific endpoints you choose. Create Filter: public class LoggingFilter : IEndpointFilter { public async ValueTask InvokeAsync( EndpointFilterInvocationContext context, EndpointFilterDelegate next) { Console.WriteLine($”Before: {context.HttpContext.Request.Path}”); var result = await next(context); // Call next filter/endpoint Console.WriteLine($”After: {context.HttpContext.Response.StatusCode}”); return result; } } Apply to Specific Endpoint: app.MapGet(“/api/data”, () => […]

Read More
Asp.Net Core

.NET Core: Use BenchmarkDotNet to Accurately Measure Performance

- 21.02.26 - ErcanOPAK comment on .NET Core: Use BenchmarkDotNet to Accurately Measure Performance

Timing code with DateTime.Now is inaccurate. BenchmarkDotNet runs proper benchmarks with statistical analysis. Install: dotnet add package BenchmarkDotNet Create Benchmark: using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; [MemoryDiagnoser] public class StringBenchmarks { [Benchmark] public string StringConcat() { string result = “”; for (int i = 0; i < 1000; i++) result += i.ToString(); return result; } [Benchmark] public […]

Read More
Git

Git: Use git clean to Remove Untracked Files Safely

- 21.02.26 - ErcanOPAK comment on Git: Use git clean to Remove Untracked Files Safely

Manual deletion of generated files is tedious. git clean removes all untracked files at once. ⚠️ Test First (Dry Run): git clean -n # Shows what WOULD be deleted without actually deleting Remove Untracked Files: git clean -f # Force remove files Remove Untracked Files AND Directories: git clean -fd # -d = directories Remove […]

Read More
Git

Git: Use git revert Instead of git reset for Shared Branches

- 21.02.26 - ErcanOPAK comment on Git: Use git revert Instead of git reset for Shared Branches

git reset rewrites history – dangerous on shared branches. git revert creates new commit that undoes changes safely. ❌ Wrong – git reset on Shared Branch: git reset –hard HEAD~1 # Removes commit from history git push –force # DANGEROUS – rewrites history for everyone! # Team members’ branches now out of sync ✅ Right […]

Read More
Ajax

AJAX: Use Retry Logic with Exponential Backoff for Failed Requests

- 21.02.26 - ErcanOPAK comment on AJAX: Use Retry Logic with Exponential Backoff for Failed Requests

Network failures happen. Retry with exponential backoff prevents overwhelming server while ensuring request eventually succeeds. Simple Retry Function: async function fetchWithRetry(url, options = {}, maxRetries = 3) { for (let i = 0; i setTimeout(resolve, delay)); } } } // Usage try { const data = await fetchWithRetry(‘/api/data’); console.log(await data.json()); } catch (error) { console.error(‘Failed […]

Read More
JavaScript

JavaScript: Use IntersectionObserver for Efficient Scroll-Based Animations

- 21.02.26 - ErcanOPAK comment on JavaScript: Use IntersectionObserver for Efficient Scroll-Based Animations

Checking scroll position with addEventListener(‘scroll’) causes performance issues. IntersectionObserver is efficient and built-in. Detect When Element Enters Viewport: const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add(‘animate-in’); observer.unobserve(entry.target); // Only animate once } }); }); // Observe all elements you want to animate document.querySelectorAll(‘.fade-in-on-scroll’).forEach(el => { observer.observe(el); }); With Threshold: […]

Read More
HTML

HTML5: Use picture Element for Art Direction and Responsive Images

- 21.02.26 - ErcanOPAK comment on HTML5: Use picture Element for Art Direction and Responsive Images

img with srcset changes resolution. picture element lets you change entire image based on screen size. Different Images for Different Screens: <picture> <!– Mobile: Portrait crop –> <source media=”(max-width: 600px)” srcset=”portrait.jpg”> <!– Tablet: Square crop –> <source media=”(max-width: 1024px)” srcset=”square.jpg”> <!– Desktop: Landscape crop –> <img src=”landscape.jpg” alt=”Hero image”> </picture> Modern Format with Fallback: <picture> […]

Read More
CSS

CSS: Use will-change to Optimize Animations Before They Start

- 21.02.26 - ErcanOPAK comment on CSS: Use will-change to Optimize Animations Before They Start

Browsers optimize animations better when they know about them in advance. will-change hints at upcoming changes. Without Optimization: .box:hover { transform: scale(1.2); /* Browser not prepared, may cause janky animation */ } With will-change: .box { will-change: transform; /* Browser prepares for transform changes */ } .box:hover { transform: scale(1.2); /* Smooth animation – browser […]

Read More
Windows

Windows 11: Use Snap Layouts to Organize Multiple Windows Efficiently

- 21.02.26 - ErcanOPAK comment on Windows 11: Use Snap Layouts to Organize Multiple Windows Efficiently

Manually resizing and positioning windows is slow. Snap Layouts instantly arrange multiple windows. Access Snap Layouts: Hover over Maximize button → Grid appears showing layout options Available Layouts: – 2 windows: Side by side (50/50) – 3 windows: Main + 2 side (various ratios) – 4 windows: Quadrants – 6 windows: 2 main + 4 […]

Read More
Windows

Windows 11: Use Storage Sense to Auto-Delete Temporary Files

- 21.02.26 - ErcanOPAK comment on Windows 11: Use Storage Sense to Auto-Delete Temporary Files

Manually cleaning temp files is tedious. Storage Sense automatically removes junk on schedule. Enable: Settings → System → Storage → Storage Sense → Turn on Configure Auto-Cleanup: – Run Storage Sense: Every day / week / month / when disk space low – Delete files in Recycle Bin older than: 1 / 14 / 30 […]

Read More
AI

AI Prompt: Learn Any Programming Concept with Analogies and Examples

- 21.02.26 - ErcanOPAK comment on AI Prompt: Learn Any Programming Concept with Analogies and Examples

Technical documentation is often too abstract. AI explains concepts using analogies you already understand. The Prompt: Explain this programming concept: CONCEPT: [e.g., async/await, closures, dependency injection, microservices] I’m familiar with: [Your background – e.g., “intermediate JavaScript”] Explain using: [Type of analogy – e.g., “restaurant analogy”, “real-world example”] Provide: 1. Simple real-world analogy 2. Why this […]

Read More
AI

AI Prompt: Debug Complex Error Messages with Root Cause Analysis

- 21.02.26 - ErcanOPAK comment on AI Prompt: Debug Complex Error Messages with Root Cause Analysis

Cryptic error messages frustrate for hours. AI explains error, identifies root cause, provides fixes. The Prompt: Debug this error: ERROR MESSAGE: [Paste full error message/stack trace] CODE CONTEXT: [Paste relevant code where error occurs] WHAT I WAS TRYING TO DO: [Describe what you were attempting] MY ENVIRONMENT: [Framework versions, OS, etc.] Provide: 1. Plain English […]

Read More
AI

AI Prompt: Prepare for Technical Interview with Custom Practice Questions

- 21.02.26 - ErcanOPAK comment on AI Prompt: Prepare for Technical Interview with Custom Practice Questions

Generic interview prep doesn’t match actual job requirements. AI creates tailored technical interview questions. The Prompt: Prepare me for a technical interview: Job Role: [e.g., Senior Backend Developer] Tech Stack: [e.g., .NET Core, SQL Server, Docker, Kubernetes] Company Type: [Startup / Enterprise / FAANG] Experience Level: [X years] Generate: 1. 20 technical questions specific to […]

Read More
Docker

Docker: Use .dockerignore to Reduce Build Context and Speed Up Builds

- 21.02.26 - ErcanOPAK comment on Docker: Use .dockerignore to Reduce Build Context and Speed Up Builds

Sending entire project folder to Docker slows builds. .dockerignore excludes unnecessary files. Create .dockerignore in project root: # Version control .git .gitignore # Dependencies (will be installed in container) node_modules npm-debug.log vendor/ # Build outputs dist/ build/ *.log # IDE files .vscode/ .idea/ *.swp # Testing coverage/ .nyc_output/ # OS files .DS_Store Thumbs.db # Docs […]

Read More
Kubernetes

Kubernetes: Use Resource Requests vs Limits to Optimize Pod Scheduling

- 21.02.26 - ErcanOPAK comment on Kubernetes: Use Resource Requests vs Limits to Optimize Pod Scheduling

Not setting resources leads to unpredictable behavior. Requests guarantee minimum, Limits cap maximum. Understanding the Difference: – Requests: Guaranteed resources (used for scheduling) – Limits: Maximum resources (hard cap) Example Configuration: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 resources: requests: memory: “256Mi” cpu: “250m” # 0.25 CPU core […]

Read More
Wordpress

WordPress: Disable Gutenberg for Specific Post Types

- 21.02.26 - ErcanOPAK comment on WordPress: Disable Gutenberg for Specific Post Types

Gutenberg great for posts but overkill for simple post types. Disable selectively per post type. Disable for Specific Post Type: add_filter(‘use_block_editor_for_post_type’, function($use_block_editor, $post_type) { // Disable for ‘product’ post type if ($post_type === ‘product’) { return false; } return $use_block_editor; }, 10, 2); Disable for Multiple Post Types: add_filter(‘use_block_editor_for_post_type’, function($use_block_editor, $post_type) { $disabled_post_types = [‘product’, […]

Read More
Wordpress

WordPress: Use the_posts Filter to Modify Query Results Globally

- 21.02.26 - ErcanOPAK comment on WordPress: Use the_posts Filter to Modify Query Results Globally

Modifying WP_Query output everywhere is repetitive. the_posts filter catches all query results in one place. Add to functions.php: add_filter(‘the_posts’, function($posts, $query) { // Don’t modify admin queries if (is_admin()) return $posts; // Example: Add reading time to all posts foreach ($posts as $post) { $word_count = str_word_count(strip_tags($post->post_content)); $reading_time = ceil($word_count / 200); $post->reading_time = $reading_time […]

Read More
Photoshop

Photoshop: Use Blend If for Non-Destructive Masking Based on Brightness

- 21.02.26 - ErcanOPAK comment on Photoshop: Use Blend If for Non-Destructive Masking Based on Brightness

Regular layer masks require painting. Blend If creates automatic masks based on brightness values. Access: Double-click layer → Blending Options → “Blend If” How It Works: Blend If: Gray – Move left slider right: Hides dark areas of this layer – Move right slider left: Hides bright areas of this layer – Alt+Drag slider: Split […]

Read More
Page 15 of 69
« Previous 1 … 10 11 12 13 14 15 16 17 18 19 20 … 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 (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • 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 (447)

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 (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • 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