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

AI

AI Prompt: Refactor Legacy Code with Explanations

- 19.03.26 - ErcanOPAK comment on AI Prompt: Refactor Legacy Code with Explanations

โ™ป๏ธ Modernize Old Code Inherited 10-year-old codebase? AI refactors + teaches you why. Refactor this legacy code: [Paste old code] Target: – Language: [Current language + latest version] – Patterns: Modern best practices – Performance: Optimize bottlenecks – Readability: Clear naming, comments For each change explain: 1. What was wrong with old approach 2. Why […]

Read More
AI

AI Prompt: Convert Screenshots to Working Code

- 19.03.26 - ErcanOPAK comment on AI Prompt: Convert Screenshots to Working Code

๐Ÿ“ธ Design to Code in Seconds Designer sends mockup. You convert to code. Takes 2 hours. Or… 30 seconds with AI. [Upload screenshot of UI mockup] Convert this design to code: Framework: React + Tailwind CSS Requirements: – Responsive (mobile-first) – Accessible (ARIA labels) – Production-ready (no placeholders) – Match colors, spacing, typography exactly – […]

Read More
AI

AI Prompt: Generate SQL Queries from Natural Language

- 19.03.26 - ErcanOPAK comment on AI Prompt: Generate SQL Queries from Natural Language

๐Ÿ—ƒ๏ธ Text to SQL Non-technical users need data. Train AI on your schema, get perfect queries. You are a SQL expert. Here’s my database schema: Tables: – Users (id, name, email, created_at) – Orders (id, user_id, total, status, created_at) – Products (id, name, price) Convert this request to SQL: “Show me top 10 customers by […]

Read More
Docker

Docker: Use –rm Flag to Auto-Delete Stopped Containers

- 19.03.26 - ErcanOPAK comment on Docker: Use –rm Flag to Auto-Delete Stopped Containers

๐Ÿงน Self-Cleaning Containers 500 stopped containers eating disk space? One flag prevents this. # Auto-delete after stop docker run –rm -it ubuntu bash # Without –rm (default) docker run -it ubuntu bash # Container stays after exit (uses disk space) # Clean existing stopped containers docker container prune -f When to Use –rm: Testing, one-off […]

Read More
Kubernetes

Kubernetes: Use kubectl logs –tail=100 -f to Debug Faster

- 19.03.26 - ErcanOPAK comment on Kubernetes: Use kubectl logs –tail=100 -f to Debug Faster

๐Ÿ” Log Debugging Shortcut Scrolling through 10,000 log lines? See only what matters. # Last 100 lines, follow mode (like tail -f) kubectl logs my-pod –tail=100 -f # From specific container in multi-container pod kubectl logs my-pod -c sidecar –tail=50 -f # Previous crashed pod kubectl logs my-pod –previous # All pods with label kubectl […]

Read More
Wordpress

WordPress: Disable REST API to Block 90% of Attack Vectors

- 19.03.26 - ErcanOPAK comment on WordPress: Disable REST API to Block 90% of Attack Vectors

๐Ÿ”’ Close the Security Hole Most WordPress hacks exploit REST API endpoints. Don’t need headless? Disable it. // Disable REST API for non-logged users add_filter(‘rest_authentication_errors’, function($result) { if (!is_user_logged_in()) { return new WP_Error( ‘rest_disabled’, ‘REST API disabled’, array(‘status’ => 401) ); } return $result; }); What This Blocks: Automated user enumeration, content scraping, brute force […]

Read More
Wordpress

WordPress: Use WP-CLI to Manage 100 Sites in 10 Minutes

- 19.03.26 - ErcanOPAK comment on WordPress: Use WP-CLI to Manage 100 Sites in 10 Minutes

