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

SQL

SQL: Read Execution Plans to Find Performance Bottlenecks

- 22.03.26 - ErcanOPAK comment on SQL: Read Execution Plans to Find Performance Bottlenecks

๐Ÿ” See What Database Actually Does Query slow? Don’t guess. Execution plans show exactly how database executes query. Find bottlenecks, fix performance. Get Execution Plan — SQL Server SET STATISTICS IO ON; SET STATISTICS TIME ON; — Show estimated plan (doesn’t run query) SET SHOWPLAN_TEXT ON; GO SELECT * FROM orders WHERE user_id = 123; […]

Read More
SQL

SQL: Use CTEs (WITH Clause) for Readable Complex Queries

- 22.03.26 - ErcanOPAK comment on SQL: Use CTEs (WITH Clause) for Readable Complex Queries

๐Ÿ“ Name Your Subqueries Nested subqueries everywhere? Unreadable mess? CTEs (Common Table Expressions) name intermediate results. Code becomes self-documenting. The Subquery Nightmare — โŒ Nested subqueries: Hard to read SELECT u.name, (SELECT COUNT(*) FROM orders o WHERE o.user_id = u.id) as order_count, (SELECT AVG(total) FROM orders o WHERE o.user_id = u.id) as avg_order FROM users […]

Read More
Asp.Net Core

.NET Core: Add Health Checks to Monitor Application Status

- 22.03.26 - ErcanOPAK comment on .NET Core: Add Health Checks to Monitor Application Status

๐Ÿ’“ Know When Your App Is Sick Load balancer needs to know: is app healthy? Database connected? Redis available? Health checks provide instant status. Basic Health Check Setup // Program.cs var builder = WebApplication.CreateBuilder(args); // Add health checks builder.Services.AddHealthChecks(); var app = builder.Build(); // Map health check endpoint app.MapHealthChecks(“/health”); app.Run(); // GET /health // Response: […]

Read More
Asp.Net Core

.NET Core: Use IHostedService for Background Tasks

- 22.03.26 - ErcanOPAK comment on .NET Core: Use IHostedService for Background Tasks

