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

Git

The Clean Way to Undo a Pushed Commit (Without Breaking History)

- 25.01.26 - ErcanOPAK comment on The Clean Way to Undo a Pushed Commit (Without Breaking History)

Never git reset on shared branches. git revert <commit-hash> Why this mattersCreates a safe inverse commit — teammates stay happy.

Read More
Ajax / JavaScript

Abort Fetch Requests to Prevent UI Race Conditions

- 25.01.26 | 25.01.26 - ErcanOPAK comment on Abort Fetch Requests to Prevent UI Race Conditions

Multiple rapid requests = stale UI updates. const controller = new AbortController(); fetch(url, { signal: controller.signal }); controller.abort(); Why this mattersPrevents outdated responses from overwriting newer state.  

Read More
JavaScript

Why structuredClone() Beats JSON Deep Copy

- 25.01.26 - ErcanOPAK comment on Why structuredClone() Beats JSON Deep Copy

Why structuredClone() Beats JSON Deep Copy const copy = structuredClone(original); Why this mattersstructuredClone preserves complex types and avoids silent data corruption.

Read More
HTML

The loading=”lazy” Attribute That Saves Bandwidth Instantly

- 25.01.26 - ErcanOPAK comment on The loading=”lazy” Attribute That Saves Bandwidth Instantly

<img src=”hero.jpg” loading=”lazy” alt=”Hero image”> Why this mattersImages load only when needed → faster pages, better Core Web Vitals.

Read More
CSS

Stop Fighting Layouts — Use gap Instead of Margins

- 25.01.26 - ErcanOPAK comment on Stop Fighting Layouts — Use gap Instead of Margins

Margins break when layouts change direction. .container { display: flex; gap: 16px; } Why this mattersCleaner CSS, fewer overrides, better responsive behavior.

Read More
Windows

Why SSDs Slow Down Over Time (And How to Prevent It)

- 25.01.26 - ErcanOPAK comment on Why SSDs Slow Down Over Time (And How to Prevent It)

Check if TRIM is enabled. fsutil behavior query DisableDeleteNotify Why this mattersWithout TRIM, SSD write speed degrades badly.

Read More
Windows

Hidden Setting That Fixes Random App Freezes

- 25.01.26 | 15.02.26 - ErcanOPAK comment on Hidden Setting That Fixes Random App Freezes

The Mystery: You have a beast of a machine—32GB of RAM, a high-end CPU—yet your IDE (Visual Studio, IntelliJ) or your browser randomly freezes for 2-3 seconds. You check the Task Manager, and you see “System” process spiking your CPU. What gives? The Culprit: A hidden Windows feature called Memory Compression. While it’s great for […]

Read More
AI

Turn Complex Topics into Clear Mental Models

- 25.01.26 - ErcanOPAK comment on Turn Complex Topics into Clear Mental Models

Not coding — but insanely useful. Explain this topic using a simple mental model and one real-world analogy. Avoid jargon. Assume the reader is smart but new. Why this worksGreat for learning, teaching, blogging, and explaining tech to non-tech people.

Read More
AI

Generate Edge-Case Unit Tests Most Devs Miss

- 25.01.26 - ErcanOPAK comment on Generate Edge-Case Unit Tests Most Devs Miss

High-impact testing prompt: Act as a QA engineer. Generate unit tests focusing on edge cases, race conditions, and invalid inputs. Do NOT repeat obvious happy-path tests. Why this worksAI is best at thinking laterally about weird scenarios humans skip.

Read More
AI

Refactor Legacy Code Without Breaking Behavior

- 25.01.26 - ErcanOPAK comment on Refactor Legacy Code Without Breaking Behavior

Prompt you can actually reuse: You are a senior software engineer. Refactor the following code for readability and performance. Keep public APIs and behavior exactly the same. Explain each change briefly and list potential risks. Why this worksIt forces the model to respect contracts instead of “rewriting everything”.

Read More
Docker

Why Your Containers Are Slow Even on Powerful Machines

- 25.01.26 - ErcanOPAK comment on Why Your Containers Are Slow Even on Powerful Machines

The problem is usually the base image. # ❌ Heavy FROM mcr.microsoft.com/dotnet/sdk:8.0 # ✅ Lightweight FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine Why this mattersSmaller images = faster pull, faster start, lower memory pressure.

Read More
Kubernetes

Readiness vs Liveness — One Mistake Takes Down Clusters

- 25.01.26 - ErcanOPAK comment on Readiness vs Liveness — One Mistake Takes Down Clusters

Readiness vs Liveness — One Mistake Takes Down Clusters livenessProbe: httpGet: path: /health/live readinessProbe: httpGet: path: /health/ready Why this mattersLiveness restarts pods. Readiness controls traffic. Mixing them causes cascading failures.

Read More
Wordpress

Why Your Site Is Slow Even With Caching Enabled

- 25.01.26 - ErcanOPAK comment on Why Your Site Is Slow Even With Caching Enabled

Autoloaded options are silently killing performance. SELECT option_name FROM wp_options WHERE autoload = ‘yes’; Why this mattersToo many autoloaded rows = memory bloat on every request.

Read More
Wordpress

Stop Installing Plugins for Simple Redirects

- 25.01.26 - ErcanOPAK comment on Stop Installing Plugins for Simple Redirects

You don’t need a plugin for redirects. # .htaccess Redirect 301 /old-page /new-page Why this mattersFewer plugins = less attack surface + faster TTFB.

Read More
Photoshop

The Fastest Way to Fix Blurry Text in UI Mockups

- 25.01.26 - ErcanOPAK comment on The Fastest Way to Fix Blurry Text in UI Mockups

Turn text layers into Shape Layers before scaling. Type Layer → Convert to Shape Why this mattersText stays vector-sharp → no raster blur → perfect for Figma/HTML handoff.

