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

Month: May 2026

Kubernetes

Kubernetes: Use Taints and Tolerations to Control Pod Placement

- 30.05.26 - ErcanOPAK comment on Kubernetes: Use Taints and Tolerations to Control Pod Placement

๐Ÿšซ Dedicated Nodes for Special Workloads Some nodes have GPUs. Some are spot instances. Taints repel pods. Tolerations allow them. Control exactly where workloads run. ๐Ÿ“ Add Taint to Node # Taint effects: # NoSchedule: Pods without toleration won’t be scheduled # PreferNoSchedule: Avoid if possible # NoExecute: Evict existing pods without toleration # Add […]

Read More
Wordpress

WordPress: Control Autoloaded Options to Speed Up Admin

- 30.05.26 - ErcanOPAK comment on WordPress: Control Autoloaded Options to Speed Up Admin

โšก 80% of Options Load on Every Page WordPress loads all ‘autoload’ options on every request. Many are never used. Clean your autoloaded options for faster admin. ๐Ÿ“ Check Autoloaded Options — SQL Query to see autoloaded options SELECT COUNT(*), SUM(LENGTH(option_value)) as total_size FROM wp_options WHERE autoload = ‘yes’; — List largest autoloaded options SELECT […]

Read More
Photoshop

Photoshop: Master Clone Stamp for Perfect Retouching

- 30.05.26 - ErcanOPAK comment on Photoshop: Master Clone Stamp for Perfect Retouching

๐ŸŽจ Copy Pixels from Anywhere Remove blemishes, duplicate objects, fix textures. Clone Stamp copies from one area and paints to another. Essential for retouching. โŒจ๏ธ Shortcuts S โ†’ Select Clone Stamp Alt+Click โ†’ Set source point [ / ] โ†’ Decrease/Increase brush size Shift+[ / ] โ†’ Decrease/Increase brush hardness Alt+Shift+Click โ†’ Set source from […]

Read More
Visual Studio

Visual Studio: Use Temporary Breakpoints That Delete Themselves After Hit

- 30.05.26 - ErcanOPAK comment on Visual Studio: Use Temporary Breakpoints That Delete Themselves After Hit

๐ŸŽฏ Break Once, Then Vanish Need to inspect a value just once? Regular breakpoint pauses every time. Temporary breakpoints delete themselves after first hit. Perfect for one-time inspections. ๐Ÿ”ง How to Create Method 1: Right-click breakpoint โ†’ Conditions โ†’ Check “Remove breakpoint when hit” Method 2: Hover over red breakpoint dot โ†’ Settings gear โ†’ […]

Read More
C#

C#: Use DateOnly and TimeOnly When You Don’t Need DateTime

- 29.05.26 - ErcanOPAK comment on C#: Use DateOnly and TimeOnly When You Don’t Need DateTime

๐Ÿ“… Date Without Time. Time Without Date. Birthday has no time. Alarm has no date. DateOnly and TimeOnly prevent bugs from midnight times, time zones, and meaningless components. ๐Ÿ“ DateOnly Examples // Create DateOnly DateOnly birthday = new DateOnly(1990, 5, 15); DateOnly today = DateOnly.FromDateTime(DateTime.Today); // Parse DateOnly parsed = DateOnly.Parse(“2024-12-25”); // Operations DateOnly tomorrow […]

Read More
C#

C#: Use Caller Info Attributes for Better Logging Without Reflection

- 29.05.26 - ErcanOPAK comment on C#: Use Caller Info Attributes for Better Logging Without Reflection

