Notes on Miscellaneous stuff
- Via Settings UI: Go to File > Preferences > Settings (or press Ctrl+,), search for "Hover", and uncheck "Editor > Hover: Enabled".
- Quick Suggestions Delay: Search for editor.quickSuggestionsDelay and increase the value
- Hover Delay: Search for editor.hover.delay and increase it
- Press Escape to dismiss the current tooltip or suggestion box.
- Press Ctrl + Space again to toggle the details pane of a suggestion.
1 April 2026 Note: This is a Gemini provided summary of a chat I had with it today.
Technical Deep Dive: WebSockets vs. REST in the Real World
This discussion explored the conceptual and practical differences between traditional REST APIs and WebSockets, using a popular overview video as a starting point.
Core Resource
- Video: REST API (HTTP) vs Websockets - Concept Overview With Example
- Creator: Be A Better Dev
- Key Insight: The video defines WebSockets as Full-Duplex (simultaneous two-way communication) compared to the Request-Response model of REST, where the server cannot "speak" until spoken to by the client.
Key Discussion Points
- The "Listener" Concept: We identified that while the video focuses on a binary choice, there is a middle ground. Technologies like Server-Sent Events (SSE) allow an app to register a "listener" to receive server updates without the full complexity of a two-way WebSocket.
- 4G Jitter & Stability: A critical part of the conversation focused on why stateful WebSockets can be "brittle" on 4G connections. Because WebSockets maintain a persistent "pipe," network jitter (timing variations) can snap the connection, requiring complex re-handshaking logic.
- The WhatsApp vs. Gemini Live Paradox: *WhatsApp succeeds on rural 4G because it uses highly optimized, lightweight protocols (like MQTT) over its connection, designed to silently reconnect and buffer small text packets.
- Gemini Live often struggles or fails on the same connection because it streams heavy, high-frequency multimodal data (audio/video). This requires near-zero latency; when jitter occurs, the stream breaks because it cannot "wait" to catch up like a text message can.
- Duplex Terminology: We clarified that while WebSockets are Full-Duplex, REST is best described as Request-Response. REST isn't strictly "half-duplex" (like a walkie-talkie), but it is restricted by the rule that the client must always initiate the conversation.
Summary Table
| Feature | REST API | WebSockets |
|---|---|---|
| Model | Request-Response | Full-Duplex (Two-way) |
| State | Stateless (Each request is new) | Stateful (Continuous connection) |
| 4G Performance | Resilient but "Laggy" | Fast but sensitive to Jitter |
| Best For | Standard data fetching | Real-time Chat, Gaming, Streaming |
Workaround for Replace During File Copy in Win 11 Being Destructive
The Core Issue
- Choosing "Replace" during a file copy or move operation in Windows 11 is a destructive action.
- The original file in the destination is overwritten directly and is not sent to the Recycle Bin.
- A "brain fade" or a physical mouse slip (dragging an older file onto a newer one) results in the immediate and permanent loss of the updated version.
The Proposed Workaround
- Step 1: Using Windows File Explorer, delete the file in the destination folder first. This ensures it is safely stored in the Recycle Bin.
- Step 2: Copy or move the source file into the now-empty destination.
- Safety Net: If the wrong file is deleted or the copy direction is reversed, the deleted file remains fully recoverable from the Recycle Bin.
Superiority Over the "Compare Info" Dialog
- Reduced Cognitive Load: The "Compare info" dialog of "Replace or Skip Files" confirmation dialog is visually dense and requires the user to analyze timestamps and file sizes under pressure.
- Fault Tolerance: Users often suffer from "dialog fatigue" and may click "Replace" on autopilot. The manual deletion method replaces complex decision-making with a simple, fail-safe mechanical habit.
Superiority Over PowerShell or Automation
- Zero Friction: A PowerShell script requires either opening a terminal or performing complex Registry edits to integrate with the Windows Explorer context menu.
- Ad-Hoc Efficiency: For spontaneous, one-off file management, the "Delete then Copy" method is faster and requires no technical setup, keeping the workflow entirely within the native user interface.
Resolving the "Device is being used" Error During USB SSD Ejection
The Issue: Following a large file transfer or backup operation, Windows may refuse to unmount the USB SSD using the "Safely Remove Hardware" feature, displaying a "device is being used" error. This is typically caused by background system services, such as Windows Defender, scanning the newly written data.
The Solution: Do not forcefully unplug the drive while the system is running. Instead, follow these steps:
- Close any open terminal windows or file explorers.
- Initiate a standard Windows Shut down.
- Wait for the computer to completely power off.
- Safely unplug the USB SSD.
Why Shutdown Guarantees Data Safety: A full system shutdown is entirely safe and ensures no data corruption occurs, even if write caching is enabled. During the shutdown sequence, the Windows operating system performs the following actions:
- Forces Cache Flushing: Windows explicitly commands all connected storage controllers to flush their write caches.
- Delays Power-Off: The operating system actively halts the final power-down until it receives confirmation from the USB SSD that all pending data in the cache has been successfully committed to the physical flash memory.
- Terminates Locks: Shutting down terminates all background services and security scans that were holding an active lock on the drive.
Therefore, once the machine is fully powered off, it is guaranteed that all data has been written and the drive is perfectly safe to physically disconnect.
Understanding Windows Defender Drive Locking and File Systems
The File Hash Cache and Interrupted Scans Windows Defender utilizes a File Hash Cache to optimize scanning speeds. When a new file is encountered, the anti-virus engine calculates a unique mathematical hash of that file's contents, scans it for threats, and records the hash in its internal database as "safe."
If a bulk copy operation (e.g., 10,000 files) is performed and the system is subsequently shut down to release the drive lock, Windows Defender may have only had time to hash and verify a fraction of those files (e.g., 2,000). When that USB drive is mounted again at a later date, Defender recognizes that 8,000 files are still unverified. Even if no new write operations are initiated by the user, Defender will immediately resume scanning the remaining files in the background. This background process will lock the drive and prevent a clean ejection until the engine has successfully hashed the remaining 8,000 items.
File System Impact: NTFS vs. exFAT The speed at which Windows Defender identifies which files are "old" and which are "new" depends entirely on the drive's file system format.
- NTFS (Standard Hard Drives, e.g., WD My Passport): NTFS is a journaled file system. By default, WD My Passport drives are pre-formatted as NTFS, making them ready to use immediately for Windows 10/11. This file system maintains a hidden database called the Update Sequence Number (USN) Journal, which keeps a strict, instant ledger of every single modification made to the drive. When an NTFS drive is connected, Windows Defender queries the USN Journal directly. The journal immediately reports exactly which files have been added or changed since the last connection. Defender skips the old files entirely and only scans the new ones, resulting in a very rapid lock-release.
- exFAT / FAT32 (Standard USB Flash Drives and External SSDs): These file systems lack a USN Journal. When an exFAT drive is connected, Windows has no centralized ledger to query. To determine what is new, Windows Defender must manually traverse the entire directory tree, checking the file headers and timestamps of every single file against its cache. For a drive containing hundreds of thousands of files, this enumeration process requires significant USB bandwidth and time, causing the drive to remain locked for 10 to 20 minutes just to determine that nothing has changed.
Windows Search Indexing and Drive Locking
The Search Indexer Lock
In addition to anti-virus software, the Windows Search Indexer (SearchIndexer.exe) is another primary background process that can prevent a USB drive from cleanly unmounting. When a drive is connected or a large volume of new files is copied to it, the indexer automatically crawls the directory tree to catalog text and metadata for faster Start Menu and File Explorer searches. While this crawling process occurs, the indexer holds an active lock on the drive, resulting in a "device is being used" error upon attempted ejection.
Global vs. Drive-Specific Indexing
For systems where Windows Search Indexing has been entirely disabled at the operating system level (e.g., via the services.msc console), this specific locking mechanism is not an issue, and the indexer will not interfere with drive removal.
However, if the global indexing service remains active, it can be disabled for a specific USB drive to prevent future locking. This ensures the backup destination is ignored by the indexer without affecting the search performance of the main operating system drive.
How to Disable Indexing for a Specific Drive:
- Open Windows File Explorer and navigate to This PC.
- Right-click the target USB drive and select Properties.
- At the bottom of the General tab, clear the checkbox labeled: "Allow files on this drive to have contents indexed in addition to file properties."
- Click Apply.
- When prompted, select the option to apply the changes to the drive, subfolders, and files, and click OK. (This process may take a few moments depending on the number of files currently on the drive).
Comments
Post a Comment