Read More
Photoshop

Non-Destructive Image Optimization for Web (Most People Do It Wrong)

- 25.01.26 - ErcanOPAK comment on Non-Destructive Image Optimization for Web (Most People Do It Wrong)

Never resize images with Image Size directly. ✅ Use Smart Objects + Export As Right click → Convert to Smart Object File → Export → Export As (WebP) Why this mattersYou preserve original quality while generating multiple responsive assets.

Read More
Visual Studio

Hidden Feature That Fixes “Works on My Machine” Bugs

- 25.01.26 - ErcanOPAK comment on Hidden Feature That Fixes “Works on My Machine” Bugs

Use Solution Filters (.slnf) for large solutions. Instead of loading the entire solution (slow, error-prone), load only what you need. File → Save As Solution Filter Why this mattersDifferent devs load different projects → fewer mismatched dependencies → fewer “but it works here” issues.

Read More
C#

Why Exceptions Should NOT Be Used for Flow Control

- 24.01.26 - ErcanOPAK comment on Why Exceptions Should NOT Be Used for Flow Control

if (!dict.TryGetValue(key, out value)) return; Why this mattersExceptions are expensive and destroy hot paths.

Read More
C#

Span — High Performance Without Unsafe Code

- 24.01.26 - ErcanOPAK comment on Span — High Performance Without Unsafe Code

Span<char> buffer = stackalloc char[128]; Why this mattersZero allocations, cache-friendly, safe memory access.

Read More
C#

Why ValueTask Exists (And When NOT to Use It)

- 24.01.26 - ErcanOPAK comment on Why ValueTask Exists (And When NOT to Use It)

ValueTask reduces allocations — only when results are often synchronous. ValueTask<int> GetCachedAsync() Why it’s dangerousMisuse increases complexity and bugs.

Read More
SQL

The Hidden Cost of OFFSET Pagination

- 24.01.26 - ErcanOPAK comment on The Hidden Cost of OFFSET Pagination

Large offsets force the database to scan and discard rows. SELECT * FROM Orders WHERE Id > @LastSeenId ORDER BY Id FETCH NEXT 20 ROWS ONLY; Why this worksKeyset pagination scales infinitely.

Read More
SQL

Why SELECT * Slowly Destroys Performance

- 24.01.26 - ErcanOPAK comment on Why SELECT * Slowly Destroys Performance

Indexes don’t help when you ask for everything. SELECT Id, Name FROM Users WHERE IsActive = 1; Why this mattersSmaller payload, better index usage, faster IO.

Read More
Asp.Net Core / C#

Use IOptionsSnapshot to Fix Config Reload Issues

- 24.01.26 - ErcanOPAK comment on Use IOptionsSnapshot to Fix Config Reload Issues

Reading config directly causes stale values. public MyService(IOptionsSnapshot<MyConfig> cfg) { _cfg = cfg.Value; } Why this mattersSupports per-request refresh in scoped services.

Read More
Asp.Net Core / C#

Why Async Controllers Improve Throughput (Not Speed)

- 24.01.26 - ErcanOPAK comment on Why Async Controllers Improve Throughput (Not Speed)

Async doesn’t make code faster — it makes servers scalable. public async Task<IActionResult> Get() { var data = await repo.GetAsync(); return Ok(data); } Why this mattersThreads are freed while waiting → more concurrent requests.

Read More
Git

Why git pull Is Dangerous (And What to Use Instead)

- 24.01.26 | 24.01.26 - ErcanOPAK comment on Why git pull Is Dangerous (And What to Use Instead)

git pull = fetch + merge (implicit and risky). git fetch origin git rebase origin/main Why this mattersCleaner history, fewer merge commits, easier reviews.

Read More
Git

The One Command That Saves You From Accidental Commits

- 24.01.26 - ErcanOPAK comment on The One Command That Saves You From Accidental Commits

Ever committed secrets or junk? git reset –soft HEAD~1 What happensCommit undone, changes preserved, history clean.

Read More
Ajax / JavaScript

Stop Using JSON for Everything — Sometimes HTML Is Faster

- 24.01.26 - ErcanOPAK comment on Stop Using JSON for Everything — Sometimes HTML Is Faster

Returning pre-rendered HTML via Ajax can outperform JSON → DOM rebuild. fetch(‘/comments’) .then(r => r.text()) .then(html => container.innerHTML = html); Why this worksLess JS work, fewer reflows, simpler rendering.

Read More
JavaScript

The Real Difference Between debounce and throttle

- 24.01.26 - ErcanOPAK comment on The Real Difference Between debounce and throttle

Misusing these kills UX and performance. // Debounce: waits until user stops debounce(search, 300); // Throttle: runs at most once per interval throttle(scrollHandler, 200); Why it mattersSearch inputs want debounce. Scroll/resize want throttle.

Read More
JavaScript

Why forEach Breaks Async Logic (and How to Fix It)

- 24.01.26 - ErcanOPAK comment on Why forEach Breaks Async Logic (and How to Fix It)

Array.forEach() does not await async functions.This silently causes race conditions and partial execution. // ❌ This does NOT wait items.forEach(async item => { await process(item); }); // ✅ Correct for (const item of items) { await process(item); } Why this mattersforEach ignores promises. Errors get swallowed, execution order breaks.

Read More
Visual Studio

Why “Edit and Continue” Lies to You

- 24.01.26 - ErcanOPAK comment on Why “Edit and Continue” Lies to You

Edit & Continue may compile — but runtime state may be invalid. Best practice: Use it for logic tweaks Restart for state-heavy changes Knowing when NOT to trust it saves hours.

Read More
Page 30 of 69
« Previous 1 … 25 26 27 28 29 30 31 32 33 34 35 … 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 (448)

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