๐Ÿ“ Know Who Called You Logging without caller info is useless. Caller Info Attributes give you file path, line number, member name โ€” at compile time. Zero performance cost. ๐Ÿ“ Basic Usage using System.Runtime.CompilerServices; public static void Log(string message, [CallerFilePath] string file = “”, [CallerLineNumber] int line = 0, [CallerMemberName] string member = “”) { […]

Read More
SQL

SQL: Use Recursive CTE to Query Hierarchical Data (Employee Trees)

- 29.05.26 - ErcanOPAK comment on SQL: Use Recursive CTE to Query Hierarchical Data (Employee Trees)

๐ŸŒณ Self-Joins Are Painful. CTE Makes It Easy. Org charts, categories, comments, folder trees โ€” all hierarchical. Recursive CTEs query parent-child relationships elegantly. ๐Ÿ“ Employee Hierarchy — Table structure CREATE TABLE employees ( id INT PRIMARY KEY, name VARCHAR(100), manager_id INT REFERENCES employees(id) ); — Recursive CTE to get org tree WITH RECURSIVE org_tree AS […]

Read More
Asp.Net Core

.NET Core: Use Problem Details for Standardized API Error Responses

- 29.05.26 - ErcanOPAK comment on .NET Core: Use Problem Details for Standardized API Error Responses

๐Ÿ“‹ RFC 7807 Standard Errors Every API invents its own error format. Problem Details (RFC 7807) standardizes HTTP error responses. Clients understand errors universally. ๐Ÿ“ Enable Problem Details // Program.cs builder.Services.AddProblemDetails(); var app = builder.Build(); app.UseStatusCodePages(); // or app.UseProblemDetails(); // More control // Now 404, 400, 500 errors return RFC 7807 format ๐ŸŽฏ Custom Problem […]

Read More
Git

Git: Use Worktrees to Work on Multiple Branches at Once

- 29.05.26 - ErcanOPAK comment on Git: Use Worktrees to Work on Multiple Branches at Once

๐ŸŒฒ Multiple Checkouts, One Repository Need to compare main vs feature branch? Stash not enough? git worktree checks out multiple branches simultaneously. No switching, no stashing. ๐Ÿ“ Basic Worktree # Create worktree for feature branch git worktree add ../project-feature feature-branch # Now you have: # /project (main branch) # /project-feature (feature-branch) # Open both in […]

Read More
Ajax

Ajax: Use Navigator.sendBeacon() for Reliable Analytics on Page Unload

- 29.05.26 - ErcanOPAK comment on Ajax: Use Navigator.sendBeacon() for Reliable Analytics on Page Unload

๐Ÿ“ก Track User Actions Even When They Leave fetch() on page unload gets cancelled. sendBeacon() sends data asynchronously, survives page close. Perfect for analytics, logging, exit tracking. ๐Ÿ“ Basic Usage // Track page unload window.addEventListener(‘beforeunload’, () => { const data = { event: ‘page_exit’, timeOnPage: performance.now(), url: window.location.href }; const blob = new Blob([JSON.stringify(data)], {type: […]

Read More
JavaScript

JavaScript: Use structuredClone() for True Deep Copy of Objects

- 29.05.26 - ErcanOPAK comment on JavaScript: Use structuredClone() for True Deep Copy of Objects

๐Ÿ“ฆ Finally, True Deep Copy Without Libraries JSON.parse(JSON.stringify()) fails with dates, undefined, functions. structuredClone() handles dates, maps, sets, arrays, nested objects โ€” everything. โŒ JSON Hack (Broken) const obj = { date: new Date(), fn: () => {}, undef: undefined }; const copy = JSON.parse(JSON.stringify(obj)); // date becomes string! // fn and undef are gone! […]

Read More
HTML

HTML: Use Download Attribute to Force File Download Instead of Opening

- 29.05.26 - ErcanOPAK comment on HTML: Use Download Attribute to Force File Download Instead of Opening

๐Ÿ“ฅ Click to Download, Not to Preview PDF opens in browser. Image displays. User right-clicks, “Save as”. download attribute forces download with custom filename. ๐Ÿ“ Basic Usage <!– Download with original filename –> <a href=”/files/report.pdf” download>Download PDF</a> <!– Download with custom filename –> <a href=”/files/report.pdf” download=”Q4_Report_2024.pdf”> Download PDF </a> <!– Image download –> <a href=”image.jpg” […]

Read More
CSS

CSS: Use Scroll Snap for Smooth, Snap-to-Section Scrolling

- 29.05.26 - ErcanOPAK comment on CSS: Use Scroll Snap for Smooth, Snap-to-Section Scrolling

๐Ÿ“ฑ Native Scroll Snap โ€” No JavaScript Horizontal carousels, full-page scroll, image galleries โ€” all with CSS scroll snap. No JS, smooth physics, works everywhere. ๐Ÿ“ Full-Page Vertical Scroll Snap .container { scroll-snap-type: y mandatory; overflow-y: scroll; height: 100vh; } .section { scroll-snap-align: start; height: 100vh; } /* HTML structure */ <div class=”container”> <section class=”section”>Page […]

Read More
Windows

Windows 11: Create God Mode Folder for All Settings in One Place

- 29.05.26 - ErcanOPAK comment on Windows 11: Create God Mode Folder for All Settings in One Place

๐Ÿ‘‘ All Control Panels, One Folder Settings scattered everywhere. God Mode creates a folder with EVERY setting. Administrative Tools, Ease of Access, Network, Personalization โ€” all in one place. ๐Ÿ”ง Create God Mode Folder 1. Right-click on Desktop 2. New โ†’ Folder 3. Rename folder to: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C} 4. Press Enter 5. Double-click folder โ†’ Contains […]