โšก Command Line Superpower Updating plugins via admin? 2 minutes per site ร— 100 sites = 3+ hours. WP-CLI? 10 minutes total. # Update all plugins on all sites wp plugin update –all # Search & replace URLs after migration wp search-replace ‘oldsite.com’ ‘newsite.com’ # Create users in bulk wp user create john john@example.com –role=editor […]

Read More
Photoshop

Photoshop Match Color: Copy Color Grading Between Photos Instantly

- 19.03.26 - ErcanOPAK comment on Photoshop Match Color: Copy Color Grading Between Photos Instantly

๐ŸŽจ Color Grading Shortcut Spent 2 hours grading one photo? Copy that exact look to 100 photos in 10 seconds each. How: Image โ†’ Adjustments โ†’ Match Color Source: Select your reference photo (the one with perfect color) Options: Luminance (brightness match), Color Intensity (saturation), Fade (blend strength) Workflow: Grade one hero image perfectly โ†’ […]

Read More
Photoshop

Photoshop Object Selection: The 1-Click Background Removal That Actually Works

- 19.03.26 - ErcanOPAK comment on Photoshop Object Selection: The 1-Click Background Removal That Actually Works

โœจ AI Selection Magic Remove.bg costs $9/month. Photoshop’s Object Selection tool? Free. Better. Faster. Use: Select โ†’ Object Selection Tool (W) How: Click object once. AI detects edges automatically. Done in 2 seconds. For Hair: After selection โ†’ Select and Mask โ†’ Refine Edge Brush on hair. Detects individual strands. The Trick: Mode: Rectangle or […]

Read More
Visual Studio

Visual Studio: The IntelliCode Secret That Writes 40% of Your Code

- 19.03.26 - ErcanOPAK comment on Visual Studio: The IntelliCode Secret That Writes 40% of Your Code

๐Ÿค– AI-Powered Autocomplete IntelliCode learns from 500,000+ GitHub repos. Predicts your next line before you type it. Free. Built-in. Underused. Enable: Tools โ†’ Options โ†’ IntelliCode โ†’ Turn on What It Does: Shows โญ starred suggestions at top of autocomplete. These are statistically what developers write next in this context. // You type: var users […]

Read More
C#

C#: Saving Memory with yield return (Lazy Streams)

- 01.03.26 - ErcanOPAK comment on C#: Saving Memory with yield return (Lazy Streams)

Don’t return a List<T> if you only need to iterate over it. Use yield return. This generates the next item only when the caller asks for it, meaning you can process 1 billion records without ever running out of RAM. It’s the magic behind LINQ.

Read More
C#

C#: Why Records are Better Than Classes for Data DTOs

- 01.03.26 - ErcanOPAK comment on C#: Why Records are Better Than Classes for Data DTOs

Tired of writing GetHashCode, Equals, and ToString for your data objects? Use record. public record User(int Id, string Name); var u1 = new User(1, “Ercan”); var u2 = u1 with { Name = “Opak” }; // Immutable transformation! It’s concise, thread-safe, and built specifically for modern data-driven applications.

Read More
C#

C#: Creating Strings Without Memory Pressure with String.Create

- 01.03.26 - ErcanOPAK comment on C#: Creating Strings Without Memory Pressure with String.Create

๐Ÿš€ High Performance C# Standard string concatenation creates too many temporary objects. String.Create allows you to write directly into the string’s buffer. This is a Senior-only optimization for code that runs millions of times per second (like logging frameworks or high-speed serializers).

Read More
SQL

SQL: Protecting Sensitive Data with Dynamic Data Masking

- 01.03.26 - ErcanOPAK comment on SQL: Protecting Sensitive Data with Dynamic Data Masking

Don’t let developers see customer credit card numbers. Mask them at the database level. ALTER TABLE Users ALTER COLUMN Email ADD MASKED WITH (FUNCTION = ’email()’); The data remains intact in the DB, but users without special permissions only see uXXX@XXXX.com. Essential for GDPR compliance.

Read More
SQL

SQL: Writing Readable Queries with Common Table Expressions (CTE)

