Rechargeable Batteries Can Save Your Sleep

9V Micro USB Rechargeable Battery

Ever notice that your smoke alarm 9V batteries always fall below the charge threshold and start beeping in the middle of the night? I’m not sure how they know what time it is but it never fails. About 18 months ago we replaced all our battery backed up smoke alarms with versions that had a 10-year battery life. We were therefore grumpily surprised at 3 A.M. to hear an all too familiar electronic chirp. Seems we forgot about our carbon monoxide detectors. I suppose every year I could just replace and throw away the old batteries but getting rid of batteries is a pain, and who wants to get rid of a battery that might still have a lot of life left? I recently discovered that they now have 9V Li-Ion rechargeable batteries. I know, I know, for a tech guy I can really lag behind the times. I really like that this particular battery has no external charger to store or lose. I just need a micro-USB cable to plug into the bottom when recharging time is nigh. I’m not recommending this particular model since I have extremely limited experience with it. I put a reminder in my calendar a year from now to go ahead and recharge these whether they need it or not. Here’s hoping for a year of un-chirperrupted sleep.

My New Favorite VS Code Extension

Tech Debt Tracker

Nobody likes technical debt and that’s why I love Tech Debt Tracker for VSCode. Not only does it do a great job of identifying technical debt in your existing code, it can keep you from introducing more debt. It has some collaboration tools I haven’t really explored yet but just the identification of technical debt is useful. The tool assigns a rating from A (good) to E (ugh) to your code. An A rating is saying This code is clean, easy to maintain, and likely to be bug-free. Who doesn’t want that?

I’ve been using the tool for several months of TypeScript development and I’ve come to believe the metrics used are valuable and accurate. Rarely will I disagree with the results. Speaking of results, they are broken out into multiple categories like, nesting depth, understandability, argument count and a few others. You can see the details inline in your editor and make a decision about what’s important to you to fix. There is also a Debt Ratings panel in the explorer so you can get an overview of the ratings of all the methods in a file.

Greenfield

If you’re lucky enough to be coding on a brand new project just use the tool to monitor your code development and strive to make every method an A. It’s fine to code up a B or C in the heat of battle. But before you release, refactor with a goal of A for everything. If for some reason you can’t, decide if that’s a //TODO or //FIX for the future or at least a notation about why you left it less than pristine shape. Sometimes the comment metric can get in the way.

The Boy Scout Rule

You should always leave your code cleaner than you found it. When you need to work on a method, and the Tech Debt Tracker grade goes down, you should fix it so that it’s no worse than when you started. If it wasn’t an A when you started you might consider doing future you a favor and making it an A before you consider yourself done.

Targeted Refactoring

Tech Debt Tracker can also be used to triage refactoring work. Look through the code base and find some code with the worst ratings. I would like to see a way for the tool to automatically find the worst code but at the moment that isn’t available.

Go Egoless

Try it out and leave your ego someplace safe. I had a lot of code that didn’t get an A. Sometimes I thought the tool was crazy, but I refactored anyway. In almost all cases, when I was done I had to admit my code had improved. In the (very) few cases where I didn’t think the code was more understandable, I just reverted to my original code. I figured after doing this for 40 years I had some instincts I could trust.

Is Your VPN Killing Your Network Connection?

Terminal Ping Failure

Overview

If you use VPN on MacOS you may notice that if you leave the VPN running for a while your normal network operations are affected. It would appear the VPN software may not be properly restoring your DNS (Domain Name Server). Here’s how to find out if that’s the problem, and how to fix it.

Is it a DNS problem?

Open the Terminal.app and ping a know IP address. The one I find easiest to remember is 1.1.1.1. If that responds, then ping a domain via its name. In the image at the top you can see I pinged the DNS with no problem, but pinging www.google.com did not work. This is a good sign that you have a DNS problem.

Six Step Recovery Process (faster than rebooting)

Step 1 - Launch the Network System Preferences panel.
System Preferences

Step 2 - Click the Advanced… button. Spoiler alert, you’ll come back here to click Apply as the last step.
Network Preferences

Step 3 - click the DNS tab at the top of the Advanced window
Advanced Network Preferences

Step 4 - drag your DNS Servers: entries to be in a different order. If you only have one, add another one (either of the two shown here will work).

