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: July 10, 2026

C#

C#: Use Records for Immutable Data Types

- 10.07.26 - ErcanOPAK comment on C#: Use Records for Immutable Data Types

๐Ÿ“ Records = Immutable Data Classes are mutable. Records are immutable. Value-based equality, concise syntax, data-centric. โŒ Class (Mutable) public class Person { public string Name { get; set; } public int Age { get; set; } } โœ… Record (Immutable) public record Person(string Name, int Age); ๐Ÿ“ Record Features // Positional record public record […]

Read More
C#

C#: Use Indexers for Array-Like Access

- 10.07.26 - ErcanOPAK comment on C#: Use Indexers for Array-Like Access

๐Ÿ“ Indexers = Array-Like Access Custom collections need array access. Indexers provide array-like syntax. Clean, intuitive, flexible. ๐Ÿ“ Indexer Basics // Simple indexer public class StringCollection { private string[] _items = new string[10]; public string this[int index] { get => _items[index]; set => _items[index] = value; } } // Usage var collection = new StringCollection(); […]

Read More
SQL

SQL: Use Triggers for Automated Actions

- 10.07.26 - ErcanOPAK comment on SQL: Use Triggers for Automated Actions

๐Ÿ”” Triggers = Automated Actions Need to automate database actions? Triggers run automatically. Audit logs, data validation, synchronization. ๐Ÿ“ Trigger Basics — Audit trigger (INSERT) CREATE TRIGGER user_audit_insert ON users AFTER INSERT AS BEGIN INSERT INTO audit_log (action, table_name, record_id, changed_by, changed_at) SELECT ‘INSERT’, ‘users’, id, SYSTEM_USER, GETDATE() FROM inserted; END; — Audit trigger (UPDATE) […]

Read More
Asp.Net Core

.NET Core: Configure CORS for API Security

- 10.07.26 - ErcanOPAK comment on .NET Core: Configure CORS for API Security

๐Ÿ” CORS = API Security Browsers block cross-origin requests. CORS configuration enables secure API access. Essential for modern APIs. ๐Ÿ“ CORS Setup // Program.cs var builder = WebApplication.CreateBuilder(args); // Add CORS policy builder.Services.AddCors(options => { options.AddPolicy(“AllowSpecificOrigin”, builder => { builder.WithOrigins(“https://myapp.com”) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); options.AddPolicy(“AllowAll”, builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); options.AddPolicy(“AllowMultipleOrigins”, builder => […]

Read More
Git

Git: Master Git Log for Commit History

- 10.07.26 - ErcanOPAK comment on Git: Master Git Log for Commit History

๐Ÿ“‹ Git Log = Commit History Need to see what changed? Git log shows commit history. Track changes, find bugs, understand code. ๐Ÿ“ Git Log Commands # Basic log git log # One line per commit git log –oneline # Show graph git log –graph git log –graph –oneline # Show changes git log -p […]

Read More
Ajax

Ajax: Use Interceptors for Request/Response Handling

- 10.07.26 - ErcanOPAK comment on Ajax: Use Interceptors for Request/Response Handling

๐Ÿ”ง Interceptors = Request/Response Control Every request needs handling. Interceptors process requests/responses. Auth, logging, retries โ€” centralized. ๐Ÿ“ Axios Interceptors import axios from ‘axios’; // Request interceptor axios.interceptors.request.use( config => { // Add auth token const token = localStorage.getItem(‘token’); if (token) { config.headers.Authorization = `Bearer ${token}`; } return config; }, error => { return Promise.reject(error); […]

Read More
JavaScript

JavaScript: Use Memoization for Performance

- 10.07.26 - ErcanOPAK comment on JavaScript: Use Memoization for Performance

โšก Memoization = Performance Repeated calculations are slow. Memoization caches results. Speed up functions, improve performance. ๐Ÿ“ Memoization Basics // Simple memoization function memoize(fn) { const cache = {}; return function(…args) { const key = JSON.stringify(args); if (cache[key] === undefined) { cache[key] = fn(…args); } return cache[key]; }; } // Expensive function function slowFunction(n) { […]

Read More
HTML

HTML: Use Web Storage for Client-Side Data

- 10.07.26 - ErcanOPAK comment on HTML: Use Web Storage for Client-Side Data

๐Ÿ’พ Web Storage = Client-Side Data Need to store data in browser? Web Storage persists data. Preferences, sessions, carts โ€” no server needed. ๐Ÿ“ Web Storage Methods // LocalStorage (persistent) localStorage.setItem(‘key’, ‘value’); const value = localStorage.getItem(‘key’); localStorage.removeItem(‘key’); localStorage.clear(); // SessionStorage (session only) sessionStorage.setItem(‘key’, ‘value’); const value = sessionStorage.getItem(‘key’); sessionStorage.removeItem(‘key’); sessionStorage.clear(); // Store objects const user […]