Read More
AI

AI Prompt: Generate Complex Terminal Commands from Plain English

- 29.05.26 - ErcanOPAK comment on AI Prompt: Generate Complex Terminal Commands from Plain English

๐Ÿ’ป “Find all files modified yesterday” โ†’ Terminal Command Can’t remember sed syntax? Awk? Grep flags? AI translates English to shell commands. Stop Googling, start doing. ๐Ÿ“ The Prompt Generate a terminal command (bash/zsh) for: [Describe what you want to do] Requirements: – Use safe flags (no destructive commands unless specified) – Include explanation of […]

Read More
Docker

Docker: Enable BuildKit for Faster, More Secure Image Builds

- 29.05.26 - ErcanOPAK comment on Docker: Enable BuildKit for Faster, More Secure Image Builds

โšก Parallel Builds = 2x Faster Old Docker builds run sequentially. BuildKit runs independent stages in parallel. Skipping unused stages. Secret mount without layers. Game changer. ๐Ÿ”ง Enable BuildKit # Environment variable export DOCKER_BUILDKIT=1 docker build . # Or always enable (add to ~/.docker/config.json) { “auth”: { … }, “features”: { “buildkit”: true } } […]

Read More
Kubernetes

Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

- 29.05.26 - ErcanOPAK comment on Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

๐Ÿ›ก๏ธ Don’t Drain All Pods at Once Node draining, cluster upgrades, autoscaling down โ€” they all kill pods. PodDisruptionBudget ensures minimum availability during voluntary disruptions. ๐Ÿ“ PDB Examples # At least 2 pods available at all times apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: minAvailable: 2 selector: matchLabels: app: myapp # No more than […]

Read More
Wordpress

WordPress: Control Heartbeat API to Reduce Server Load

- 29.05.26 - ErcanOPAK comment on WordPress: Control Heartbeat API to Reduce Server Load

โค๏ธ Your Admin Is Making Unnecessary Requests WordPress Heartbeat API pings server every 15-60 seconds. On high-traffic admin, this kills performance. Control or disable it. ๐Ÿ“ Reduce Heartbeat Frequency // functions.php add_filter(‘heartbeat_settings’, ‘custom_heartbeat_settings’); function custom_heartbeat_settings($settings) { $settings[‘interval’] = 120; // Change to 120 seconds (default 15) return $settings; } // Disable completely on admin add_action(‘init’, […]

Read More
Photoshop

Photoshop: Use Content-Aware Fill to Remove Objects Like Magic

- 29.05.26 - ErcanOPAK comment on Photoshop: Use Content-Aware Fill to Remove Objects Like Magic

โœจ Make Objects Disappear Tourist in background? Unwanted logo? Content-Aware Fill analyzes surrounding pixels and fills selection seamlessly. Like magic eraser. ๐Ÿ“ How To Use 1. Select object to remove (Lasso, Pen, Magic Wand) 2. Edit โ†’ Fill (Shift+F5) 3. In dialog: Contents โ†’ Content-Aware 4. Opacity: 100% 5. Click OK โ†’ Object disappears! For […]

Read More
Visual Studio

