Map CAPS Lock to Control Key in Windows

Windows version: 10

If you use the control keys a lot for keyboard shortcuts, it makes sense to have the control key where the caps lock key is. Why? Because while the fingers are resting in the home position (ASDF row), you have the pinky finger under the “A” key and right beside it will be the “Control” key. It’s easy on the pinky and ergonomic.

The early keyboards used to have the Control Key beside A: http://xahlee.info/kbd/keyboard_ctrl_vs_capslock_position.html

Here are three ways I recommend (I prefer the registry edit):

Both Power Toys and Ctrl2Cap are fine in my opinion as both are officially listed on the Microsoft sites.

However I like the registry edit solution better as there is no software to install and it’s just a single line of edit. I used to be scared editing the Registry Editor but the procedure below is tested and safe. Just carefully type in the values (you won’t be able to copy/paste them).

1. Open the Registry Editor, you can hit the “Windows” key and start typing regedit and it will show you suggestions for opening the Registry Editor:

2. Navigate to the entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

3. Right-click “Keyboard Layout” and add a new “Binary Value” with name: Scancode Map

4. Type in the following values:

00 00 00 00 00 00 00 00 02 00 00 00 1d 00 3a 00 00 00 00 00

You can’t copy / paste them, so type them in carefully 😊

5. Click OK, close the Registry Editor and restart your computer. Your CAPS Lock key should now be mapped to the Controls Key.

Windows Firewall Rule for Go Web Development

If you do Go web development on Windows, then you are likely to come across the Windows Firewall – Security Alert whenever you build and run the Go app. For example, here I am trying to build and run a sample Go web server program “main1.exe” that wants to run on port 4000:

Windows Defender Firewall – Security Alert

This can be annoying when you create a lot of throw-away small apps for learning; you end up with hundreds of these “allow” rules in the Firewalls ruleset. Here’s a small glimpse of all the rules that got created running an experimental web program “multiple_handlers.exe”:

I am not sure if hundreds or even thousands of these junk rules slow up the system. To me they are junk for sure as I am not likely to run these again after the learning and testing is done. So my solution is to create a single inbound rule for port 4000 and always try to stick to the same port when developing web programs in Go. Here is how to do it in Windows:

1. Press the Windows key (start button) on your keyboard and start typing “firewall”, click the Windows Defender Firewall link as shown below:

2. Next click on “Advanced settings”

3. Then right-click on “Inbound Rules”, which will bring up a pop-up menu, then click “New Rule…”

4. Select “Port” then click Next

5. Type the port you want to allow. I choose 4000 for local development, so that’s what I specify and click Next.

6. Select “Allow the connection” and click Next

7. I work from home, so I choose “Private” only and click Next

8. Give the rule a friendly name, I gave it “4000 for local development” and click Finish

9. The rule should now be created and can be seen as below.

Now I can happily run my Go web programs on port 4000 and never receive a Windows firewall security alert ever again 😀

Turn Off Windows Sound Notification Banner

Operating System: Windows 10

In an earlier article I posted how to How to Disable Windows Volume Popup, but that required a small 300 KB program to be installed.

In my opinion the real-offensive element is actually the browser notification banner that gets attached to the media control popup. This is what I mean:

Both Chrome and Firefox notification banner attaches to this volume popup. Disable it like this:

Chrome

  1. In Chrome address bar, type chrome://flags/
  2. Then find the setting Hardware Media Key Handling and set it to Disabled.

Firefox

  1. In Firefox address bar, type about:config
  2. Then set media.hardwaremediakeys.enabled to false

Enjoy just the volume control bar without the ugly offensive banner!

Add Gitignore in Visual Studio

Objective: You have multiple Visual Studio projects (using the same technology stack) under a single git repository and you need to manually add a .gitignore file.

Instead of copy/pasting an existing .gitignore file, let Visual Studio generate it for you.

2 Steps to Add the .gitignore File via Visual Studio

  1. Inside Visual Studio, open your solution and click the tab “Team Explorer”
  2. Then click “Add” under Ignore & Attributes Files -> Ignore File
Steps to add .ignore file in the Team Explorer tab
After successfully adding the .gitignore file

This will add the .gitignore file in your root git repository folder. So you should not need to repeat the projects for other Visual Studio projects in the same folder (provided they are all using the same technology stack).

Dark Mode for Sumatra PDF

Windows: version 10
Sumatra PDF: version 3.2 64-bit

A dark mode for Sumatra PDF is really easy – you just need to tinker with 3 lines of code in the settings.

Why Use Sumatra PDF?

In my opinion, it’s the best PDF reader. It’s small in size, super-fast and doesn’t have any annoying cruft.

Why a Dark Mode (Night Mode)?

If you code for long periods of time, then it’s really great to have your code editor run in dark mode. This greatly reduces the strain on the eyes.

But let’s say you are also following along an e-book, maybe a PDF and you switch to Sumatra PDF. The default setting is black text on white background. Immediately your eyes are shocked with bright luminescent white light. It’s as if you were relaxing in a room with the lights switched off and suddenly someone walked in and abruptly turned the lights on.

As you are coding along you have to switch back and forth multiple times between your PDF reader and code editor. It can be really jarring for the eyes and nerves.

How to Enable Dark Mode?

In Sumatra PDF, click on the Menu -> Settings -> Advanced Options

This should open the SumatraPDF-settings.txt file in your text editor. Change the following 3 lines under the heading FixedPageUI:

TextColor = #eeeeee
BackgroundColor = #111111
GradientColors = #000000

TextColor changes the text color of the PDF document. Background color changes, well the background color of the PDF document. GradientColors will change the background window of Sumatra PDF.

MySQL Workbench 8.0 – Set the Default Time Zone

MySQL Workbench 8.0.19
MySQL Server 8.0.19

Summary

Here is a single screenshot summary of the actions you need to take in 6 labelled steps to change the time zone via MySQL workbench:

Detailed Steps

A detailed list of steps follow below.

Step 1 & 2

Either click from the main navigation menu -> Server -> Options File:

Or from the left navigation Administration tab -> Options File:

Step 3, 4 & 5

Then under General tab scroll down to the International field set, then locate the default-time-zone field, set it to your preferred zone:

Step 6

Then click on the Apply button:

You will get a confirmation box, hit the Apply button.

Directly Edit Config File my.ini

An alternative would be to directly edit the my.ini file and set the property:

default_time_zone = +8:00

In Windows 10, you can find the file here:

C:\ProgramData\MySQL\MySQL Server 8.0\my.ini

Set the JDK Path in GlassFish

GlassFish version: 5.1.0
Windows version: 10

Motivation

You may have several version of the JDK installed on your machine. By default you may be using JDK 11 or even 13, but GlassFish requires JDK 8.

Issue

Running asadmin generates the following error

Exception in thread “main” java.lang.NullPointerException
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:128)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:120)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:194)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:200)
at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:64)
at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:193)
at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:231)
at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:207)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:347)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:282)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:33)

Fix

Edit: ~\glassfish\config\asenv.bat
Assuming JDK 8 installation path is C:\Program Files\Java\jdk1.8.0_241

Add the line:

set AS_JAVA=C:\Program Files\Java\jdk1.8.0_241