Read More
CSS

CSS: Master Z-Index for Stack Order

- 10.07.26 - ErcanOPAK comment on CSS: Master Z-Index for Stack Order

๐Ÿ“š Z-Index = Stack Order Elements overlap. Z-index controls stacking order. Modals, tooltips, dropdowns โ€” proper layering. ๐Ÿ“ Z-Index Basics /* Basic usage */ .modal { z-index: 1000; position: fixed; } .tooltip { z-index: 100; position: absolute; } .dropdown { z-index: 50; position: relative; } /* Stacking context */ .parent { position: relative; z-index: 1; […]

Read More
Windows

Windows 11: Test Your RAM with Memory Diagnostics

- 10.07.26 - ErcanOPAK comment on Windows 11: Test Your RAM with Memory Diagnostics

๐Ÿง  Memory Diagnostics = RAM Testing Faulty RAM causes crashes. Memory Diagnostics tests your RAM. Find bad memory, fix instability. ๐Ÿ“ Running Memory Diagnostic # Open Memory Diagnostic – Search: “Windows Memory Diagnostic” – Or: mdsched.exe (Run) # Options 1. Restart now and check for problems 2. Check for problems the next time I start […]

Read More
AI

AI Prompt: Generate YouTube Video Scripts

- 10.07.26 - ErcanOPAK comment on AI Prompt: Generate YouTube Video Scripts

๐ŸŽฌ AI YouTube Scripts Video scripts take time. AI generates YouTube scripts โ€” hook, body, call-to-action. Create engaging videos. ๐Ÿ“ The Prompt Generate a YouTube video script for: Topic: [Your topic] Duration: [e.g., 5-10 minutes] Target Audience: [e.g., beginners, experts] Style: [e.g., educational, entertaining] Provide: 1. Video Title Options (3-5) 2. Description (SEO optimized) 3. […]

Read More
Docker

Docker: Use Environment Variables with Compose

- 10.07.26 - ErcanOPAK comment on Docker: Use Environment Variables with Compose

๐Ÿ”ง Environment Variables = Configuration Hardcoding config is bad. Environment variables externalize configuration. Different environments, same code. ๐Ÿ“ Using Env Variables # Docker Compose with env version: ‘3.8’ services: app: image: myapp:latest environment: – NODE_ENV=production – DB_HOST=database – DB_USER=postgres – DB_PASSWORD=postgres env_file: – .env – .env.production # .env file NODE_ENV=production DB_HOST=localhost DB_USER=postgres DB_PASSWORD=secret # Using […]

Read More
Kubernetes

Kubernetes: Use CronJobs for Scheduled Tasks

- 10.07.26 - ErcanOPAK comment on Kubernetes: Use CronJobs for Scheduled Tasks

โฐ CronJobs = Scheduled Tasks Regular tasks need automation. CronJobs schedule tasks in Kubernetes. Backups, cleanup, reports โ€” automatic. ๐Ÿ“ CronJob Setup apiVersion: batch/v1 kind: CronJob metadata: name: daily-backup spec: schedule: “0 2 * * *” # Daily at 2 AM jobTemplate: spec: template: spec: containers: – name: backup image: alpine:latest command: – /bin/sh – […]

Read More
Wordpress

WordPress: Supercharge Management with WP-CLI

- 10.07.26 - ErcanOPAK comment on WordPress: Supercharge Management with WP-CLI

โŒจ๏ธ WP-CLI = WordPress Command Line Admin panel is slow. WP-CLI manages WordPress from command line. Fast, automated, powerful. ๐Ÿ“ WP-CLI Setup # Install WP-CLI curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp # Check installation wp –info # Common Commands wp –help # Show all commands wp core # Core management wp […]

Read More
Photoshop

Photoshop: Master Photo Composition Techniques

- 10.07.26 - ErcanOPAK comment on Photoshop: Master Photo Composition Techniques

๐Ÿ“ Composition = Great Photos Great photos start with composition. Composition techniques create stunning images. Balance, rule of thirds, leading lines. ๐Ÿ“ Composition Tools # Rule of Thirds Grid – Enable: View โ†’ Show โ†’ Grid – Or: View โ†’ Show โ†’ Rule of Thirds – Or: Crop tool โ†’ Overlay options # Golden Ratio […]

Read More
Visual Studio

Visual Studio: Master Find & Replace for Code Search

- 10.07.26 - ErcanOPAK comment on Visual Studio: Master Find & Replace for Code Search

๐Ÿ” Find & Replace = Code Search Power Manual search is slow. Find & Replace finds and changes anything. Code, comments, files โ€” all instantly. โŒจ๏ธ Find & Replace Shortcuts Ctrl + F โ†’ Find (current file) Ctrl + H โ†’ Replace (current file) Ctrl + Shift + F โ†’ Find in Files (all files) […]

Read More
C#

C#: Use ValueTuple for Lightweight Multiple Return Values

- 10.07.26 - ErcanOPAK comment on C#: Use ValueTuple for Lightweight Multiple Return Values

๐Ÿ“ฆ ValueTuple = Lightweight Tuples Return multiple values without creating classes. ValueTuple is lightweight, value-based, convenient. ๐Ÿ“ฆ Tuple (Reference Type) var result = Tuple.Create(1, “Alice”); int id = result.Item1; string name = result.Item2; โœ… ValueTuple (Value Type) var result = (Id: 1, Name: “Alice”); int id = result.Id; string name = result.Name; ๐ŸŽฏ ValueTuple Examples […]

Read More
C#

C#: Use Object Initializers for Clean Object Creation

- 10.07.26 - ErcanOPAK comment on C#: Use Object Initializers for Clean Object Creation

๐Ÿ“ฆ Object Initializers = Clean Creation Constructors with many params are messy. Object initializers create objects cleanly. Readable, concise, flexible. โŒ Constructor public class User { public string Name { get; set; } public int Age { get; set; } public string Email { get; set; } public User(string name, int age, string email) { […]

Read More
SQL

SQL: Use Views to Simplify Complex Queries

- 10.07.26 - ErcanOPAK comment on SQL: Use Views to Simplify Complex Queries

๐Ÿ“Š Views = Virtual Tables Complex queries repeated everywhere. Views simplify them. Create once, use like a table. ๐Ÿ“ Create View CREATE VIEW active_users AS SELECT id, name, email, created_at FROM users WHERE status = ‘active’ AND last_login > ‘2024-01-01’; — Query the view SELECT * FROM active_users; — View with JOIN CREATE VIEW order_summary […]

Read More
Asp.Net Core

.NET Core: Use Health Checks for Monitoring

- 10.07.26 - ErcanOPAK comment on .NET Core: Use Health Checks for Monitoring

๐Ÿฅ Health Checks = Monitoring Apps fail silently. Health checks monitor app health. Database, cache, services โ€” all in one. ๐Ÿ“ Health Check Setup # Install package dotnet add package Microsoft.AspNetCore.Diagnostics.HealthChecks # Program.cs var builder = WebApplication.CreateBuilder(args); // Add health checks builder.Services.AddHealthChecks() .AddDbContextCheck() .AddUrlGroup(new Uri(“https://api.example.com”), “External API”) .AddCheck(“Custom”) .AddCheck(“Memory”, new MemoryHealthCheck(512)); var app = builder.Build(); […]

Read More
Git

Git: Use Cherry-pick to Select Specific Commits

- 10.07.26 - ErcanOPAK comment on Git: Use Cherry-pick to Select Specific Commits

๐Ÿ’ Cherry-pick = Selective Commits Don’t need all commits? git cherry-pick applies specific commits. Choose what to bring, leave the rest. ๐Ÿ“ Cherry-pick Commands # Cherry-pick a single commit git cherry-pick commit-hash # Cherry-pick multiple commits git cherry-pick hash1 hash2 hash3 # Cherry-pick range of commits git cherry-pick hash1..hash5 # From hash1 to hash5 git […]

Read More
Ajax

Ajax: Get Started with GraphQL

- 10.07.26 - ErcanOPAK comment on Ajax: Get Started with GraphQL

๐Ÿ“ก GraphQL = Modern API Query REST has over-fetching. GraphQL gets exactly what you need. One endpoint, flexible queries. โŒ REST (Over-fetching) GET /api/users/1 // Gets ALL fields { id, name, email, address, phone, createdAt, updatedAt } โœ… GraphQL (Exact) query { user(id: 1) { name email } } // Gets ONLY what you ask […]

Read More
JavaScript

JavaScript: Master Async/Await for Modern Async Code

- 10.07.26 - ErcanOPAK comment on JavaScript: Master Async/Await for Modern Async Code

โšก Async/Await = Modern Async Promises are good. Async/Await is better. Write async code like sync code. Cleaner, more readable. โŒ Promise Chain fetchUser() .then(user => fetchOrders(user)) .then(orders => fetchDetails(orders)) .then(details => console.log(details)) .catch(err => console.error(err)); โœ… Async/Await try { const user = await fetchUser(); const orders = await fetchOrders(user); const details = await fetchDetails(orders); […]

Read More
HTML

HTML: Use IFrames to Embed Content

- 10.07.26 - ErcanOPAK comment on HTML: Use IFrames to Embed Content

๐Ÿ–ผ๏ธ IFrames = Embed Content Need to embed external content? IFrames embed videos, maps, forms โ€” any external page. ๐Ÿ“ IFrame Basics <!– Basic iframe –> <iframe src=”https://example.com”></iframe> <!– With dimensions –> <iframe src=”https://example.com” width=”600″ height=”400″></iframe> <!– Full features –> <iframe src=”https://example.com” width=”100%” height=”500″ title=”Example Site” allowfullscreen loading=”lazy” sandbox=”allow-scripts allow-same-origin” ></iframe> <!– YouTube Embed –> […]

Read More
CSS

CSS: Master CSS Units (px, em, rem, vh, vw)

- 10.07.26 - ErcanOPAK comment on CSS: Master CSS Units (px, em, rem, vh, vw)

๐Ÿ“ CSS Units = Perfect Sizing Wrong units break designs. CSS units matter. px, em, rem, vh, vw โ€” choose wisely. ๐Ÿ“ Unit Types /* Absolute Units */ px โ†’ Pixels (fixed) pt โ†’ Points (print) pc โ†’ Picas (print) /* Relative Units (Font) */ em โ†’ Relative to parent font-size rem โ†’ Relative to […]

Read More
Windows

Windows 11: Use Clipboard History for Multiple Copies

- 10.07.26 - ErcanOPAK comment on Windows 11: Use Clipboard History for Multiple Copies

๐Ÿ“‹ Clipboard History = Copy Multiple Items One copy at a time is slow. Clipboard History stores multiple items. Copy once, paste anytime. ๐Ÿ“ Enable Clipboard History # Enable Win + V โ†’ Turn on OR Settings โ†’ System โ†’ Clipboard โ†’ Clipboard history # Open Clipboard History Win + V # Features – Store […]

Read More
AI

AI Prompt: Generate Engaging Social Media Captions

- 10.07.26 - ErcanOPAK comment on AI Prompt: Generate Engaging Social Media Captions

๐Ÿ“ฑ AI Social Media Captions Social media needs engagement. AI generates captions โ€” Instagram, LinkedIn, Twitter. Engaging, shareable, effective. ๐Ÿ“ The Prompt Generate social media captions for: Topic: [Your topic] Platform: [Instagram, LinkedIn, Twitter, TikTok] Tone: [e.g., inspirational, educational, funny] Target Audience: [e.g., professionals, creatives] Provide: 1. Instagram Caption (5 options) – Hook in first […]

Read More
Docker

Docker: Master Container Logging for Debugging

- 10.07.26 - ErcanOPAK comment on Docker: Master Container Logging for Debugging

๐Ÿ“‹ Container Logs = Debugging Power Containers fail silently. Container logs reveal everything. Debug, monitor, track problems. ๐Ÿ“ Log Commands # Show logs docker logs container_name # Follow logs (real-time) docker logs -f container_name # Last N lines docker logs –tail 100 container_name # With timestamps docker logs -t container_name # Since specific time docker […]

Read More
Kubernetes

Kubernetes: Choose the Right Service Type

- 10.07.26 - ErcanOPAK comment on Kubernetes: Choose the Right Service Type

๐Ÿ”Œ Service Types = How to Expose Apps Pods need access. Service types control exposure. ClusterIP, NodePort, LoadBalancer โ€” choose right one. ๐Ÿ“ Service Types # ClusterIP (Default) apiVersion: v1 kind: Service metadata: name: internal-app spec: type: ClusterIP selector: app: myapp ports: – port: 80 targetPort: 8080 # NodePort apiVersion: v1 kind: Service metadata: name: […]

Read More
Wordpress

WordPress: Master ACF for Custom Fields

- 10.07.26 - ErcanOPAK comment on WordPress: Master ACF for Custom Fields

๐Ÿ“ ACF = Advanced Custom Fields WordPress fields are limited. ACF creates custom fields. Any field type, any layout โ€” flexible content. ๐Ÿ“ ACF Field Types # Text Fields – Text – Text Area – WYSIWYG Editor – Number – Email – Password # Choice Fields – Select – Checkbox – Radio Button – True […]

Read More
Page 1 of 2
1 2 Next ยป

Posts pagination

1 2 Next »
July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

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