Monday, September 21, 2020

Setting VS Code to Edit Windows Batch Files

You will need to edit the Windows Registry to make this update so tread lightly.
  1. Launch the Registry Editor (regedit.exe)
  2. Navigate to the following branch: HKEY_CLASSES_ROOT\batfile\shell\edit\command
  3. Double-click the (default) value on the right. By default, VS Code is installed under C:\users\{YourUserName}\AppData\Local\Programs\Microsoft VS Code and the executable file is Code.exe. You will need to find the path to VS Code executable.
  4. Replace the existing data with the complete path of VS Code that you discovered in step 3. In my case it was: "C:\Users\{YourUserName}\AppData\Local\Programs\Microsoft VS Code\Code.exe" "%1"
  5. Note that in step 4 above to include the "%1"
  6. Exit the Registry Editor.


Sunday, September 20, 2020

A Fast vs Slow Thinking Example

A few years ago a ran across the book entitled Thinking, Fast and Slow by the 2002 Nobel Memorial Prize in Economic Science winner Daniel Kahneman. 

In short, we have two systems that drive the way we think. System 1 is fast, intuitive, and emotional; System 2 is slower, more deliberative, and more logical. While system 1 may serve us well in many circumstances, we must take the time to examine our fast, initial gut-level thinking and consider that it may be wrong. 

For an example of system 1 taking precedence over system 2, I got an email from an undergrad student concerned that his previous extra credit grades were not calculated correctly in his overall course grade. Here is the initial email:

---start email--- Hi Professor,

I just finished the coding assignments and I noticed that even though I got full points on both assignments the total percentage for my grade went down.  Is this because the extra credit was not a separate assignment/category and was part of the normal assignment weighting?

John Doe ---end email---

While I empathize with the student in that one does not want to see their overall score lowered when they got perfect scores on subsequent assignments, his gut-level response was in error. After considering his question, here is my response:

---start email--- John, This is because of the mathematical relationship between the divisor and quotient in division. Simply put, when the divisor increases and the dividend remains constant (or does not increase at a constant rate with the divisor), the quotient will decrease. Here, the divisor increases by 1 for each score. To remain at the percentage of 106.1111111111111, you would need to score 106.1111111111111 on each assignment. 

Below is the calculation of your course score to date.

   100 - assignment 1a
   100 - assignment 1b
   100 - assignment 2a|
+ 100 - assignment 2b
   116.6666666666667            - extra credit (35/30) assignment 3a
   120                          - extra credit (60/40) assignment 3b
   636.6666666666667 / 6 = 106.1111111111111 – Your score before assignment 4 a & b
   100 - assignment 4a
+ 100 - assignment 4b
   836.6666666666667 / 8 = 104.5833333333333 – Your score after assignment 4 a & b ---end email---

Now, to be honest, I think my initial reaction to my overall score decreasing would be the same. However, after actually calculating the score, system 2 wins again.

Saturday, September 12, 2020

Loving VS Code (as much as Notepad++)

OK, I really do love VS Code as much as Notepad++ now. One thing that I have liked about Notepad++ was that when exiting, unsaved files are persisted in the view. I discovered that VS Code provides the same!

First, select File | Preferences | Settings.

Next, search for “hot exit”. Then, update the setting to onExitAndWindowClose.