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

Why git pull Sometimes Corrupts Team History (Even Without Conflicts)

- 31.01.26 - ErcanOPAK comment on Why git pull Sometimes Corrupts Team History (Even Without Conflicts)

The issue is not conflicts.It’s implicit merge commits. What happens git pull = fetch + merge That merge commit: Breaks linear history Hides real change intent Makes bisect harder Safer default git config –global pull.rebase true Why this matters Rebase preserves intent, merge preserves state.Teams need intent.

Read More
Ajax

Why Your Ajax Requests “Randomly” Fail in Production

- 31.01.26 - ErcanOPAK comment on Why Your Ajax Requests “Randomly” Fail in Production

Locally works.Production fails. Cause Preflight CORS requests. What happens Browser sends: OPTIONS /api/data Before: POST /api/data If server doesn’t handle OPTIONS → fail. Minimal fix (ASP.NET example) app.UseCors(builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); Why this matters Ajax failures are often network policy, not JS bugs.

Read More
JavaScript

Why forEach Can Be Slower Than for (And When It Matters)

- 31.01.26 - ErcanOPAK comment on Why forEach Can Be Slower Than for (And When It Matters)

This is NOT about micro-optimizations.It’s about callback overhead. Example items.forEach(item => process(item)); vs for (let i = 0; i < items.length; i++) { process(items[i]); } Why forEach creates a function call per iteration Harder for JS engines to optimize No early break support When it matters Large arrays Hot paths Real-time processing Rule Readability first.But […]

Read More
HTML

The loading=”lazy” Attribute Is Not Just About Images

- 31.01.26 - ErcanOPAK comment on The loading=”lazy” Attribute Is Not Just About Images

Everyone uses it for images.Almost nobody uses it for iframes. Example <iframe src=”https://www.youtube.com/embed/VIDEO_ID” loading=”lazy”> </iframe> Why this matters Prevents layout blocking Improves First Contentful Paint (FCP) Massive win for content-heavy blogs Cause → Effect Less initial network pressure → faster perceived load.

Read More
CSS

Why position: sticky “Randomly” Stops Working

- 31.01.26 - ErcanOPAK comment on Why position: sticky “Randomly” Stops Working

