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

Asp.Net Core

.NET Core: Scaling with Redis and IDistributedCache

- 28.02.26 - ErcanOPAK comment on .NET Core: Scaling with Redis and IDistributedCache

In-memory cache fails when you have multiple server instances. Use Distributed Caching to share data across your entire cluster. // In Program.cs builder.Services.AddStackExchangeRedisCache(options => { options.Configuration = “localhost:6379”; }); Now, when Server A caches a user’s session, Server B can access it immediately, ensuring a seamless user experience in a load-balanced environment.

Read More
Asp.Net Core

.NET Core: Zero-Startup Latency with Native AOT Compilation

- 28.02.26 - ErcanOPAK comment on .NET Core: Zero-Startup Latency with Native AOT Compilation

Modern cloud apps need to start fast (Cold Starts). Native AOT compiles your C# directly to machine code, removing the need for the JIT compiler at runtime. Benefits: Smaller binary size, lower memory footprint, and near-instant startup. Perfect for AWS Lambda or Azure Functions where you pay for every millisecond of execution.

Read More
Git

Git: Applying a Specific Fix from One Branch to Another with Cherry-Pick

- 28.02.26 - ErcanOPAK comment on Git: Applying a Specific Fix from One Branch to Another with Cherry-Pick

You fixed a critical bug in the experimental branch, but you aren’t ready to merge the whole branch to production yet. Use Cherry-Pick. git cherry-pick [COMMIT_HASH] This copies only that specific commit’s changes and applies them to your current branch. Surgical and clean.

Read More
Git

Git: Finding the Exact Commit That Broke Your App with Bisect

- 28.02.26 - ErcanOPAK comment on Git: Finding the Exact Commit That Broke Your App with Bisect

The code was working 2 weeks ago, and now it’s broken. You have 200 commits to check. Don’t do it manually. git bisect start git bisect bad # Current version is broken git bisect good abc123 # This commit was working Git will use binary search to narrow down the culprit in just a few […]

Read More
Ajax

Ajax: Building Resilient Apps with Exponential Backoff Retry Logic

- 28.02.26 - ErcanOPAK comment on Ajax: Building Resilient Apps with Exponential Backoff Retry Logic