โฐ Long-Running Tasks in ASP.NET Core Need scheduled jobs? Background processing? Email queue? IHostedService runs tasks in background without blocking requests. Basic Background Service public class EmailQueueService : BackgroundService { private readonly ILogger _logger; private readonly IServiceProvider _services; public EmailQueueService( ILogger logger, IServiceProvider services) { _logger = logger; _services = services; } protected override async […]

Read More
Git

Git: Use git cherry-pick to Copy Specific Commits Between Branches

- 22.03.26 - ErcanOPAK comment on Git: Use git cherry-pick to Copy Specific Commits Between Branches

๐Ÿ’ Pick Commits Like Cherries Need one commit from feature branch in production? Don’t merge entire branch. Cherry-pick that commit. The Scenario # Feature branch has 10 commits feature-branch: abc123 – Add user login def456 – Fix critical security bug โ† Need this in production NOW ghi789 – Add dashboard … 7 more commits # […]

Read More
Git

Git: Use git stash to Save Work Without Committing

- 22.03.26 - ErcanOPAK comment on Git: Use git stash to Save Work Without Committing

๐Ÿ’พ Save Work, Switch Branch, Come Back Halfway through feature. Emergency bug fix needed. Don’t want to commit messy code. git stash saves work temporarily. The Problem # Working on feature branch git status # modified: feature.js # modified: styles.css # Boss: “Fix production bug NOW!” git checkout main # Error: Your local changes would […]

Read More
Ajax

Ajax: Use AbortController to Cancel Pending Requests

- 22.03.26 - ErcanOPAK comment on Ajax: Use AbortController to Cancel Pending Requests

๐Ÿšซ Cancel Requests Before They Complete User types fast, sends 10 search requests. All 10 return, UI flickers. AbortController cancels outdated requests. The Problem // โŒ Search on every keystroke – race condition! searchInput.addEventListener(‘input’, async (e) => { const results = await fetch(`/api/search?q=${e.target.value}`); const data = await results.json(); displayResults(data); }); // User types: “javascript” // […]

Read More
JavaScript

JavaScript: Use Destructuring to Extract Values Elegantly

- 22.03.26 - ErcanOPAK comment on JavaScript: Use Destructuring to Extract Values Elegantly

๐Ÿ“ฆ Unpack Data Like a Pro Accessing nested properties? Writing obj.prop.subprop.value? Destructuring extracts values in one line. Object Destructuring // โŒ Old way: Repetitive const user = { name: ‘John’, age: 30, email: ‘john@example.com’ }; const name = user.name; const age = user.age; const email = user.email; // โœ… Destructuring: One line const { name, […]

Read More
HTML

HTML5: Use Semantic Elements for Better SEO and Accessibility

- 22.03.26 - ErcanOPAK comment on HTML5: Use Semantic Elements for Better SEO and Accessibility

๐ŸŽฏ Meaningful HTML, Better Rankings div soup everywhere? Google confused, screen readers lost. Semantic HTML tells machines what content means. The Div Soup Problem Home My Article Article content… ยฉ 2024 Semantic HTML Home My Article Article content… ยฉ 2024 ๐Ÿ“š Essential Semantic Elements Element Purpose <header> Top of page/section <nav> Navigation links <main> Main […]

Read More
CSS

CSS: Use Container Queries for True Component-Based Responsive Design

- 22.03.26 - ErcanOPAK comment on CSS: Use Container Queries for True Component-Based Responsive Design

๐Ÿ“ฆ Responsive Components, Not Just Pages Media queries check viewport width. Component in sidebar? Full width? Same breakpoint fails. Container queries check parent width. The Problem with Media Queries โŒ Media Queries /* Card component */ .card { display: flex; } @media (max-width: 768px) { .card { flex-direction: column; /* Stack on mobile */ } […]

Read More
Windows

Windows 11: Customize Windows Terminal for Professional Development

- 22.03.26 - ErcanOPAK comment on Windows 11: Customize Windows Terminal for Professional Development

โšก Terminal That Looks Like Hollywood Default terminal ugly? Windows Terminal + customization = beautiful, productive, professional dev environment. Install Oh My Posh (Themes) # Install Oh My Posh (PowerShell prompt theme engine) winget install JanDeDobbeleer.OhMyPosh # Install Nerd Font (for icons) # Download from: https://www.nerdfonts.com/ # Recommended: CascadiaCode Nerd Font, FiraCode Nerd Font # […]

Read More
Windows

Windows 11: Use WSL2 to Run Linux Tools Natively on Windows

- 22.03.26 - ErcanOPAK comment on Windows 11: Use WSL2 to Run Linux Tools Natively on Windows

๐Ÿง Linux + Windows = Perfect Dev Environment Need Linux tools but stuck on Windows? No dual boot needed. WSL2 runs full Linux kernel inside Windows. Native performance. Install WSL2 (One Command) # Open PowerShell as Administrator wsl –install # That’s it! Installs: # – WSL2 # – Ubuntu (default) # – Virtual Machine Platform […]

Read More
AI

AI Prompt: Learn New Technology with Personalized Curriculum

- 22.03.26 - ErcanOPAK comment on AI Prompt: Learn New Technology with Personalized Curriculum

๐ŸŽ“ Your Personal Tech Tutor Learning new framework? Need structured path? AI creates custom curriculum based on your level and goals. The Learning Curriculum Prompt Create a learning curriculum for: [TECHNOLOGY] My background: – Current role: [e.g., Frontend Developer] – Experience: [e.g., 3 years JavaScript, React basics] – Goal: [e.g., Build production-ready apps in 3 […]

Read More
AI

AI Prompt: Transform Data Between Formats (CSV, JSON, XML, SQL)

- 22.03.26 - ErcanOPAK comment on AI Prompt: Transform Data Between Formats (CSV, JSON, XML, SQL)

๐Ÿ”„ Convert Any Data Format Instantly CSV to JSON? XML to SQL? Excel to API payload? AI transforms data between formats in seconds. The Universal Data Transformer Prompt Transform this data from [SOURCE FORMAT] to [TARGET FORMAT]: [Paste data] Requirements: – Preserve all data (no loss) – Use proper data types – Format for [USE […]

Read More
AI

AI Prompt: Generate Complete API Documentation from Codebase

- 22.03.26 - ErcanOPAK comment on AI Prompt: Generate Complete API Documentation from Codebase

๐Ÿ“š Documentation in Minutes, Not Days Writing API docs manually takes forever. AI reads your code and generates complete documentation with examples. The Documentation Prompt Generate comprehensive API documentation for this codebase: [Paste controllers/routes/API code] Include: 1. Endpoint descriptions (what each does) 2. HTTP methods and paths 3. Request parameters (query, body, headers) 4. Request […]

Read More
Docker

Docker: Add Health Checks to Detect and Restart Failing Containers

- 22.03.26 - ErcanOPAK comment on Docker: Add Health Checks to Detect and Restart Failing Containers

๐Ÿ’“ Monitor Container Health Automatically Container running but app crashed? Database connection dead? Health checks detect it and restart automatically. The Problem Without Health Checks Container Status: Running โœ“ App Status: Crashed โœ— Docker thinks everything is fine. Users see 502 errors. You don’t know until customers complain. Add Health Check in Dockerfile FROM node:18 […]

Read More
Kubernetes

Kubernetes: Use ConfigMaps and Secrets to Separate Configuration from Code

- 22.03.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps and Secrets to Separate Configuration from Code

๐Ÿ” Never Hardcode Config Again API keys in code? Database passwords committed to Git? ConfigMaps and Secrets externalize all configuration. ConfigMaps vs Secrets ๐Ÿ“ ConfigMaps Non-sensitive configuration API endpoints Feature flags Environment settings Application config files ๐Ÿ”’ Secrets Sensitive data (base64 encoded) Database passwords API keys TLS certificates OAuth tokens Creating ConfigMaps # configmap.yaml apiVersion: […]

Read More
Wordpress

WordPress: Enable Object Caching with Redis for 10x Performance

- 22.03.26 - ErcanOPAK comment on WordPress: Enable Object Caching with Redis for 10x Performance

๐Ÿš€ Database Queries: 100 โ†’ 5 Every page load = 100 database queries. Redis caches them in memory. Page generation: 800ms โ†’ 80ms. What Is Object Caching? WordPress queries database repeatedly for same data (user info, settings, post meta). Object cache stores results in RAM for instant retrieval. ๐Ÿ”„ Without Object Cache Page Load Request: […]

Read More
Wordpress

WordPress: Create Custom Post Types for Portfolios, Products, Reviews

- 22.03.26 - ErcanOPAK comment on WordPress: Create Custom Post Types for Portfolios, Products, Reviews

๐Ÿ“ฆ Beyond Posts and Pages WordPress has Posts and Pages. You need Portfolios, Products, Team Members? Custom Post Types unlock unlimited content structures. What Are Custom Post Types? Think of them as custom content containers with their own admin interface, taxonomies, and templates. ๐Ÿ’ก Use Cases Portfolio: Projects with client, year, category Products: E-commerce items […]

Read More
Photoshop

Photoshop: Use Adjustment Layers for Non-Destructive Color Correction

- 22.03.26 - ErcanOPAK comment on Photoshop: Use Adjustment Layers for Non-Destructive Color Correction

๐ŸŽจ Edit Colors Without Destroying Pixels Applying brightness/contrast directly? Destructive. Can’t undo later. Adjustment Layers keep edits separate, always reversible. Why Adjustment Layers? โŒ Direct Adjustments Permanently modifies pixels Can’t tweak later Multiple edits degrade quality Must undo entire history โœ… Adjustment Layers Non-destructive Editable anytime Can be toggled on/off Reorderable Essential Adjustment Layers ๐ŸŽฏ […]

Read More
Photoshop

Photoshop: Record Actions to Automate Repetitive Tasks

- 22.03.26 - ErcanOPAK comment on Photoshop: Record Actions to Automate Repetitive Tasks

๐ŸŽฌ Macros for Photoshop Resize 100 images? Apply same effects to 50 photos? Do it once, record it, replay on all. Actions = automation. How to Record an Action Open Actions panel: Window โ†’ Actions (Alt+F9) Click Create New Action button (folder+ icon) Name it (e.g., “Resize for Instagram”) Click Record Perform your steps (resize, […]

Read More
Visual Studio

Visual Studio: Create Custom Code Snippets to Type Less Code

- 22.03.26 - ErcanOPAK comment on Visual Studio: Create Custom Code Snippets to Type Less Code

โšก Type 3 Letters, Get 20 Lines Writing same boilerplate over and over? Custom snippets let you type ‘prop’ and get full property with backing field. Built-in Snippets You Should Know Shortcut Expands To prop Auto-property ctor Constructor for For loop foreach Foreach loop try Try-catch block cw Console.WriteLine() Usage: Type shortcut โ†’ Press Tab […]

Read More
C#

C#: Use Index and Range for Clean Array Slicing

- 19.03.26 - ErcanOPAK comment on C#: Use Index and Range for Clean Array Slicing

๐Ÿ”ช Slice Arrays Like Python Array.Copy() for slicing? Verbose. Index (^) and Range (..) operators make it elegant. Index from End (^) var numbers = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Old way: Last element var last = numbers[numbers.Length – 1]; // New way: ^1 means “1 […]

Read More
C#

C#: Use Expression-Bodied Members for One-Liners

- 19.03.26 - ErcanOPAK comment on C#: Use Expression-Bodied Members for One-Liners

โœจ Write Less, Express More Simple properties and methods don’t need full syntax. Expression bodies (=>) make code concise. Before: Verbose Syntax public class User { public string FirstName { get; set; } public string LastName { get; set; } // Verbose property public string FullName { get { return $”{FirstName} {LastName}”; } } // […]

Read More
C#

C#: Use Tuples for Multiple Return Values

- 19.03.26 - ErcanOPAK comment on C#: Use Tuples for Multiple Return Values

๐Ÿ“ฆ Return Multiple Values Elegantly Creating class for one method? Using out parameters? Ugly. Tuples return multiple values cleanly. The Old Ways (Painful) // โŒ Out parameters (ugly) public void GetStats(out int count, out decimal total, out decimal avg) { count = 100; total = 5000m; avg = 50m; } // Ugly usage GetStats(out int […]

Read More
C#

C#: Use String Interpolation with Format Specifiers

- 19.03.26 - ErcanOPAK comment on C#: Use String Interpolation with Format Specifiers

๐ŸŽจ Format Strings Like a Pro String.Format() verbose. Concatenation messy. String interpolation with format specifiers = clean & powerful. Common Format Specifiers decimal price = 1234.5678m; DateTime now = DateTime.Now; int count = 42; // Currency Console.WriteLine($”Price: {price:C}”); // Output: Price: $1,234.57 // Fixed decimal places Console.WriteLine($”Price: {price:F2}”); // Output: Price: 1234.57 // Percentage Console.WriteLine($”Progress: […]

Read More
SQL

SQL: Use Indexed Views to Cache Complex Query Results

- 19.03.26 - ErcanOPAK comment on SQL: Use Indexed Views to Cache Complex Query Results

โšก Materialized Views in SQL Server Complex aggregation query taking 10 seconds? Create indexed view. Query becomes instant. Data stays fresh automatically. Problem: Slow Aggregate Query — This runs every time, slow on large tables SELECT CategoryId, COUNT(*) AS ProductCount, AVG(Price) AS AvgPrice, SUM(Stock) AS TotalStock FROM Products GROUP BY CategoryId; — 10 seconds on […]

Read More
SQL

SQL: Use Window Functions for Running Totals Without Self-Joins

- 19.03.26 - ErcanOPAK comment on SQL: Use Window Functions for Running Totals Without Self-Joins

๐Ÿ“Š Advanced Analytics Made Easy Need running totals, rankings, moving averages? Window functions do it in one query. No self-joins. Running Total Example — Calculate cumulative sales per day SELECT SaleDate, Amount, SUM(Amount) OVER (ORDER BY SaleDate) AS RunningTotal FROM Sales ORDER BY SaleDate; — Result: — SaleDate Amount RunningTotal — 2024-01-01 100 100 — […]

Read More
Asp.Net Core

.NET Core: Use Result Pattern Instead of Throwing Exceptions

- 19.03.26 - ErcanOPAK comment on .NET Core: Use Result Pattern Instead of Throwing Exceptions

๐ŸŽฏ Explicit Error Handling Exceptions for control flow? Expensive. Hidden. Result pattern makes errors explicit and performant. Traditional Exception Way public User GetUser(int id) { var user = _db.Users.Find(id); if (user == null) throw new NotFoundException(“User not found”); if (!user.IsActive) throw new InvalidOperationException(“User inactive”); return user; } // Caller has no idea what exceptions to […]

Read More
Asp.Net Core

.NET Core: Use Minimal APIs for Lightweight Endpoints

- 19.03.26 - ErcanOPAK comment on .NET Core: Use Minimal APIs for Lightweight Endpoints

โšก Build APIs in 5 Lines of Code Skip controllers, routing, Startup.cs. Minimal APIs (.NET 6+) make simple endpoints incredibly simple. Traditional Controller Way // Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddControllers(); } public void Configure(IApplicationBuilder app) { app.UseRouting(); app.UseEndpoints(endpoints => endpoints.MapControllers()); } // UsersController.cs [ApiController] [Route(“api/[controller]”)] public class UsersController : ControllerBase { [HttpGet] public […]

Read More
Page 2 of 69
ยซ Previous 1 2 3 4 5 6 7 … 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 (751)
  • 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 (751)

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