Posts

Cleaning Up After Highlight.js: A Guide to Fixing Syntax Highlighting Issues

Image
I initially replaced Highlight.js with manual formatting for code snippets after revamping my Blogger site, aiming for more control. However, the process proved too time-consuming and unsustainable, so I returned to using Highlight.js for efficiency. Since blogging is a side activity, it's important that it fits easily into my daily routine as a programmer. In this post, I'll show you how I fix syntax highlighting issues that arise when using Highlight.js. I'll focus only on the browser version , since blogging platforms like Blogger often condense most of the theme's source code into a single file — making separation of concerns difficult. In this context, using a CDN to load and execute the script is the most practical approach. 1. Setup When I come up with an idea for a new post, I open Obsidian and create a new Markdown file. In the latter, I may include plenty of code snippets to illustrate the methods I want to explain to read...

WQL ASSOCIATORS OF Queries in PowerShell: From WMIC to CimCmdlets

The ASSOCIATORS OF statement in SQL for WMI (WQL) retrieves objects related to a specified source instance, where the source and related objects belong to different classes and are connected through an association class . For example, Win32_LogicalDiskToPartition is an association class that links Win32_DiskPartition and Win32_LogicalDisk . Using this association, you can list the disk partitions related to a specific logical disk (or vice versa). The object paths used to identify the source instances include the DeviceID property, which is intuitive and easy to understand. For instance, DeviceID values are in the form of C: for a logical disk or volume, or Disk #1, Partition #1 for a disk partition, making them more human-readable. In contrast, the Storage Management Provider (SMP) equivalent classes — MSFT_Partition , MSFT_Volume , and their association class MSFT_PartitionToVolume — do not expose user-friendly object path values. These ide...

Mutual Exclusion Techniques for Batch Scripts

In some situations, it's important to ensure that a Batch script runs only once at a time, in order to preserve the integrity of resources that cannot be shared or accessed concurrently. While implementing a mutex is straightforward in PowerShell or other .NET languages, the default Windows Shell does not provide an equally simple mechanism to prevent parallel execution of Batch scripts. In this post, I explore several workaround methods for identifying and managing a single running instance of a Batch script. 1. Using a Lock File One of the simplest techniques for achieving mutual exclusion in Batch scripts is the use of a lock file. When the script starts, it creates a specific file to signal that an instance is already running. Upon completion, the script deletes the lock file. If another instance of the script is launched while the lock file exists, it detects the file's presence and exits immediately, preventing parallel execution. Here's...