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: Master Virtual Desktops for Deep Work

- 21.02.26 - ErcanOPAK comment on Windows 11: Master Virtual Desktops for Deep Work

Context switching is the enemy of productivity. Professional developers use separate desktops for different tasks. The Setup: Win + Tab. Create Desktop 1 (Coding), Desktop 2 (Communication – Slack/Email), Desktop 3 (Personal). Set different wallpapers for each to trigger your brain’s ‘context switch’.

Read More
AI

AI Prompt: Create a Professional 5-Year Financial Roadmap

- 21.02.26 - ErcanOPAK comment on AI Prompt: Create a Professional 5-Year Financial Roadmap

Use AI as a highly qualified Financial Advisor to optimize your savings and investments. “Act as a Certified Financial Planner. My current monthly income is [X], my fixed expenses are [Y]. My goal is to [e.g., Save for a house / Early retirement]. 1. Suggest a 50/30/20 budget breakdown. 2. Recommend an investment diversification strategy […]

Read More
AI

AI Prompt: Conduct a Professional Performance Audit of Your Code

- 21.02.26 - ErcanOPAK comment on AI Prompt: Conduct a Professional Performance Audit of Your Code

AI is excellent at spotting O(n^2) complexity that humans might miss. “Analyze this code block for Big O complexity: [Paste Code]. Identify any ‘N+1’ query problems, unnecessary allocations, or blocking I/O. Suggest a refactored version that optimizes for both memory and execution time.”

Read More
AI

AI Prompt: From User Story to Full Technical Specification

- 21.02.26 - ErcanOPAK comment on AI Prompt: From User Story to Full Technical Specification

Don’t just ask AI for a function. Ask for a complete blueprint. The Master Prompt: “Act as a Staff Software Engineer. I have a user story: [User can upload and resize images]. 1. Design a scalable AWS-based architecture. 2. Provide the OpenAPI (Swagger) spec. 3. List potential failure modes (Circuit breakers, Retries). 4. Write the […]

Read More
Docker

Docker: Optimizing Layer Cache for Lightning Fast CI/CD Builds

- 21.02.26 - ErcanOPAK comment on Docker: Optimizing Layer Cache for Lightning Fast CI/CD Builds

Every line in a Dockerfile is a layer. If you change a file, all subsequent layers are rebuilt. This is slow. The Pro Strategy: Always copy your dependency files (package.json, .csproj) BEFORE your source code. This ensures that ‘npm install’ or ‘dotnet restore’ is only re-run if dependencies change, not every time you edit a […]

Read More
Kubernetes

Kubernetes: Namespace Resource Quotas to Prevent Cost Spikes

- 21.02.26 - ErcanOPAK comment on Kubernetes: Namespace Resource Quotas to Prevent Cost Spikes

In a multi-tenant cluster, one runaway pod can consume all resources and crash other services. The Solution: Define a ResourceQuota per namespace. This limits the total CPU and Memory that a specific team or environment (dev/prod) can use. apiVersion: v1 kind: ResourceQuota metadata: name: mem-cpu-demo spec: hard: requests.cpu: “1” requests.memory: 1Gi limits.cpu: “2” limits.memory: 2Gi

Read More
Wordpress

WordPress: Hardening Security with .htaccess Headers

- 21.02.26 - ErcanOPAK comment on WordPress: Hardening Security with .htaccess Headers

Go beyond plugins. Add a layer of professional security at the server level using your .htaccess file. Header set X-Content-Type-Options “nosniff” Header set X-Frame-Options “SAMEORIGIN” Header set X-XSS-Protection “1; mode=block” This prevents Clickjacking and XSS attacks before WordPress even starts loading.

Read More
Wordpress

WordPress: Professional Database Cleaning Without Plugins

- 21.02.26 - ErcanOPAK comment on WordPress: Professional Database Cleaning Without Plugins

Plugins like WP-Optimize are great, but for a professional touch, you should handle overhead manually to keep the site lean. WordPress stores thousands of ‘Revisions’. Limit them in wp-config.php: define(‘WP_POST_REVISIONS’, 5); // Keep only last 5 Then, run this SQL query to delete old ones: DELETE FROM wp_posts WHERE post_type = ‘revision’;

Read More
Photoshop

Photoshop: Perfect Color Match Between Different Images

- 21.02.26 - ErcanOPAK comment on Photoshop: Perfect Color Match Between Different Images

Compositing two different photos? The colors never match perfectly—until now. The Secret: Image -> Adjustments -> Match Color. Select your target image as the ‘Source’. Photoshop’s algorithm analyzes the luminance and color palette of the target and applies it to your current layer. Use the ‘Fade’ slider to make it look natural.

Read More
Photoshop

Photoshop: Professional Grade Non-Destructive Editing Workflow

- 21.02.26 - ErcanOPAK comment on Photoshop: Professional Grade Non-Destructive Editing Workflow

Destroying pixels is for amateurs. Pros use Smart Objects and Adjustment Layers. Convert to Smart Object: Right-click your layer. Any filter applied now becomes a ‘Smart Filter’ which can be edited later. Luminosity Masks: Control exactly where your adjustments hit based on brightness values. By using this workflow, you can return to a project 6 […]

Read More
Visual Studio

Visual Studio: Memory Profiling to Kill Hidden Memory Leaks

- 21.02.26 - ErcanOPAK comment on Visual Studio: Memory Profiling to Kill Hidden Memory Leaks

Professional developers don’t just debug; they profile. If your app slows down over time, you likely have a memory leak. The Pro Move: Use the Diagnostic Tools (Alt+F2). Take two snapshots of the heap and use the ‘View Heap’ tool to compare them. Visual Studio will show you exactly which objects are staying in memory […]

Read More
C#

C#: Simplify Logic with Modern Switch Pattern Matching

- 21.02.26 - ErcanOPAK comment on C#: Simplify Logic with Modern Switch Pattern Matching

Replace long if-else blocks with clean switch expressions. var message = status switch { 200 => “OK”, 404 => “Not Found”, _ => “Unknown” };

Read More
C#

C#: Why Dapper is Often Better than Entity Framework

- 21.02.26 - ErcanOPAK comment on C#: Why Dapper is Often Better than Entity Framework

EF is great, but Dapper is the ‘King of Speed’. Use it for high-performance read queries where every millisecond counts. var users = connection.Query(“SELECT * FROM Users WHERE Active = 1”).ToList();

Read More
C#

C#: Use ‘yield return’ for Memory Efficient Iteration

- 21.02.26 - ErcanOPAK comment on C#: Use ‘yield return’ for Memory Efficient Iteration

Don’t create giant lists in memory if you only need to iterate once. yield return creates items lazily. public IEnumerable GetBigData() { for(int i=0; i < 1000000; i++) yield return i; }

Read More
SQL

SQL: Calculate Running Totals with ROW_NUMBER() and OVER()

- 21.02.26 - ErcanOPAK comment on SQL: Calculate Running Totals with ROW_NUMBER() and OVER()

Window functions allow you to perform calculations across sets of rows related to the current row. SELECT Name, Salary, SUM(Salary) OVER(ORDER BY HireDate) as RunningTotal FROM Employees;

Read More
SQL

SQL: Use CTEs (Common Table Expressions) for Readable Queries

- 21.02.26 - ErcanOPAK comment on SQL: Use CTEs (Common Table Expressions) for Readable Queries

Stop using complex subqueries. CTEs make your SQL look like clean code. WITH MonthlySales AS ( SELECT ProductId, SUM(Amount) as Total FROM Sales GROUP BY ProductId ) SELECT * FROM MonthlySales WHERE Total > 1000;

Read More
Asp.Net Core

.NET Core: Custom Middleware for Global Exception Handling

- 21.02.26 - ErcanOPAK comment on .NET Core: Custom Middleware for Global Exception Handling

Stop using try-catch in every controller. Handle errors globally and return consistent JSON. app.UseExceptionHandler(appError => { appError.Run(async context => { context.Response.StatusCode = 500; await context.Response.WriteAsJsonAsync(new { Error = “Internal Server Error” }); }); });

Read More
Asp.Net Core

.NET Core: Implement Built-in Health Checks for Microservices

- 21.02.26 - ErcanOPAK comment on .NET Core: Implement Built-in Health Checks for Microservices

Let your load balancer or K8s know your app is healthy. builder.Services.AddHealthChecks(); app.MapHealthChecks(“/health”);

Read More
Git

Git: Keep History Clean with Squash Rebase

- 21.02.26 - ErcanOPAK comment on Git: Keep History Clean with Squash Rebase

Don’t let ‘fixed typo’ or ‘test’ commits ruin your main branch. Merge them into one clean commit before pushing. git rebase -i HEAD~3 # Pick first, squash others

Read More
Git

Git: Use ‘Stash Pop’ to Move Work Between Branches

- 21.02.26 - ErcanOPAK comment on Git: Use ‘Stash Pop’ to Move Work Between Branches

Started working on the wrong branch? Stash your changes, switch branch, and pop them back. git stash git checkout correct-branch git stash pop

Read More
Ajax

Ajax: Use Axios Interceptors for Global Error Handling and Auth

- 21.02.26 - ErcanOPAK comment on Ajax: Use Axios Interceptors for Global Error Handling and Auth

Don’t manually add tokens to every request. Centralize your logic. axios.interceptors.request.use(config => { config.headers.Authorization = `Bearer ${localStorage.getItem(‘token’)}`; return config; });

Read More
JavaScript

JavaScript: Clean Your Code with Optional Chaining and Nullish Coalescing

- 21.02.26 - ErcanOPAK comment on JavaScript: Clean Your Code with Optional Chaining and Nullish Coalescing

Forget deep nested ‘if’ checks for object properties. // Old way const street = user && user.address && user.address.street; // Modern way (C# style) const street = user?.address?.street ?? ‘Default Street’;

Read More
HTML

HTML5: Stop Using JS Modals – The Native Element is Here

- 21.02.26 - ErcanOPAK comment on HTML5: Stop Using JS Modals – The Native Element is Here

Native modals are better for accessibility and performance. No extra libraries needed. This is a native modal! Close Open Modal

Read More
CSS

CSS: Create Modern Glassmorphism Effects with backdrop-filter

- 21.02.26 - ErcanOPAK comment on CSS: Create Modern Glassmorphism Effects with backdrop-filter

Achieve the frosted glass look used in iOS and Windows 11 using pure CSS. .glass-card { background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 15px; }

Read More
Windows

Windows 11: PowerToys – The Ultimate Productivity Add-on

- 21.02.26 - ErcanOPAK comment on Windows 11: PowerToys – The Ultimate Productivity Add-on

Install Microsoft PowerToys. It adds ‘FancyZones’ for window snapping, ‘PowerRename’ for bulk file naming, and a Mac-like ‘PowerToys Run’ search launcher.

Read More
Windows

Windows 11: Activate ‘God Mode’ for Hidden Power Settings

- 21.02.26 - ErcanOPAK comment on Windows 11: Activate ‘God Mode’ for Hidden Power Settings

Access every single Windows setting in one list without digging through the Settings app. The Trick: Create a new folder on your desktop and name it exactly: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

Read More
AI

AI Prompt: The ‘Master Repairman’ for Any Home Appliance

- 21.02.26 - ErcanOPAK comment on AI Prompt: The ‘Master Repairman’ for Any Home Appliance

Fix anything at home without calling an expensive technician first. “Act as an expert appliance technician with 30 years of experience. My [Device Name – e.g., Bosch Dishwasher] is showing error [Code – e.g., E15]. 1. Explain the root cause. 2. Give me a step-by-step DIY fix guide. 3. List the tools I need. 4. […]

Read More
AI

AI Prompt: Convert Legacy Code to Modern Patterns

- 21.02.26 - ErcanOPAK comment on AI Prompt: Convert Legacy Code to Modern Patterns

Instantly modernize old codebases. “I have this legacy code from 2010: [Paste Code]. Refactor it to use C# 12 features (Primary constructors, Collection expressions) and implement the Repository pattern for the data access part.”

Read More
AI

AI Prompt: Generate 100% Edge-Case Coverage for Your Methods

- 21.02.26 - ErcanOPAK comment on AI Prompt: Generate 100% Edge-Case Coverage for Your Methods

Ask AI to act as a QA Engineer to find bugs you didn’t see. “Act as a Senior QA Engineer. Here is my C# method: [Paste Code]. Generate a list of 10 edge cases including nulls, overflows, and logic errors. Then, write xUnit tests for each using FluentAssertions and Moq.”

Read More
Docker

Docker: Shrink Image Size by 80% with Multi-Stage Builds

- 21.02.26 - ErcanOPAK comment on Docker: Shrink Image Size by 80% with Multi-Stage Builds

Don’t include the SDK and build tools in your production image. Use a multi-stage approach to only ship the final binary. FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src COPY . . RUN dotnet publish -c Release -o /app FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY –from=build /app . ENTRYPOINT [“dotnet”, “MyApp.dll”]

Read More
Page 14 of 69
« Previous 1 … 9 10 11 12 13 14 15 16 17 18 19 … 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