Visual Studio: Use Peek Definition (Alt+F12) Without Leaving Your File

- 29.05.26 - ErcanOPAK comment on Visual Studio: Use Peek Definition (Alt+F12) Without Leaving Your File

๐Ÿ‘€ See Code Without Opening New Tabs F12 opens new tab, breaks flow. Alt+F12 (Peek Definition) shows code inline. Edit, navigate, close with Esc. Stay in context. โŒจ๏ธ Shortcuts Alt+F12 โ†’ Peek Definition (inline view) Shift+Alt+F12 โ†’ Peek References (where method is used) Ctrl+Alt+F12 โ†’ Peek to Implementation (interfaces) Within peek window: Ctrl+Alt+Home โ†’ Promote […]

Read More
C#

C#: Use Native AOT to Compile .NET Apps to Single Executables

- 28.05.26 - ErcanOPAK comment on C#: Use Native AOT to Compile .NET Apps to Single Executables

๐Ÿ“ฆ One .exe, No Runtime Required .NET app needs runtime installed. Native AOT compiles to single native executable. Fast startup, small container size, no .NET on target machine. ๐Ÿ”ง Enable Native AOT <PropertyGroup> <PublishAot>true</PublishAot> </PropertyGroup> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <PublishAot>true</PublishAot> <JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault> <TrimMode>full</TrimMode> </PropertyGroup> โš™๏ธ Publish Command # Windows (x64) dotnet publish -c Release -r win-x64 –self-contained -p:PublishAot=true […]

Read More
C#

C#: Use Span for High-Performance Memory Access Without Allocation

- 28.05.26 - ErcanOPAK comment on C#: Use Span for High-Performance Memory Access Without Allocation

โšก Zero-Allocation Slicing Span<T> gives a view into memory without copying. No allocations, no GC pressure. Ideal for parsing, string manipulation, and high-performance scenarios. โŒ Allocating Substring // Allocates new string (GC pressure) string data = “123,456,789”; string first = data.Substring(0, 3); // New string allocation string second = data.Substring(4, 3); // Another allocation // […]

Read More
SQL

SQL: Use Partial Indexes to Index Only Relevant Rows

- 28.05.26 - ErcanOPAK comment on SQL: Use Partial Indexes to Index Only Relevant Rows

๐ŸŽฏ Index Only What You Query Full indexes waste space. Partial indexes index only rows matching a WHERE clause. Smaller, faster, more efficient. ๐Ÿ“ Basic Partial Index — Index only active users (not soft-deleted) CREATE INDEX idx_active_users_email ON users(email) WHERE deleted_at IS NULL; — Query uses this index automatically SELECT * FROM users WHERE email […]

Read More
Asp.Net Core

.NET Core: Understanding Middleware Order (It Matters!)

- 28.05.26 - ErcanOPAK comment on .NET Core: Understanding Middleware Order (It Matters!)

๐Ÿ”„ Order of Registration = Order of Execution Wrong middleware order = broken app. Auth before Routing? Exception handling after everything? Order matters dramatically. โœ… Correct Order (Recommended) var app = builder.Build(); // 1. Exception handling (catch errors from everything) if (app.Environment.IsDevelopment()) app.UseDeveloperExceptionPage(); else app.UseExceptionHandler(“/error”); // 2. Security (run early) app.UseHsts(); app.UseHttpsRedirection(); // 3. Static […]

Read More
Git

Git: Use Reflog to Recover Deleted Commits and Branches

- 28.05.26 - ErcanOPAK comment on Git: Use Reflog to Recover Deleted Commits and Branches

๐Ÿ•ฐ๏ธ Git’s Time Machine Accidentally deleted branch? Reset –hard too far? Reflog logs every HEAD change. Rewind time, recover lost work. ๐Ÿ“ View Reflog # View all reflog entries git reflog # Output: # a1b2c3d HEAD@{0}: commit: Add feature # d4e5f6g HEAD@{1}: checkout: moving from main to feature # g7h8i9j HEAD@{2}: reset: moving to HEAD~2 […]

Read More
Ajax

Ajax: Use FormData API for File Uploads Without Libraries

