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

C#

C#: Use Using Statements for Resource Management

- 12.07.26 - ErcanOPAK comment on C#: Use Using Statements for Resource Management

πŸ“¦ Using = Resource Management Resources leak without cleanup. Using statements ensure disposal. Files, connections, streams β€” auto-cleanup. ❌ Manual Cleanup var file = File.Open(“file.txt”); try { // Use file } finally { file.Dispose(); } βœ… Using Statement using var file = File.Open(“file.txt”); // Use file – auto-disposed πŸ“ Using Examples // File operations using […]

Read More
C#

C#: Use Lambda Expressions for Concise Code

- 12.07.26 - ErcanOPAK comment on C#: Use Lambda Expressions for Concise Code

⚑ Lambda Expressions = Concise Code Anonymous methods are verbose. Lambda expressions are concise. One-liners for LINQ, delegates, events. ❌ Anonymous Method Func square = delegate(int x) { return x * x; }; βœ… Lambda Expression Func square = x => x * x; πŸ“ Lambda Examples // Basic syntax (parameters) => expression (parameters) => […]

Read More
SQL

SQL: Use GROUP BY for Data Aggregation

- 12.07.26 - ErcanOPAK comment on SQL: Use GROUP BY for Data Aggregation

πŸ“Š GROUP BY = Data Aggregation Raw data is too detailed. GROUP BY summarizes data. Counts, sums, averages β€” powerful analysis. πŸ“ GROUP BY Basics — Count by category SELECT category, COUNT(*) as product_count FROM products GROUP BY category; — Sum by customer SELECT customer_id, SUM(total) as total_spent, COUNT(*) as order_count FROM orders GROUP BY […]

Read More
Asp.Net Core

.NET Core: Master Routing for Clean URLs

- 12.07.26 - ErcanOPAK comment on .NET Core: Master Routing for Clean URLs

πŸ—ΊοΈ Routing = Clean URLs URLs matter. Routing maps URLs to code. Clean, semantic, SEO-friendly. πŸ“ Routing Basics // Program.cs var app = builder.Build(); // Basic routing app.MapGet(“/”, () => “Hello World!”); app.MapGet(“/users”, () => new[] { new { Id = 1, Name = “Alice” } }); app.MapGet(“/users/{id:int}”, (int id) => new { Id = […]

Read More
Git

Git: Use Reset to Undo Local Changes

- 12.07.26 - ErcanOPAK comment on Git: Use Reset to Undo Local Changes

↩️ Git Reset = Undo Local Changes Made a mistake? Git reset undoes local changes. Soft, mixed, hard β€” choose wisely. πŸ“ Reset Types # Soft Reset git reset –soft HEAD~1 # Moves HEAD back # Changes stay in staging # Mixed Reset (default) git reset –mixed HEAD~1 git reset HEAD~1 # Moves HEAD back […]

Read More
Ajax

Ajax: Use Axios for HTTP Requests

- 12.07.26 - ErcanOPAK comment on Ajax: Use Axios for HTTP Requests

πŸ“‘ Axios = HTTP Client Fetch is basic. Axios is feature-rich. Interceptors, error handling, automatic JSON. πŸ“ Axios Setup # Install npm install axios # Basic GET import axios from ‘axios’; axios.get(‘https://api.example.com/data’) .then(response => console.log(response.data)) .catch(error => console.error(error)); # POST axios.post(‘https://api.example.com/data’, { name: ‘Alice’, email: ‘alice@example.com’ }) .then(response => console.log(response.data)) .catch(error => console.error(error)); # Async/Await […]

Read More
JavaScript

JavaScript: Understand Hoisting

- 12.07.26 - ErcanOPAK comment on JavaScript: Understand Hoisting

πŸ“€ Hoisting = Declaration Lifting Variables behave strangely. Hoisting explains it. Declarations lifted, assignments stay. πŸ“ Hoisting Examples // var hoisting console.log(x); // undefined (not error) var x = 5; // Equivalent to: var x; console.log(x); // undefined x = 5; // function hoisting sayHello(); // “Hello” function sayHello() { console.log(‘Hello’); } // function expression […]

Read More
HTML

HTML: Use Web Storage for Client-Side Data

- 12.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. πŸ“ 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 = { name: ‘Alice’, age: […]

Read More
CSS

CSS: Use Filter Effects for Visual Magic

- 12.07.26 - ErcanOPAK comment on CSS: Use Filter Effects for Visual Magic

🎨 Filter Effects = Visual Magic Images need effects. CSS filters apply visual effects. Blur, brightness, contrast β€” no Photoshop needed. πŸ“ Filter Functions /* Blur */ filter: blur(5px); filter: blur(2px); /* Brightness */ filter: brightness(0.8); filter: brightness(1.2); filter: brightness(200%); /* Contrast */ filter: contrast(1.5); filter: contrast(200%); /* Grayscale */ filter: grayscale(100%); filter: grayscale(0.5); /* […]

Read More
Windows

Windows 11: Unlock God Mode for All Settings

- 12.07.26 - ErcanOPAK comment on Windows 11: Unlock God Mode for All Settings

πŸ‘‘ God Mode = All Settings Settings are scattered. God Mode brings them all together. One folder, all controls. πŸ“ Enable God Mode # Create God Mode Folder 1. Right-click on Desktop 2. New β†’ Folder 3. Name the folder: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C} # Access God Mode – Double-click folder – See all settings # What’s Inside […]

Read More
AI

AI Prompt: Generate Content Calendar

- 12.07.26 - ErcanOPAK comment on AI Prompt: Generate Content Calendar

πŸ“… AI Content Calendar Content planning is hard. AI generates content calendars β€” topics, formats, channels. Plan ahead. πŸ“ The Prompt Generate a 30-day content calendar for: Business: [Your business] Industry: [Your industry] Target Audience: [Who are they?] Content Types: [Blog, video, social, email] Provide: 1. Weekly Themes 2. Content Ideas (30 items) – Blog […]

Read More
Docker

Docker: Follow Dockerfile Best Practices

- 12.07.26 - ErcanOPAK comment on Docker: Follow Dockerfile Best Practices

πŸ“¦ Dockerfile Best Practices Dockerfiles can be optimized. Best practices create efficient images. Smaller, faster, secure. ❌ Unoptimized FROM ubuntu:latest RUN apt-get update RUN apt-get install -y python3 RUN apt-get install -y python3-pip COPY . . RUN pip install -r requirements.txt CMD python3 app.py βœ… Optimized FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip […]

Read More
Kubernetes

Kubernetes: Use ConfigMaps for Configuration

- 12.07.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps for Configuration

βš™οΈ ConfigMaps = Configuration Hardcoding config is bad. ConfigMaps externalize configuration. Change settings without rebuilding. πŸ“ Creating ConfigMaps # From literal values kubectl create configmap app-config \ –from-literal=env=production \ –from-literal=log-level=debug \ –from-literal=api-url=https://api.example.com # From file kubectl create configmap app-config \ –from-file=./configs/app.properties \ –from-file=./configs/log4j.properties # From YAML apiVersion: v1 kind: ConfigMap metadata: name: app-config data: env: […]

Read More
Wordpress

WordPress: Essential Security Tips to Protect Your Site

- 12.07.26 - ErcanOPAK comment on WordPress: Essential Security Tips to Protect Your Site

πŸ›‘οΈ WordPress Security = Protect Your Site WordPress sites are targeted. Security tips protect your site. Updates, passwords, backups. πŸ“ Essential Security # 1. Keep Everything Updated – WordPress core – Themes – Plugins – PHP version # 2. Strong Passwords – Use password manager – 16+ characters – Unique per site # 3. Two-Factor […]

Read More
Photoshop

Photoshop: Optimize Export Settings for Web

- 12.07.26 - ErcanOPAK comment on Photoshop: Optimize Export Settings for Web

πŸ“€ Export Settings = Web Optimization Large images slow websites. Export settings optimize images. Quality, size, format β€” perfect. πŸ“ Export Options # Save for Web File β†’ Export β†’ Save for Web (Alt+Shift+Ctrl+S) # JPEG Settings – Quality: 70-80% (good) – Optimized: Yes – Progressive: Yes – Embedded: None # PNG Settings – PNG-24 […]

Read More
Visual Studio

Visual Studio: Master IntelliSense for Faster Coding

- 12.07.26 - ErcanOPAK comment on Visual Studio: Master IntelliSense for Faster Coding

πŸ’‘ IntelliSense = Code Suggestions Typing code is slow. IntelliSense suggests code. Methods, properties, parameters β€” auto-complete. ⌨️ IntelliSense Shortcuts Ctrl + Space β†’ Open IntelliSense Ctrl + Shift + Space β†’ Show parameter info Ctrl + J β†’ Quick info (hover) Ctrl + Alt + Space β†’ Complete word # IntelliSense Features – Member […]

Read More
C#

C#: Use Extension Methods to Add Functionality

- 12.07.26 - ErcanOPAK comment on C#: Use Extension Methods to Add Functionality

πŸ”Œ Extension Methods = Add Functionality Can’t modify existing types? Extension methods add functionality. Use like instance methods. ❌ Static Methods string email = “USER@EXAMPLE.com”; email = StringHelper.ToTitleCase(email); βœ… Extension Method string email = “USER@EXAMPLE.com”; email = email.ToTitleCase(); πŸ“ Extension Examples // Static class, static methods public static class StringExtensions { public static string ToTitleCase(this […]

Read More
C#

C#: Use Generics for Type-Safe Code

- 12.07.26 - ErcanOPAK comment on C#: Use Generics for Type-Safe Code

🧩 Generics = Type-Safe Code Object types are unsafe. Generics create type-safe reusable code. Performance, safety, flexibility. ❌ Object (Unsafe) public class Stack { private object[] items; public void Push(object item) { } public object Pop() { } } Stack s = new Stack(); s.Push(123); // Boxed int i = (int)s.Pop(); // Cast βœ… Generic […]

Read More
SQL

SQL: Use Views to Simplify Complex Queries

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

πŸ“Š Views = Virtual Tables Complex queries repeated everywhere. Views simplify them. Create once, query 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: Manage Configuration with appsettings

- 12.07.26 - ErcanOPAK comment on .NET Core: Manage Configuration with appsettings

βš™οΈ Configuration = appsettings Hardcoding config is bad. appsettings externalizes configuration. JSON, environment, secrets. πŸ“ appsettings.json // appsettings.json { “Logging”: { “LogLevel”: { “Default”: “Information”, “Microsoft”: “Warning” } }, “AllowedHosts”: “*”, “ConnectionStrings”: { “DefaultConnection”: “Server=localhost;Database=MyDb;User=sa;Password=MyPass123;” }, “AppSettings”: { “ApiKey”: “abc-123-xyz”, “Timeout”: 30, “RetryCount”: 3, “EnableLogging”: true, “BaseUrl”: “https://api.example.com” } } // appsettings.Development.json (override) { “AppSettings”: […]

Read More
Git

Git: Use Bisect to Find Bugs with Binary Search

- 12.07.26 - ErcanOPAK comment on Git: Use Bisect to Find Bugs with Binary Search

πŸ” Git Bisect = Find Bugs Bug appeared but when? git bisect finds the exact commit. Binary search through history. πŸ“ Bisect Commands # Start bisect git bisect start # Mark current commit as bad git bisect bad # Mark known good commit git bisect good commit-hash # Or from specific commit git bisect bad […]

Read More
Ajax

Ajax: Use Fetch API for Modern HTTP Requests

- 12.07.26 - ErcanOPAK comment on Ajax: Use Fetch API for Modern HTTP Requests

🌐 Fetch API = Modern HTTP XMLHttpRequest is old. Fetch API is modern. Promise-based, cleaner, more powerful. ❌ XMLHttpRequest const xhr = new XMLHttpRequest(); xhr.open(‘GET’, ‘/api/users’); xhr.onload = function() { if (xhr.status === 200) { const data = JSON.parse(xhr.responseText); console.log(data); } }; xhr.send(); βœ… Fetch API fetch(‘/api/users’) .then(response => response.json()) .then(data => console.log(data)) .catch(error => […]

Read More
JavaScript

JavaScript: Master Promises for Async Operations

- 12.07.26 - ErcanOPAK comment on JavaScript: Master Promises for Async Operations

🀝 Promises = Async Operations Callback hell is ugly. Promises make async code elegant. Chain, catch, await β€” async made easy. ❌ Callback Hell getUser(function(user) { getOrders(user, function(orders) { getDetails(orders, function(details) { console.log(details); }); }); }); βœ… Promise Chain getUser() .then(user => getOrders(user)) .then(orders => getDetails(orders)) .then(details => console.log(details)) .catch(err => console.error(err)); πŸ“ Promise Methods […]

Read More
HTML

HTML: Use Picture Element for Responsive Images

- 12.07.26 - ErcanOPAK comment on HTML: Use Picture Element for Responsive Images

πŸ–ΌοΈ Picture Element = Responsive Images Images need to be responsive. Picture element delivers different images for different screens. πŸ“ Picture Basics <picture> <source media=”(max-width: 480px)” srcset=”image-mobile.jpg”> <source media=”(max-width: 768px)” srcset=”image-tablet.jpg”> <source media=”(min-width: 769px)” srcset=”image-desktop.jpg”> <img src=”image-default.jpg” alt=”Description”> </picture> <!– Different formats (WebP fallback) –> <picture> <source type=”image/webp” srcset=”image.webp”> <source type=”image/avif” srcset=”image.avif”> <img src=”image.jpg” alt=”Description”> […]

Read More
CSS

CSS: Master Gradients for Color Transitions

- 12.07.26 - ErcanOPAK comment on CSS: Master Gradients for Color Transitions

🌈 Gradients = Color Transitions Solid colors are basic. Gradients create smooth transitions. Modern, vibrant, professional. πŸ“ Gradient Types /* Linear Gradient */ background: linear-gradient(to right, red, blue); background: linear-gradient(45deg, red, blue); background: linear-gradient(to bottom, red, yellow, green); /* Radial Gradient */ background: radial-gradient(circle, red, blue); background: radial-gradient(ellipse, red, blue); background: radial-gradient(circle at 50% 50%, […]

Read More
Windows

Windows 11: Master File Explorer Advanced Features

- 12.07.26 - ErcanOPAK comment on Windows 11: Master File Explorer Advanced Features

πŸ“‚ File Explorer = Advanced Features File Explorer is more than folders. Advanced features boost productivity. Quick Access, Search, Navigation. πŸ“ Quick Access # Pin to Quick Access – Right-click folder β†’ Pin to Quick Access – Unpin: Right-click β†’ Unpin # Quick Access Features – Frequent folders – Recent files – Pinned items # […]

Read More
AI

AI Prompt: Generate Marketing Strategy

- 12.07.26 - ErcanOPAK comment on AI Prompt: Generate Marketing Strategy

πŸ“Š AI Marketing Strategy Marketing needs strategy. AI generates marketing strategies β€” channels, messaging, goals. Grow your business. πŸ“ The Prompt Generate a marketing strategy for: Business: [Your business] Industry: [Your industry] Target Audience: [Who are they?] Goal: [e.g., increase sales, awareness] Budget: [Low/Medium/High] Provide: 1. Executive Summary 2. Market Analysis – Target audience – […]

Read More
Docker

Docker: Use Image Tags for Versioning

- 12.07.26 - ErcanOPAK comment on Docker: Use Image Tags for Versioning

🏷️ Image Tags = Versioning Images need versions. Image tags version your images. Latest, v1.0.0, SHA β€” track changes. πŸ“ Tag Commands # Tag an image docker tag myapp:latest myapp:v1.0.0 # Tag for registry docker tag myapp:latest username/myapp:v1.0.0 # Multiple tags docker tag myapp:latest myapp:latest docker tag myapp:latest myapp:v1.0.0 docker tag myapp:latest myapp:v1.0.0-production # View […]

Read More
Kubernetes

Kubernetes: Use Ingress Controllers for HTTP Routing

- 12.07.26 - ErcanOPAK comment on Kubernetes: Use Ingress Controllers for HTTP Routing

πŸšͺ Ingress = HTTP Routing NodePort and LoadBalancer are basic. Ingress provides advanced HTTP routing. Single entry point, multiple services. πŸ“ Ingress Basics # Install NGINX Ingress Controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml # Ingress Resource apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress spec: rules: – host: app.example.com http: paths: – path: / pathType: Prefix backend: […]

Read More
Wordpress

WordPress: Manage Multiple Sites with Multisite

- 12.07.26 - ErcanOPAK comment on WordPress: Manage Multiple Sites with Multisite

🌐 Multisite = Multiple Sites Running multiple WordPress sites is hard. Multisite manages them from one installation. πŸ“ Enable Multisite # wp-config.php /* Multisite */ define(‘WP_ALLOW_MULTISITE’, true); // After adding, go to Tools β†’ Network Setup // Add these lines (provided by setup) define(‘MULTISITE’, true); define(‘SUBDOMAIN_INSTALL’, false); define(‘DOMAIN_CURRENT_SITE’, ‘example.com’); define(‘PATH_CURRENT_SITE’, ‘/’); define(‘SITE_ID_CURRENT_SITE’, 1); define(‘BLOG_ID_CURRENT_SITE’, 1); […]

Read More
Page 1 of 97
1 2 3 4 5 6 … 97 Next Β»

Posts pagination

1 2 3 … 97 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 (857)
  • 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 (857)
  • 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