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

Day: June 6, 2026

Photoshop

Photoshop: Use Channel Mixer for Professional Black and White Conversions

- 06.06.26 - ErcanOPAK comment on Photoshop: Use Channel Mixer for Professional Black and White Conversions

🎛️ Desaturate is Ugly. Channel Mixer is Art. Desaturate removes color equally. Channel Mixer lets you control how red, green, blue contribute to final image. Ansel Adams-style control. 📝 How to Use Adjustment Layer → Channel Mixer → Check “Monochrome” Now adjust: – Red: 0-200% (how much red channel contributes) – Green: 0-200% – Blue: […]

Read More
Visual Studio

Visual Studio: Use CodeLens to See References Without Searching

- 06.06.26 - ErcanOPAK comment on Visual Studio: Use CodeLens to See References Without Searching

👁️ Above Every Method: Who Uses It? Right-click → Find All References is slow. CodeLens shows reference count right above method names. Click to see list. No context switching. 🔧 Enable CodeLens Tools → Options → Text Editor → All Languages → CodeLens Check: “Enable CodeLens” Features shown: – References: 3 references (click to see […]

Read More
C#

C#: Use Collection Literals for Cleaner Array and List Creation

- 06.06.26 - ErcanOPAK comment on C#: Use Collection Literals for Cleaner Array and List Creation

[] Instead of new List<int> { 1, 2, 3 } Collection literals are coming to C# 12. [1, 2, 3] works for arrays, lists, spans. Finally, Python-like syntax. 📝 Collection Literal Syntax int[] numbers = [1, 2, 3, 4, 5]; List<string> names = [“Alice”, “Bob”, “Charlie”]; Span<int> spanNumbers = [10, 20, 30]; ReadOnlySpan<char> chars = […]

Read More
C#

C#: Use Required Keyword to Enforce Property Initialization

- 06.06.26 - ErcanOPAK comment on C#: Use Required Keyword to Enforce Property Initialization

✅ No More Uninitialized Non-Nullable Properties Nullable Reference Types warned about nulls. required makes initialization mandatory at compile time. ❌ Before (Runtime Null) public class User { public string Name { get; set; } } var user = new User(); user.Name.Length; // 💥 NullReferenceException ✅ Required (Compile Error) public class User { public required string […]

Read More
SQL

SQL: Use Materialized Views for Precomputed Query Results

- 06.06.26 - ErcanOPAK comment on SQL: Use Materialized Views for Precomputed Query Results

⚡ Views are Virtual. Materialized Views are Cached. Regular views run query every time. Materialized views store results. 100x faster for expensive aggregations. Refresh on schedule. 📝 Create Materialized View (PostgreSQL) CREATE MATERIALIZED VIEW daily_sales_summary AS SELECT DATE(order_date) as sale_date, COUNT(*) as order_count, SUM(total) as total_revenue, AVG(total) as avg_order_value, COUNT(DISTINCT user_id) as unique_customers FROM orders […]

Read More
Asp.Net Core

.NET Core: Bind Configuration to Strongly Typed Objects

- 06.06.26 - ErcanOPAK comment on .NET Core: Bind Configuration to Strongly Typed Objects

🎯 Use IOptions Instead of IConfiguration Everywhere _config[“Database:ConnectionString”] is stringly typed. IOptions<T> binds to class. Strong typing, validation, reload support. 📝 Define Settings Class public class DatabaseSettings { public string ConnectionString { get; set; } = string.Empty; public int CommandTimeout { get; set; } = 30; public int MaxPoolSize { get; set; } = 100; […]

Read More
Git

Git: Use Git Worktree to Work on Multiple Branches at Once

- 06.06.26 - ErcanOPAK comment on Git: Use Git Worktree to Work on Multiple Branches at Once

🌲 No More git stash While Switching Branches Stash, switch, work, stash back, switch… painful. Git worktree checks out multiple branches simultaneously. Work on two branches side by side. 📝 Basic Worktree # Create worktree for feature branch git worktree add ../project-feature feature-branch # Now you have: # /project (main branch) # /project-feature (feature-branch) # […]

Read More
Ajax

Ajax: Use Trusted Types to Prevent DOM-Based XSS

- 06.06.26 - ErcanOPAK comment on Ajax: Use Trusted Types to Prevent DOM-Based XSS

🛡️ Lock Down XSS Attack Vectors innerHTML with user input is dangerous. Trusted Types enforce sanitization. Only trusted HTML can be injected. 📝 Enable Trusted Types // CSP Header (enable Trusted Types) Content-Security-Policy: require-trusted-types-for ‘script’; trusted-types default // Or meta tag <meta http-equiv=”Content-Security-Policy” content=”require-trusted-types-for ‘script’; trusted-types default”> // Create a policy const policy = trustedTypes.createPolicy(‘myPolicy’, […]

Read More
JavaScript

JavaScript: Use Error Cause for Better Error Chains

- 06.06.26 - ErcanOPAK comment on JavaScript: Use Error Cause for Better Error Chains

🔗 Don’t Lose the Original Error Throwing new Error() loses original stack. Error cause chains errors. See full context. 📝 Without Error Cause (Lost Context) try { await fetchUser(userId); } catch (err) { throw new Error(`Failed to get user ${userId}`); // Original error stack lost! } ✅ With Error Cause (Full Context) try { await […]

Read More
HTML

HTML: Use beforematch Event to Lazy Load Hidden Content

- 06.06.26 - ErcanOPAK comment on HTML: Use beforematch Event to Lazy Load Hidden Content

⚡ Load Content Before It’s Revealed Find in page reveals hidden content. beforematch fires before reveal. Load heavy content only when needed. 📝 Basic Example <details hidden> <summary>Click to expand</summary> <div class=”heavy-content” data-loaded=”false”> Loading… </div> </details> <script> document.querySelector(‘details’).addEventListener(‘beforematch’, (e) => { const container = e.target.querySelector(‘.heavy-content’); if (container.dataset.loaded === ‘false’) { // Load heavy content only […]

Read More
CSS

CSS: Use Container Style Queries to Respond to Parent Styling

- 06.06.26 - ErcanOPAK comment on CSS: Use Container Style Queries to Respond to Parent Styling

🎨 Not Just Size, But Parent’s CSS Properties Container queries check parent size. Style queries check parent CSS values. Dark mode per component? Yes. 📝 Basic Style Query .card { container-name: card; container-type: inline-size; } @container card style(–theme: dark) { .card { background: #1a1a2e; color: #e0e0e0; border-color: #333; } } @container card style(–theme: light) { […]

Read More
Windows

Windows 11: Use Quick Assist to Help Friends and Family Remotely

- 06.06.26 - ErcanOPAK comment on Windows 11: Use Quick Assist to Help Friends and Family Remotely

🖥️ TeamViewer Alternative Built into Windows No need to install TeamViewer or AnyDesk. Quick Assist is built-in. View or take control of remote PC. No account required for guest. 🔧 How to Use Helper (you): Start → Quick Assist → Assist another person Sign in with Microsoft account → Get security code Guest (person needing […]

Read More
AI

AI Prompt: Generate JSON Schema from Sample Data

- 06.06.26 - ErcanOPAK comment on AI Prompt: Generate JSON Schema from Sample Data

📋 Generate Validation Rules from Example JSON Writing JSON Schema by hand is painful. AI generates schema from examples. Infer types, required fields, patterns, constraints. 📝 The Prompt Generate a JSON Schema (draft-07) from these example objects: Examples: [{{“id”: 1, “name”: “Alice”, “email”: “alice@example.com”, “age”: 30}}, {{“id”: 2, “name”: “Bob”, “email”: “bob@example.com”, “age”: 25}}, {{“id”: […]

Read More
Docker

Docker: Use Distroless Images for Maximum Security

- 06.06.26 - ErcanOPAK comment on Docker: Use Distroless Images for Maximum Security

🔐 No Shell. No Package Manager. No Attack Surface. Alpine has sh, curl, wget. Distroless has ONLY your app and its runtime. Can’t exec into container. Can’t install malware. Minimum attack surface. 📝 Distroless Dockerfile # Multi-stage build FROM golang:1.21 AS builder WORKDIR /app COPY . . RUN CGO_ENABLED=0 go build -o app # Distroless […]

Read More
Kubernetes

Kubernetes: Enforce Pod Security Standards at Namespace Level

- 06.06.26 - ErcanOPAK comment on Kubernetes: Enforce Pod Security Standards at Namespace Level

🔒 PodSecurityPolicy is Deprecated. PSS is Here. PSP was complex. Pod Security Standards (PSS) are built-in. Three levels: Privileged, Baseline, Restricted. Apply per namespace. 📝 Apply PSS to Namespace # Label namespace for enforcement kubectl label namespace production pod-security.kubernetes.io/enforce=baseline kubectl label namespace production pod-security.kubernetes.io/enforce-version=latest # Warn mode (logs warning, doesn’t block) kubectl label namespace staging […]

Read More
Wordpress

WordPress: Create Custom Shortcodes for Dynamic Content

- 06.06.26 | 06.06.26 - ErcanOPAK comment on WordPress: Create Custom Shortcodes for Dynamic Content

🔌 [shortcode] in Post Content = PHP Function Users can’t run PHP in posts. Shortcodes let them. Write PHP once, users use [shortcode] anywhere. Galleries, forms, dynamic lists. 📝 Basic Shortcode // functions.php function recent_posts_shortcode($atts) { $args = shortcode_atts(array( ‘count’ => 5, ‘category’ => ” ), $atts); $query = new WP_Query(array( ‘posts_per_page’ => $args[‘count’], ‘category_name’ […]

Read More
Photoshop

Photoshop: Master Curves for Professional Color Grading

- 06.06.26 - ErcanOPAK comment on Photoshop: Master Curves for Professional Color Grading

📈 Levels is Beginner. Curves is Pro. Levels adjusts black, white, gamma. Curves controls ANY brightness level independently. Cinema-grade color grading in your hands. 📝 How to Use Adjustment Layer → Curves Click on line to add points: – Bottom-left (0,0): Shadows – Middle (128,128): Midtones – Top-right (255,255): Highlights Drag points up = lighter […]

Read More
Visual Studio

Visual Studio: Use Live Share to Debug with Remote Team Members

- 06.06.26 - ErcanOPAK comment on Visual Studio: Use Live Share to Debug with Remote Team Members

👥 Pair Programming Without Screen Share Screen share is passive. Live Share lets both developers edit, debug, and navigate. Shared servers, terminals, and even voice. 🔧 Start Live Share Install extension: Live Share (Microsoft) Start: View → Other Windows → Live Share → Start Session Share link with team member (valid for 30 minutes) Features: […]

Read More
Page 2 of 2
« Previous 1 2

Posts pagination

« Previous 1 2
June 2026
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  
« May    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (954)
  • 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)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (580)
  • Add Constraint to SQL Table to ensure email contains @ (580)
  • Average of all values in a column that are not zero in SQL (541)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (506)
  • Find numbers with more than two decimal places in SQL (455)

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 (954)
  • 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