Step 5 - Once you have a different DNS server on Top click OK.

This will take you back to the previous screen and now you can do

Step 6 - click Apply.
Your network should be working properly. You can repeat the original terminal test or just use a browser to go to a page.

Apple Watch and Being on Time

One thing I loved about my analog watch is that I could set it five minutes ahead of the actual time. You would think after a while I would adjust and that five minute buffer wouldn’t help much but after a couple of decades it is still useful. Until very recently I didn’t realize that a lot of digital watches support this crutch. The Apple Watch is my most recent timepiece and in Settings->Clock is an option for setting the watch face display time ahead. All that was required was touching the option, and then using the crown to adjust the amount of time from 1->59 minutes. It’s not a universal setting. The watch still keeps track of the real time and many features still use the real time but when I glance down at the watch face I get the false time, but enough buffer to get to the next meeting on time.

VS Code File Explorer Indent Level

In Visual Studio Code the Explorer panel indents items under a folder by a whopping 8 pixels by default. That’s just not enough for my old eyes. When I went to the settings I couldn’t find the option to adjust it. Then I went a-googling and found some .css hack workarounds but those results were over a year old. A little more searching revealed that it’s now a configurable feature.

  1. Open the Settings (Code->Preference->Settings or ⌘, on macOs)
  2. Search with tree indent
  3. You should see Workbench->Tree: Indent
  4. Change the default value to one more to your liking. I found that 20 was a better balance of indentation visibility and horizontal space usage.

8 Pixels

With 8 pixel indentation

20 Pixels

With 20 pixel indentation

Block 3rd Party Cookies in Chrome

After reading an interesting article on pixel tracking I thought that surely Chrome has a way to turn off 3rd party cookie tracking. It does but it’s not that easy to reach, and most of the top Google search results refer to old locations for the setting. Here’s a roadmap to the five turns needed to find the proper setting.

0. Open the Chrome settings from the Kebab ⋮ (vertical ellipses) menu in the upper right corner
Chrome Settings Page

1. Open the advanced section near the bottom
Advanced

2. Scroll down and click theSite Settings entry
Site Settings

3. In the Permissions section click the Cookie and site data entry
Cookies and site data

4. In the Cookies and site data enable the slider for Block third-party cookies
Block 3rd party cookies

Apple Watch and Custom Monograms

Apple watch
I started using a ligature of my initials when I was taking a scuba diving class. We all had similar equipment and the instructor handed out sharpies with instructions to personalize our gear. I’ve used it repeatedly in the ensuing decades. When I got my watch and saw the Monogram feature I thought it would nice to use it there as well. Turns out I got quite lucky. The combination of T and G that I used is a unicode character and the Monogram feature supports unicode. I was able to just cut and paste the unicode I needed in the iPhone Watch app using the Clock option. How-to Geek has an in-depth article on the process and various ways to use unicode.

Apple Watch and Tennis Score Keeping

Tennis Scoring
I found it surprisingly hard to find an Apple Watch app for keeping score in a tennis game. Most of the apps out there want to analyze your swing, or track your workout or find some other way to justify charging you a subscription fee. I just want to remember the score.

All Sports Score Keeper

I eventually found a nice solution that keeps track of both the game score and the set score. It didn’t turn up in most of my searches because I kept using the word Tennis and this app is designed for multiple sports. This turned out to be a nice benefit because I also do a hitting drill with a friend and we play one point at a time until 21. The All Sports Score Keeper app can do this with either the Simple Scoring option or the Table Tennis option. Table tennis can use 11 or 21 point scoring so be sure to use the options to configure it. This is also a convenient way to keep track of your bean bag toss game, especially as the afternoon wears on and beer supply starts dwindling.

For the price of a can of tennis balls, you’ll never forget the score again. Try it for free to make sure it works for you and if so, you’ll likely want the undo and reset features that are available in the paid version.

Swiping

You change the score with a simple swipe. At first I thought this was not going to be to my liking but it eliminates the potential for accidentally touching and scoring a point. Plus the concept of swiping towards your opponent when they score and towards yourself when you score is hard to get wrong.

Free Version bug

At the time of this writing, the app is on version 1.4 and there is a small bug that is easy to work around once you understand it. The hamburger menu ☰ shows the various sports you can select. It is off by one. So if you select Tennis you’re going to get Table Tennis. Select the item above the sport you want to get that sport’s scoring.