Network flickers happen. If a request fails, don’t just show an error; try again—but wait longer each time to avoid overloading the server. async function fetchWithRetry(url, retries = 3, delay = 1000) { try { return await fetch(url); } catch (err) { if (retries === 0) throw err; await new Promise(r => setTimeout(r, delay)); return […]

Read More
JavaScript

JavaScript: Preventing Memory Leaks with WeakMap and WeakSet

- 28.02.26 - ErcanOPAK comment on JavaScript: Preventing Memory Leaks with WeakMap and WeakSet

Standard Maps keep a ‘strong’ reference to keys, preventing Garbage Collection even if the object is no longer used. This causes memory leaks in long-running SPAs. // The Safe Way let userMetadata = new WeakMap(); let user = { id: 1 }; userMetadata.set(user, { lastLogin: Date.now() }); user = null; // The metadata is now […]

Read More
HTML

HTML5: Predicting the User’s Next Move with

- 28.02.26 - ErcanOPAK comment on HTML5: Predicting the User’s Next Move with

What if the next page the user clicks on loads instantly? You can achieve this by prefetching assets. The Strategy: Use this on your ‘Home’ page to pre-load the ‘Pricing’ or ‘Login’ pages. The browser downloads them in the background during idle time.

Read More
CSS

CSS: Professional Branding with Custom Scrollbars

- 28.02.26 - ErcanOPAK comment on CSS: Professional Branding with Custom Scrollbars

Default scrollbars often look ugly and clash with your design. Customize them with pure CSS. ::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #3498db; border-radius: 5px; } ::-webkit-scrollbar-thumb:hover { background: #2980b9; } Why? It’s a small detail that makes your web app feel ‘finished’ and high-end.

Read More
Windows

Windows 11: Cleaning Up the Taskbar for Maximum Focus

- 28.02.26 - ErcanOPAK comment on Windows 11: Cleaning Up the Taskbar for Maximum Focus

The Taskbar in Windows 11 can get crowded. For a professional workspace, disable the ‘Chat’ and ‘Task View’ buttons. Right-click Taskbar -> Taskbar Settings. Turn off Search (or set to icon only), Task View, and Widgets. A cleaner taskbar reduces visual distraction and increases cognitive focus during deep work.

Read More
Windows

Windows 11: Fixing Ghost Connection Issues with Network Reset

- 28.02.26 - ErcanOPAK comment on Windows 11: Fixing Ghost Connection Issues with Network Reset

Sometimes WiFi works but certain apps can’t connect. This is often due to corrupted IP stacks or DNS caches. The Fix: Go to Settings -> Network & Internet -> Advanced network settings -> Network reset. It wipes all network adapters and reinstalls them. It’s the ultimate ‘nuclear option’ that solves 90% of weird connectivity bugs.

Read More
AI

AI Prompt: The Emergency Plumber – DIY Leak Management

- 28.02.26 - ErcanOPAK comment on AI Prompt: The Emergency Plumber – DIY Leak Management

Plumbing issues happen on Sundays. Use AI to stabilize the situation before the pro arrives. The Prompt: “I have a leak coming from [Location – e.g., under the kitchen sink]. I have basic tools: [Wrench, tape, bucket]. 1. What should I turn off immediately? 2. Give me a temporary fix to stop water damage. 3. […]

Read More
AI

AI Prompt: Modernizing Old C# Code to .NET 8 Syntax

- 28.02.26 - ErcanOPAK comment on AI Prompt: Modernizing Old C# Code to .NET 8 Syntax

Do you have old code with ArrayList and manual loops? Use this for an instant upgrade. “Act as a Senior .NET Architect. Rewrite this legacy code using C# 12 and .NET 8 features: [Paste Code]. Use Primary Constructors, File-scoped namespaces, LINQ where appropriate, and ensure it is thread-safe. Explain each major change made for performance […]

Read More
AI

AI Prompt: The ‘Second-Order Thinking’ Decision Framework

- 28.02.26 - ErcanOPAK comment on AI Prompt: The ‘Second-Order Thinking’ Decision Framework

Most people only think about the immediate consequences of a decision. Use AI to look 10 years ahead. The Prompt: “I am considering [Decision – e.g., Quitting my job to start a startup]. Act as a Strategic Analyst. Use ‘Second-Order Thinking’ to analyze: 1. Immediate effects. 2. The effects of those effects (2-3 years). 3. […]

Read More
Docker

Docker: Why You Should COPY package.json BEFORE the Rest of Your App

- 28.02.26 - ErcanOPAK comment on Docker: Why You Should COPY package.json BEFORE the Rest of Your App

Are your Docker builds taking too long? You are probably breaking the Layer Cache. # WRONG COPY . . RUN npm install # PRO WAY COPY package*.json ./ RUN npm install COPY . . Why? If you copy everything first, any small code change invalidates the npm install layer. By copying only the JSON first, […]

Read More
Kubernetes

Kubernetes: Keeping Critical Pods Safe with Taints and Tolerations

- 28.02.26 - ErcanOPAK comment on Kubernetes: Keeping Critical Pods Safe with Taints and Tolerations

In a large cluster, you don’t want ‘general’ workloads running on your expensive GPU nodes or high-security master nodes. The Logic: – Taint: Applied to a Node (“Only special pods allowed here”). – Toleration: Applied to a Pod (“I am allowed to run on that special node”). This is the foundation of multi-tenant cluster management […]

Read More
Wordpress

WordPress: Hardening Cookies by Changing Your Security Salts

- 28.02.26 - ErcanOPAK comment on WordPress: Hardening Cookies by Changing Your Security Salts

If your site has ever been compromised, or you just want a security boost, you must change your Authentication Salts. Salts add extra randomness to your passwords. Changing them in wp-config.php will instantly log out every user and invalidate all current sessions. It’s like changing the locks on your house doors. Note: Get fresh keys […]

Read More
Wordpress

WordPress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

- 28.02.26 - ErcanOPAK comment on WordPress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

Many plugins (like Contact Form 7) load their scripts on every page, even if there’s no form. This destroys your Google PageSpeed score. add_action(‘wp_print_scripts’, ‘remove_unused_scripts’, 100); function remove_unused_scripts() { if (!is_page(‘contact’)) { wp_dequeue_script(‘contact-form-7’); wp_dequeue_style(‘contact-form-7′); } } Result: Your homepage loads 200KB less data, leading to a much faster ‘Largest Contentful Paint’ (LCP).

Read More
Photoshop

Photoshop: Moving Objects Seamlessly with Content-Aware Move

- 28.02.26 - ErcanOPAK comment on Photoshop: Moving Objects Seamlessly with Content-Aware Move

Need to move a person 2 inches to the left? Don’t cut and paste. Use the Content-Aware Move Tool (J). How it works: Select the object, move it to the new location, and Photoshop will automatically fill the old hole and blend the object’s edges into the new background. Tip: Set the ‘Structure’ to 7 […]

Read More
Photoshop

Photoshop: Professional Image Sharpening with the High Pass Method

- 28.02.26 - ErcanOPAK comment on Photoshop: Professional Image Sharpening with the High Pass Method

Generic ‘Sharpen’ filters often create ugly artifacts. The High Pass method gives you granular control over what gets sharpened. The Pro Workflow: 1. Duplicate your layer (Ctrl+J). 2. Filter -> Other -> High Pass. Set radius until you see faint outlines (usually 1.5 – 3.0). 3. Set the Layer Blend Mode to Overlay or Soft […]

Read More
Visual Studio

Visual Studio: Using [DebuggerDisplay] to Speed Up Your Debugging Sessions

- 28.02.26 - ErcanOPAK comment on Visual Studio: Using [DebuggerDisplay] to Speed Up Your Debugging Sessions

Tired of clicking the small arrow to see object properties while debugging? DebuggerDisplay shows the data you want directly in the variable list. [DebuggerDisplay(“User: {Name} (ID: {Id})”)] public class User { public int Id { get; set; } public string Name { get; set; } } The Fix: This attribute forces Visual Studio to show […]

Read More
C#

C#: Why You Should ‘Seal’ Your Classes for Performance

- 28.02.26 - ErcanOPAK comment on C#: Why You Should ‘Seal’ Your Classes for Performance

If you don’t expect a class to be inherited, use the sealed keyword. The Science: The JIT compiler can perform ‘Devirtualization’ on sealed classes. Since it knows there are no overrides, it calls methods directly instead of looking up the virtual method table (vtable). Small gains in many places lead to a much faster system.

Read More
C#

C#: Reducing Boilerplate with Primary Constructors in C# 12

- 28.02.26 - ErcanOPAK comment on C#: Reducing Boilerplate with Primary Constructors in C# 12

C# 12 allows you to declare constructor parameters directly in the class definition. No more private fields and assignment blocks! public class UserService(IDatabase db, ILogger logger) { public void Save() => logger.Log(“Saved to ” + db.Name); } Why? It makes your classes significantly shorter and focuses the reader’s eye on the logic, not the setup.

Read More
C#

C#: Professional Formatting with Advanced String Interpolation

- 28.02.26 - ErcanOPAK comment on C#: Professional Formatting with Advanced String Interpolation

String interpolation isn’t just for variables; it’s for formatting. var price = 123.456; Console.WriteLine($”Price: {price:C2}”); // Currency: $123.46 Console.WriteLine($”Date: {DateTime.Now:dd/MM/yyyy}”); The Advantage: It keeps your code localized and prevents messy .ToString() calls everywhere.

Read More
SQL

SQL: The ‘IsDeleted’ Pattern vs Data Integrity

- 28.02.26 - ErcanOPAK comment on SQL: The ‘IsDeleted’ Pattern vs Data Integrity

Never physically DELETE data in enterprise apps. Use a bit column IsDeleted. But how do you handle unique constraints? Pro Tip: Use a Filtered Unique Index. This allows you to have the same email address in a ‘Users’ table if the previous ones are marked as deleted. CREATE UNIQUE INDEX UI_ActiveEmail ON Users(Email) WHERE IsDeleted […]

Read More
SQL

SQL: Calculating Running Totals with the OVER() Clause

- 28.02.26 - ErcanOPAK comment on SQL: Calculating Running Totals with the OVER() Clause

Before Window Functions, calculating a running total required a complex self-join. Now, it’s a one-liner. SELECT OrderDate, Amount, SUM(Amount) OVER (ORDER BY OrderDate) as RunningTotal FROM Sales; Why? It’s significantly faster because the database only scans the table once (O(N) vs O(N^2)).

Read More
Asp.Net Core

.NET Core: Reducing Data Transfer Costs with Response Compression

- 28.02.26 - ErcanOPAK comment on .NET Core: Reducing Data Transfer Costs with Response Compression

Sending large JSON payloads? Compress them with Brotli or Gzip automatically at the middleware level. builder.Services.AddResponseCompression(options => { options.EnableForHttps = true; }); app.UseResponseCompression(); The Impact: Reduces payload size by up to 70%, making your mobile app much faster on slow 4G networks.

Read More
Asp.Net Core

.NET Core: Implementing Professional Monitoring with Health Checks

- 28.02.26 - ErcanOPAK comment on .NET Core: Implementing Professional Monitoring with Health Checks

How does your load balancer know your app is healthy? Not just ‘running’, but actually connected to the DB. // In Program.cs builder.Services.AddHealthChecks() .AddSqlServer(builder.Configuration.GetConnectionString(“Default”)); app.MapHealthChecks(“/health”); The Benefit: It returns a 200 OK only if the app AND its dependencies are healthy. Essential for Kubernetes deployments.

Read More
Git

Git: Cleaning Up Your Branch History with Squash and Merge

- 28.02.26 - ErcanOPAK comment on Git: Cleaning Up Your Branch History with Squash and Merge

Nobody needs to see your ‘oops’, ‘fix typo’, and ‘test’ commits in the main history. Use Squash. When merging a feature branch, it combines all 20 of your messy commits into one single, clean commit. This keeps the production history readable and professional.

Read More
Git

Git: Saving Hours of Typing with Custom Git Aliases

- 28.02.26 - ErcanOPAK comment on Git: Saving Hours of Typing with Custom Git Aliases

Stop typing git checkout and git commit. Create professional shortcuts in your .gitconfig. git config –global alias.co checkout git config –global alias.br branch git config –global alias.st status git config –global alias.last ‘log -1 HEAD’ Now, git st does exactly what git status does. Small change, massive daily time savings.

Read More
Ajax

Ajax: Using ‘priority’ to Speed Up Critical API Calls

- 28.02.26 - ErcanOPAK comment on Ajax: Using ‘priority’ to Speed Up Critical API Calls

Not all API calls are equal. Your ‘User Profile’ is more important than ‘Related Products’. fetch(‘/api/user’, { priority: ‘high’ }); fetch(‘/api/ads’, { priority: ‘low’ }); The Logic: This tells the browser which network requests to put at the front of the queue, improving the ‘Perceived Performance’ of your app.

Read More
Page 8 of 69
« Previous 1 … 3 4 5 6 7 8 9 10 11 12 13 … 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