- 01.03.26 - ErcanOPAK comment on SQL: Writing Readable Queries with Common Table Expressions (CTE)

Stop nesting subqueries. It makes SQL unreadable. Use WITH. WITH MonthlySales AS ( SELECT Month, SUM(Amount) as Total FROM Sales GROUP BY Month ) SELECT * FROM MonthlySales WHERE Total > 10000; It reads like a story from top to bottom, making it much easier for your team to maintain.

Read More
Asp.Net Core

.NET Core: Handling Errors Gracefully with Middleware

- 01.03.26 - ErcanOPAK comment on .NET Core: Handling Errors Gracefully with Middleware

Stop using try-catch in every Controller action. It’s messy. Use a Global Exception Middleware. app.UseExceptionHandler(exceptionHandlerApp => { exceptionHandlerApp.Run(async context => { // Log the error and return a professional JSON response }); }); This keeps your code dry and ensures your users never see a ‘Yellow Screen of Death’.

Read More
Asp.Net Core

.NET Core: Mastering Service Lifetimes (A Visual Guide)

- 01.03.26 - ErcanOPAK comment on .NET Core: Mastering Service Lifetimes (A Visual Guide)

๐Ÿ”น Transient: New instance every time. ๐Ÿ”น Scoped: One instance per HTTP request. ๐Ÿ”น Singleton: One instance for the entire app life. Using a Scoped service inside a Singleton will cause major memory leaks! Always double-check your DI graph.

Read More
Git

Git: Surgical Stashing – Don’t Save Everything!

- 01.03.26 - ErcanOPAK comment on Git: Surgical Stashing – Don’t Save Everything!

Sometimes you only want to temporarily hide one file, not your whole workspace. Use git stash push. git stash push -m “temporary fix” path/to/file.js This keeps your other experimental changes active while you fix a bug in a specific file. Total workflow control.

Read More
Git

Git: Writing Commits That Your Future Self Won’t Hate

- 01.03.26 - ErcanOPAK comment on Git: Writing Commits That Your Future Self Won’t Hate

# Bad: fix bug # Good: feat(auth): add password strength validation Follow the Conventional Commits standard. It makes your history searchable and allows for automated changelog generation.

Read More
Ajax

Ajax: Improving Perceived Speed with Skeleton Screens

- 01.03.26 - ErcanOPAK comment on Ajax: Improving Perceived Speed with Skeleton Screens

Users hate spinners. They love Skeleton Screens. It gives the illusion that the content is already there. The Strategy: While your Ajax request is pending, show a gray box that matches the shape of your final content. This reduces ‘bounce rates’ significantly.

Read More
JavaScript

JavaScript: Mastering Array.from() for Functional UI

- 01.03.26 - ErcanOPAK comment on JavaScript: Mastering Array.from() for Functional UI

Converting a NodeList or a set of data into a UI list? Stop using forEach and start using the mapping feature of Array.from. const listItems = Array.from({ length: 5 }, (v, i) => `Item ${i + 1}`); // Output: [‘Item 1’, ‘Item 2’, ‘Item 3’, ‘Item 4’, ‘Item 5’] This allows you to generate data […]

Read More
HTML

HTML5: Creating Modern FAQ Accordions Without JavaScript

- 01.03.26 - ErcanOPAK comment on HTML5: Creating Modern FAQ Accordions Without JavaScript

๐Ÿš€ Lightweight UI Don’t load heavy JS libraries for simple accordions. Use the native <details> element. Is this SEO Friendly? Yes! Google crawls content inside details tags even when they are closed. It’s clean, accessible, and works on every browser perfectly.

Read More
CSS

CSS: Creating the Ultimate Glassmorphism Look (Modern UI)

- 01.03.26 - ErcanOPAK comment on CSS: Creating the Ultimate Glassmorphism Look (Modern UI)

The ‘Frosted Glass’ effect is everywhere in iOS and Windows. Here is the code to do it right. .glass-panel { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 15px; box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); } Note: backdrop-filter is the magic property that blurs everything […]

Read More
Windows

Windows 11: Instant Multitasking with Snap Layouts

- 01.03.26 - ErcanOPAK comment on Windows 11: Instant Multitasking with Snap Layouts

Manually resizing windows is for the past. Hover over any window’s ‘Maximize’ button to see Snap Layouts. Choose a 3-column split or a 2×2 grid. Windows will remember this ‘Snap Group’, allowing you to switch between apps and your layout instantly from the taskbar.

Read More
Windows

Windows 11: Keeping Your PC Awake with Microsoft PowerToys

- 01.03.26 - ErcanOPAK comment on Windows 11: Keeping Your PC Awake with Microsoft PowerToys

Downloading a huge file or running a long script? Don’t let Windows go to sleep. The Utility: PowerToys Awake. How: Right-click the coffee mug icon in your tray. Select ‘Keep awake indefinitely’. No need to change your complex Power & Sleep settings. One click to stay on, one click to return to normal.

Read More
AI

AI Prompt: The Zero-Waste Personalized Chef

- 01.03.26 - ErcanOPAK comment on AI Prompt: The Zero-Waste Personalized Chef

Stop wasting money on groceries. Let AI plan your week based on what’s already in your fridge. The Prompt: “I have these ingredients: [List them]. I want [3] meals. I have a [Type – e.g. Air Fryer/Slow Cooker]. I am [Diet – e.g. Low Carb]. Create a recipe for each, including prep time and macros. […]

Read More
AI

AI Prompt: Transforming Your Resume for ATS Mastery

- 01.03.26 - ErcanOPAK comment on AI Prompt: Transforming Your Resume for ATS Mastery

Applicant Tracking Systems (ATS) reject 70% of resumes before a human sees them. Fix yours now. “Act as a Senior HR Manager. I am applying for [Job Title]. Here is the Job Description: [Paste JD]. Here is my Resume: [Paste Resume]. Rewrite my experience section using the ‘Google XYZ Formula’ (Accomplished [X] as measured by […]

Read More
AI

AI Prompt: The ‘Ultimate Problem Solver’ Framework

- 01.03.26 - ErcanOPAK comment on AI Prompt: The ‘Ultimate Problem Solver’ Framework

๐ŸŽฏ The Power Prompt “I have [Problem]. Act as a world-class consultant. 1. Ask me 5 clarifying questions to define the root cause. 2. Once answered, provide 3 solutions: The Quick Fix, The Scalable Fix, and The Extreme Fix. 3. Tell me which one you’d choose and why.” This prompt forces AI to think before […]

Read More
Docker

Docker: Why OrbStack is the New King of Local Containers

- 01.03.26 - ErcanOPAK comment on Docker: Why OrbStack is the New King of Local Containers

Docker Desktop is heavy and slow on Mac/Windows. Enter OrbStack: a lightning-fast alternative. Why switch? ๐Ÿš€ 2x faster network performance. ๐Ÿ”‹ Uses 80% less CPU during idle. โšก Starts in under 2 seconds. It’s 100% compatible with the docker CLI but optimized for the modern developer’s machine.

Read More
Kubernetes

Kubernetes: Managing Clusters Visually with Lens IDE

- 01.03.26 - ErcanOPAK comment on Kubernetes: Managing Clusters Visually with Lens IDE

The terminal is great, but visualizing 100+ pods is hard. Lens is the ‘World’s Most Powerful Kubernetes IDE’. Real-time stats of CPU/RAM for every container. One-click access to Pod logs and Shell. Stop typing kubectl get pods every 5 seconds. Use Lens to see the health of your infrastructure at a glance.

Read More
Page 5 of 69
ยซ Previous 1 2 3 4 5 6 7 8 9 10 … 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