Most people blame the browser.The real reason is parent overflow context. Problem .sidebar { position: sticky; top: 0; } Works… until it doesn’t. Hidden cause If ANY parent has: overflow: hidden; overflow: auto; overflow: scroll; Sticky breaks. Why position: sticky is calculated relative to the nearest scroll container, not the viewport. Fix .parent { overflow: […]

Read More
Windows

Hidden Clipboard Superpower (Nobody Uses This)

- 31.01.26 - ErcanOPAK comment on Hidden Clipboard Superpower (Nobody Uses This)

Press: Win + V You get: Clipboard history Pinned snippets Cross-app reuse Use case Store: SQL snippets Git commands Email templates This alone can save hours per week.

Read More
Windows

Fix Random UI Lag Without Touching Hardware

- 31.01.26 - ErcanOPAK comment on Fix Random UI Lag Without Touching Hardware

Cause Background apps + power profile mismatch. Fix Settings → Power → Power Mode → Best performance Disable “Startup apps” you don’t need Turn off transparency effects Why this works Windows dynamically downclocks UI threads on balanced mode.

Read More
AI

Plan a Real-Life Skill Upgrade in 30 Days

- 31.01.26 - ErcanOPAK comment on Plan a Real-Life Skill Upgrade in 30 Days

Not productivity porn. Real execution. Prompt Create a 30-day plan to learn [SKILL].Constraints: max 45 minutes per day no paid resources weekly measurable outcome final real-world deliverableAvoid motivational language. Be practical. Why it works AI shines at structured planning, not motivation.

Read More
AI

Find Performance Bugs Humans Miss

- 31.01.26 - ErcanOPAK comment on Find Performance Bugs Humans Miss

Humans profile what they expect to be slow.AI finds what’s actually slow. Prompt Review this code for performance risks.Focus on: hidden allocations unnecessary async boundaries repeated I/O GC pressureExplain WHY each issue matters and when it becomes visible in production.Code: [PASTE HERE] Why this matters These issues don’t appear in small test data. They explode […]

Read More
AI

Turn Legacy Code Into Clean Architecture (Without Rewriting)

- 31.01.26 - ErcanOPAK comment on Turn Legacy Code Into Clean Architecture (Without Rewriting)

Use this when You inherit ugly but working code. Prompt Analyze the following code. Identify hidden coupling and responsibility leaks Propose a Clean Architecture refactor without changing behavior Suggest incremental steps, not a full rewrite Show before/after structure diagramsCode: [PASTE HERE] Why it works AI is excellent at structural reasoning, not just code generation.

Read More
Docker

Why Your Docker Image Is Slow Even Though It’s “Small”

- 31.01.26 - ErcanOPAK comment on Why Your Docker Image Is Slow Even Though It’s “Small”

Image size ≠ image performance. Hidden cause Layer invalidation. Most Dockerfiles are written like this: COPY . . RUN npm install Every small file change invalidates the cache. Correct approach COPY package.json package-lock.json ./ RUN npm install COPY . . Cause → Effect Stable dependency layers Faster rebuilds Lower CI/CD costs This is why two […]

Read More
Kubernetes

Why Your Pod “Looks Healthy” But Still Drops Traffic

- 31.01.26 - ErcanOPAK comment on Why Your Pod “Looks Healthy” But Still Drops Traffic

This is a classic production trap. Root cause readinessProbe ≠ livenessProbe Most people use only one. Correct pattern livenessProbe: httpGet: path: /health/live port: 80 readinessProbe: httpGet: path: /health/ready port: 80 Why this matters Liveness = should I restart? Readiness = should I receive traffic? If your app is warming caches or reconnecting DBs, traffic arrives […]

Read More
Wordpress

The Silent SEO Killer: Auto-Generated Attachment Pages

- 31.01.26 - ErcanOPAK comment on The Silent SEO Killer: Auto-Generated Attachment Pages

WordPress creates pages for every uploaded image. What happens Thin content pages Duplicate titles Crawled but useless URLs Fix (no plugin) Redirect attachment pages: add_action(‘template_redirect’, function () { if (is_attachment()) { wp_redirect(home_url(), 301); exit; } }); Why this works You’re reclaiming crawl budget and removing SEO noise. Most blogs never fix this. That’s why it […]

Read More
Wordpress

Stop Using Plugins for Dynamic Content: Use Conditional Blocks Instead

- 31.01.26 - ErcanOPAK comment on Stop Using Plugins for Dynamic Content: Use Conditional Blocks Instead

Most WordPress sites are plugin-heavy for no reason. Hidden power WordPress Block Editor already supports conditional rendering via PHP + block patterns. Example Show a CTA only for logged-out users: if (!is_user_logged_in()) { echo do_blocks(‘<!– wp:buttons –>…<!– /wp:buttons –>’); } Why this matters Fewer plugins → fewer update risks Faster TTFB Full control over UX […]

Read More
Photoshop

Make Cheap Plastic Look Like Premium Metal (Product Photos)

- 31.01.26 - ErcanOPAK comment on Make Cheap Plastic Look Like Premium Metal (Product Photos)

Great for e-commerce & ads. Steps Convert to Smart Object Apply Gradient Map (dark gray → silver) Overlay Directional Motion Blur mask Why it works Metal reflects directionally; plastic diffuses light.You’re faking physics, not color.

Read More
Photoshop

How to Repair a Cracked or Torn Old Photo (Not Retouch — Repair)

- 31.01.26 - ErcanOPAK comment on How to Repair a Cracked or Torn Old Photo (Not Retouch — Repair)

Most people retouch. Professionals reconstruct. Technique Duplicate layer Use Content-Aware Fill only for structure Switch to Clone Stamp (Lighten mode) Why Lighten? It preserves shadows while rebuilding highlights — ideal for cracks. Pro tip Finish with a 5–8% noise layer to unify texture.

Read More
Visual Studio

Why Your Debug Session Lies About Reality (And How to Fix It)

- 31.01.26 - ErcanOPAK comment on Why Your Debug Session Lies About Reality (And How to Fix It)

Ever noticed code behaving differently in Debug vs Release? Root cause Visual Studio injects: Different JIT optimizations Conditional compilation (#if DEBUG) Altered timing (especially async code) Hidden fix Force Release-mode debugging: <PropertyGroup Condition=”‘$(Configuration)’==’Release'”> <DebugType>portable</DebugType> </PropertyGroup> Why this matters Many race conditions only exist in optimized builds.Debug mode can mask real production bugs.

Read More
C#

Why LINQ in Hot Paths Can Kill Performance

- 30.01.26 - ErcanOPAK comment on Why LINQ in Hot Paths Can Kill Performance

LINQ is elegant… and allocates. Problem Deferred execution Hidden enumerators Fix Use LINQ at boundaries, not inside loops. for (int i = 0; i < list.Count; i++) { Process(list[i]); } Why Predictable execution beats elegance under load.

Read More
C#

Why lock(this) Is a Concurrency Time Bomb

- 30.01.26 - ErcanOPAK comment on Why lock(this) Is a Concurrency Time Bomb

You don’t control who else locks this. Fix private readonly object _sync = new(); lock (_sync) { } Why Encapsulation matters in threading.

Read More
C#

Why async void Should Almost Never Exist

- 30.01.26 - ErcanOPAK comment on Why async void Should Almost Never Exist

async void hides exceptions. Only valid Event handlers Wrong async void Process() { throw new Exception(); } Correct async Task Process()  

Read More
SQL

Why Indexes Sometimes Make Queries Slower

- 30.01.26 - ErcanOPAK comment on Why Indexes Sometimes Make Queries Slower

Indexes are not magic. Bad case Low-selectivity columns Over-indexing Diagnosis SET STATISTICS IO ON; Why Wrong index = more lookups than scans.

Read More
SQL

Why SELECT * Destroys Query Performance Over Time

- 30.01.26 - ErcanOPAK comment on Why SELECT * Destroys Query Performance Over Time

Today it’s fine. Tomorrow it’s slow. Why Schema changes Wider rows More IO Fix Select only what you need. SELECT Id, Name FROM Users;  

Read More
Asp.Net Core / C#

Why Background Services Stop Without Errors

- 30.01.26 - ErcanOPAK comment on Why Background Services Stop Without Errors

BackgroundService silently dies if an exception escapes. Rule Always wrap execution loops. while (!stoppingToken.IsCancellationRequested) { try { await DoWork(); } catch (Exception ex) { Log(ex); } } Why Unhandled exceptions kill the worker.

Read More
Asp.Net Core / C#

Why HttpClient Causes Random Timeouts

- 30.01.26 - ErcanOPAK comment on Why HttpClient Causes Random Timeouts

Creating HttpClient per request is a silent killer. Problem Socket exhaustion DNS caching issues Fix Use IHttpClientFactory. services.AddHttpClient(); Why It pools handlers safely.

Read More
Git

Recover a Deleted Commit Without Panic

- 30.01.26 - ErcanOPAK comment on Recover a Deleted Commit Without Panic

Commit gone? Not really. git reflog git checkout <hash> Why Git never deletes immediately — it just forgets references.

Read More
Git

Why git pull Is Dangerous in Long-Lived Branches

- 30.01.26 - ErcanOPAK comment on Why git pull Is Dangerous in Long-Lived Branches

git pull = fetch + merge. That merge may silently introduce conflicts. Safer git fetch git rebase origin/main Why Rebase keeps history linear and reviewable.

Read More
Ajax / JavaScript

Why AJAX Requests Randomly Fail Under Load

- 30.01.26 - ErcanOPAK comment on Why AJAX Requests Randomly Fail Under Load

Works locally. Fails in production. Hidden issue Browsers limit parallel connections per origin. Fix Batch requests Use request queues Prefer a single endpoint await Promise.allSettled(requests); Why Uncontrolled parallelism = dropped requests.

Read More
JavaScript

Why Array.forEach() Breaks Async Logic (Silently)

- 30.01.26 - ErcanOPAK comment on Why Array.forEach() Breaks Async Logic (Silently)

This bug survives code reviews way too often. Problem forEach does not await async callbacks. items.forEach(async item => { await save(item); }); This exits immediately. Errors may never surface. Correct for (const item of items) { await save(item); } Why it matters Async flow control must be explicit, not assumed.

Read More
HTML

Why Forms Fail Silently on Mobile Browsers

- 30.01.26 - ErcanOPAK comment on Why Forms Fail Silently on Mobile Browsers

Form works on desktop… submits nothing on mobile. Common culprit Missing or incorrect input types. Fix <input type=”email” autocomplete=”email” required> Why Mobile browsers optimize behavior based on type.

Read More
CSS

Why CSS Animations Jank on Mobile (Even With Simple Transitions)

- 30.01.26 - ErcanOPAK comment on Why CSS Animations Jank on Mobile (Even With Simple Transitions)

Animations look fine on desktop… then stutter on phones. Root cause Animating layout-triggering properties: width height top / left Correct approach Only animate GPU-friendly properties. transform: translateX(); opacity: 0.9;  

Read More
Page 25 of 69
« Previous 1 … 20 21 22 23 24 25 26 27 28 29 30 … 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