Pro Version Sync Issue

When I paid for the pro version I had a problem getting my watch to recognize the new version. I wrote the developer and he responded almost immediately. The steps I took to correct this were:

  1. Open the app on the phone
  2. Open the app on the watch
  3. Try to undo on the watch (a pro version version feature) and when the app asks you to get the pro version (which you already have) leave that message on the watch.
  4. Force close the app on your phone (i.e. double-click the home button and swipe up on the app)
  5. Reopen the app on the phone.
  6. NOW press OK on the watch to dismiss the dialog
  7. Try the undo feature again. If it works, you’re all set.

Once I did this I had no problem with the app.

Workouts and Apps

There is an Apple Watch problem that’s a little problematic. If you start a workout session for your tennis game there is no way to keep the scoring app as the top app. Apple continually gives the workout app that privilege. This is somewhat inconvenient. You can double press the crown to get to the scoring app. I just gave up on tracking my workout. You still get all the credits for steps and exercise you just won’t have things like the heart rate tracking and other nice details. I can’t fault the app or the developer. I have seen similar complaints about other apps and the fact that the workout app gets priority.

Apple Watch and Audible Book Syncing

Apple watch I wear a watch every day, but it wasn’t until the Apple Watch Series 5 that I felt I could give up my non-smart watch. The always-on feature was key. Once I had an Apple watch I started finding more and more things to like about it. One was the ability to listen to Audible books from my watch on my daily walk and leave my phone at home. I don’t have the cellular feature and I like that now I am not disturbed by text or phone calls when I walk. Plus it’s just nice to not carry my oversized phone with me on the walk.

Syncing Audible Books

The biggest problem with syncing is that it’s slow and seems like it’s not working. When I let it run overnight it worked. Starting the sync requires theses steps:

  1. Go to the My Library section of the app.
  2. Select the Device tab
  3. Click on the meatballs … next to the book you want to sync
  4. Select the Sync to Apple Watch option in the menu that shows up (this step not shown in image)
    Audible Screen Shot

When the process completes, a watch icon will show up for the sync’d book. You can see an example next to “The Hollow Hills” in the image. Again, when I first did this and watched the progress it would get past the preparing content step with no problem. However, it would make 0% progress on syncing and stay there. When I just did it at night and put my watch on the charger and placed my phone next to it, the sync was finished when I got up.

In the screen shot you’ll notice the book “The Last Enchantment” doesn’t have a kebab menu. That’s because I experimented with downloading that book in parts. If I click on that book I can see both parts and then I can sync the parts one at a time.

The Final Problem

One last issue arose after the book had sync’d. The Audible app on the watch seemed stuck on the screen that had instructions for how to sync a book. This was fixed by force quitting the Audible app on my watch. Force quitting an app isn’t such an obvious thing for a new watch owner so here are the steps for that.

  1. Have the Audible app active on your watch
  2. Press and hold the side button for a few seconds to bring up the reboot screen.
  3. Press in on the CROWN for a second or two and you’ll see the app quit.

Now launch the Audible app again and go for a walk with just your watch and wireless headphones.

REFERENCE

A post from Scott Allen helped me realize I both wasn’t alone, wasn’t crazy, and needed to be more patient. Scott’s post has many more details and workarounds for various issues that might arise.

Storing the Hexo Site in GitHub

Now that you learned in Part 1 -> Blogging with Hexo and GitHubPages how to get your site up on [username].github.io, you need a repository that stores your original markdown and any changes you make to the files that generate your blog.

1. Create a New Repository

Create a new repository in GitHub. Don’t add a ReadMe to it; just create the empty repository. GitHub will show you a section titled

…or push an existing repository from the command line

Underneath that are two commands that you can copy to the clipboard with the clipboard icon to the right. We’ll use these commands after the next step.

2. git init (finally)

Open a terminal window at the root level of your hexo site. NOW you can do a git init, then add all your files, and do a normal commit. You’ll notice that the previous process of setting up Hexo did create a .gitignore file for you that will ignore all the generated files.

Take the copied commands from GitHub and paste those into the terminal. This will both link your local repo to GitHub and push up the changes.