Creating a Counter or Progress Bar for a Python Program

I’ve written a number of Python apps where I would like it to print some sort of counter or progress bar to STDOUT to let me know that it is still running instead of locked up or died somehow without me being able to see it.

I had tried using a couple of different existing progress bar related modules but none of them really worked except in a very specific use case.

So, after a bit of futzing around I → Continue reading “Creating a Counter or Progress Bar for a Python Program”

How To Spy and Verify a Static Void Method in Java

The Mockito and PowerMockito libraries for JUnit4 are not always the most intuitive.

Following is an example of how to spy and verify a static void method.

    @Test
    public void testAdd() {

        // Prepare the Utils class to be spied.
        PowerMockito.spy(Utils.class);

        // Run the test and get the actual value from the OUT
        int actualValue = App.add("Test1", 1, 1);

        /*
         * To verify the number of times that we called Utils.doSomething we
         * first need to tell the PowerMockito library 
Continue reading “How To Spy and Verify a Static Void Method in Java”

Using sed with regex capture groups

There are many times when you have a file from which you want to extract specific strings based on a regex and using a capture group is a very efficient way to parse multiple strings from the same line.

I have found that sed is the easiest way to do so on the Linux command line.

Given the following input file:

This is a line of text with a year=2020 month=12 in it
This line of text does not have 
Continue reading “Using sed with regex capture groups”

Configuring rsyslog to rotate log files from log messages streamed to it from a Systemd service

In general, I have moved to writing all of my applications to write their log output to STDOUT. This makes running them on the command line, in an IDE, on a bare metal box, VM, or in a container completely decoupled from how you store and view the logs. No more having multiple logging configs for each flavor of deployment.

In this particular case, I am running an application in a container (but it isn’t necessary that it is in → Continue reading “Configuring rsyslog to rotate log files from log messages streamed to it from a Systemd service”

12×9 Sheet Pan Cookie Cake

This is for a 12×9 inch sheet pan cookie cake.

Ingredients

  • 3 cups all-purpose flour
  • 1 TBSP cornstarch
  • 1 1/2 tsp baking soda
  • 1/2 tsp salt
  • 1 cup light brown sugar
  • 1/3 cup granulated sugar
  • 2 1/4 cups unsalted butter
  • 1 cup dark or semi-sweet chocolate chips
  • 2 eggs
  • 1 TBSP vanilla extract

If you have a stand mixer this is much easier, but if all you have is a hand mixer that will work too.

  1. Preheat oven to 350
Continue reading “12×9 Sheet Pan Cookie Cake”

[SOLVED] Unable to Sign-In to Gmail with Thunderbird with OAuth2, Keeps Asking for Email or Phone Over and Over

If you are setting up Thunderbird to use your Gmail account you may find that when Thunderbird opens a new window to a Google web portal into which you are to provide your email address and password that it will keep asking you over and over again for your email and never enable to you to enter the password.

This occurs when Thunderbird’s privacy settings do not allow it to store cookies.

First, ensure that your gmail account has Allow Continue reading “[SOLVED] Unable to Sign-In to Gmail with Thunderbird with OAuth2, Keeps Asking for Email or Phone Over and Over”

How to Find Ingested Foreign Objects in Poop

Admittedly, not the most savory subject. But, for those of us with pets and/or children it is sometimes a necessity to try to find a previously ingested foreign object in feces to make sure that it does not cause medical problems in the person or animal that has accidentally eaten it.

Recently, we thought our dog had eaten a relatively small magnet and figured that we would have to be checking his feces over the next few days to ensure → Continue reading “How to Find Ingested Foreign Objects in Poop”

Edit a Range of Lines Using sed

Let’s say that you have a range of lines in a source file (lines 11 – 17) that you want to comment out with a ‘#’ and a space character before the line.

To do that, you would use sed, specifying a range of lines and then specify a replacement command with a capture group as follows:

sed '11,17{s/\(\w\)/\# \1/}' filename.py
Continue reading “Edit a Range of Lines Using sed”

Notes on Forming, Mixing, Pouring and Curing Concrete

DISCLAIMER:  These are my own notes learned from my own trials and tribulations of building things with concrete.  They are in no way, shape or form to be taken as an expert opinion.  Follow what you read here at your own risk.  This is mostly notes to myself as I work through learning how to build things out of concrete.

Big Lessons Learned

Helpers

Doing this by yourself is painful.  For anything more than a small job you absolutely need → Continue reading “Notes on Forming, Mixing, Pouring and Curing Concrete”