- 28.05.26 - ErcanOPAK comment on Ajax: Use FormData API for File Uploads Without Libraries

๐Ÿ“ Drag & Drop + Progress Bar, Native No more FormData polyfills. FormData API sends forms + files with fetch. Track upload progress, handle multiple files. ๐Ÿ“ Basic File Upload <input type=”file” id=”fileInput” multiple> <button onclick=”uploadFiles()”>Upload</button> <progress id=”progressBar” value=”0″ max=”100″></progress> async function uploadFiles() { const files = document.getElementById(‘fileInput’).files; const formData = new FormData(); for (let […]

Read More
JavaScript

JavaScript: Use Top-Level Await in Modules for Cleaner Async Code

- 28.05.26 | 28.05.26 - ErcanOPAK comment on JavaScript: Use Top-Level Await in Modules for Cleaner Async Code

โฐ Async Without Async Function Wrapper Need await at top level? Used to need IIFE. Top-level await works directly in ES modules. Cleaner initialization code. โŒ Old Way (IIFE) (async () => { const data = await fetch(‘/api/config’); const config = await data.json(); startApp(config); })(); โœ… Top-Level Await // In .mjs or type=”module” script const […]

Read More
HTML

HTML: Use Native Dialog Element for Modals Without JavaScript Libraries

- 28.05.26 - ErcanOPAK comment on HTML: Use Native Dialog Element for Modals Without JavaScript Libraries

๐Ÿ“ฑ Built-in Modal, No Library <dialog> element creates native modals. Accessibility, focus management, backdrop โ€” all built-in. No more 100KB modal libraries. ๐Ÿ“ Basic Dialog <dialog id=”myDialog”> <h2>Confirm Action</h2> <p>Are you sure you want to delete this item?</p> <form method=”dialog”> <button value=”cancel”>Cancel</button> <button value=”confirm”>Confirm</button> </form> </dialog> <button onclick=”myDialog.showModal()”>Open Modal</button> <script> myDialog.addEventListener(‘close’, () => { console.log(‘Closed […]

Read More
CSS

CSS: Use :has() Selector to Style Parent Elements Based on Children

- 28.05.26 - ErcanOPAK comment on CSS: Use :has() Selector to Style Parent Elements Based on Children

๐Ÿ‘จโ€๐Ÿ‘ง Parent Finally Knows About Child CSS couldn’t select parent based on children. Until now. :has() changes everything โ€” style parent when child exists. โŒ Before :has() // JavaScript needed if (card.querySelector(‘.badge’)) { card.classList.add(‘has-badge’); } โœ… With :has() // Pure CSS! .card:has(.badge) { border-left: 4px solid gold; } ๐ŸŽฏ Powerful Examples // Style form that […]

Read More
Windows

Windows 11: Use Focus Sessions to Eliminate Distractions

- 28.05.26 - ErcanOPAK comment on Windows 11: Use Focus Sessions to Eliminate Distractions

๐Ÿง˜ Built-In Pomodoro Timer Notifications, taskbar badges, flashing icons โ€” all distractions. Focus Sessions silence everything, set timers, track productivity. ๐Ÿ”ง Start a Focus Session Method 1: Clock app โ†’ Focus Sessions Method 2: Taskbar clock/calendar โ†’ Focus Method 3: Settings โ†’ System โ†’ Focus Shortcut: Win + N โ†’ Focus โš™๏ธ Configure Do Not […]

Read More
Page 3 of 5
ยซ Previous 1 2 3 4 5 Next ยป

Posts pagination

« Previous 1 2 3 4 5 Next »
May 2026
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Mar   Jun »

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)
  • Add Constraint to SQL Table to ensure email contains @ (580)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (579)
  • Average of all values in a column that are not zero in SQL (538)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (506)
  • Find numbers with more than two decimal places in SQL (454)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files
  • Ajax: Add Custom Headers to Fetch Requests
  • JavaScript: Use console.table to Display Arrays as Tables
  • HTML: Use Spellcheck Attribute to Enable Browser Spell Check
  • CSS: Use user-select to Prevent Text Selection
  • Windows 11: Use Snipping Tool for Instant Screenshots

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com