Saturday, January 02, 2021

Abridged guide to using highlight.js for syntax-highlighting in Blogger

Using highlight.js. I am highlighting XML & Java code snippets, so the "base" version will suffice.

Setup

At Blogger, go to Theme, then select the dropdown on right of "Customise" button > Edit HTML.

Using HTML view, paste the code below under "head" tag:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/default.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

Save the template.

Usage - Java

Just wrap content in "pre" tags with:

<code class="java">...........</code>

Usage - XML

Just wrap content in "pre" tags with:

<code class="xml">...........</code>

But, your XML content needs to be escaped (Free Online XML Escape / Unescape Tool - FreeFormatter.com).

References

Friday, January 01, 2021

Windows 10 - Reinstalling Hardware Drivers with DevCon

Tested on Windows 10 64-bit.

Manual/UI Way
Go to Device Manager, locate the faulty entry (mine is a Bluetooth-WIFI card) and right-click & select "Uninstall driver". Then "Scan for hardware changes" (Menu: Action).

Semi-manual/command-prompt way
  1. Download & install Windows Drivers Kit (WDK) [direct link]. Ignore "warning" as you just need to use the DevCon.exe tool.
  2. Locate devcon.exe. Usually in this path (by default): C:\Program Files (x86)\Windows Kits\10\Tools\x64
  3. Optional: Add the path into environment variable PATH.
  4. Run "Command Prompt" as an administrative user.
  5. Locate the "troublesome" hardware:
    • At the prompt: devcon hwids * > c:\Windows\Temp\hwids.txt
    • This will dump the hardware list to the hwids.txt file. Open with Notepad(++).
    • Locate the hardware entry. E.g.
      • USB\VID_13D3&PID_3501\5&343F8C61&0&1
        •     Name: Qualcomm Atheros Bluetooth 4.1
          •     Hardware IDs:
            •         USB\VID_13D3&PID_3501&REV_0001
              •         USB\VID_13D3&PID_3501
                •     Compatible IDs:
                  •         USB\Class_E0&SubClass_01&Prot_01
                    •         USB\Class_E0&SubClass_01
                      •         USB\Class_E0
                    • Pick a string that's unique to the hardware entry. E.g. "VID_13D3"
                    • Run this command to make sure the results only return the hardware entry: devcon hwids *VID_13D3*
                    • Example output:
                      • C:\WINDOWS\system32>devcon hwids *VID_13D3*
                      • USB\VID_13D3&PID_3501\5&343F8C61&0&1
                      •     Name: Qualcomm Atheros Bluetooth 4.1
                      •     Hardware IDs:
                      •         USB\VID_13D3&PID_3501&REV_0001
                      •         USB\VID_13D3&PID_3501
                      •     Compatible IDs:
                      •         USB\Class_E0&SubClass_01&Prot_01
                      •         USB\Class_E0&SubClass_01
                      •         USB\Class_E0
                      • 1 matching device(s) found.
                  • Confidence high, now you can run the 2 commands below sequentially to 'reinstall' the hardware driver:
                    • Remove hardware entry: devcon remove *VID_13D3*
                    • Rescan for hardware changes: devcon rescan
                  You can then add the 2 commands into a BAT file for faster execution.

                  References: