How Do You Use the strace Utility?

Problem scenario
You want to use the strace command. How do you use it?

Solution

  1. Go to a Linux command prompt.
  2. Run this: sleep 100 &
  3. Look at the number the above command produced (e.g., 310222). Craft a command like this (but replace 310222 with the number in the above command): strace kill 310222
  4. Run the command drafted above. You should see lines like "openat…" and "kill". In the kill command you will see the returned signal from the kernel (e.g., SIGTERM)
  5. Run this: sleep 100 &
  6. Look at the number the above command produced (e.g., 310222). Craft a command like this (but replace 310222 with the number in the above command): strace kill -9 310222
  7. Run the command drafted above. You should see lines like "openat…" and "kill". In the kill command you will see the returned signal from the kernel (e.g., SIGKILL)

FFR
The -9 flag in kill will kill a process; normally kill would just terminate the process.

To learn more about strace, see this external posting.

How Do You Install opencv / cv2 without pip3 so The -DWITH_FFMPEG=ON is Set On?

Problem scenario
You do not want to use pip or pip3 to install opencv. How do you install opencv (with the -DWITH_FFMPEG=ON flag)?

Solution
Prerequisite
This assumes that cmake has been installed. If you are running Ubuntu/Debian, run this: sudo apt -y install cmake
If you are running CentOS/RHEL/Fedora (some RedHat derivative), run this: sudo yum -y install cmake
If you are running SUSE, run this: sudo zypper -n install cmake

Procedures

Run these commands:

wget -O opencv.zip https://github.com/opencv/opencv/archive/master.zip

sudo cp -i opencv.zip /bin/
cd /bin
sudo unzip /bin/opencv.zip
sudo mkdir build && cd build
sudo cmake ../opencv-master -DWITH_FFMPEG=ON

How Do You Install and Create a Virtual Environment?

Problem scenario
You want to use a virtual environment to install pip packages. You want to run a Python program with a module that will require a pip installation. What should you do to install and configure the environment and then enter it using Ubuntu/Debian Linux?

Solution

sudo apt -y install python3-virtualenv
sudo apt -y install python3.*-venv
python3 -m venv cont_int #replace "cont_int" with the name of the directory you want to create
cd cont_int
source bin/activate

How Do You Make Your Laptop Have Two Different OSes?

Problem scenario
You have a Windows laptop with a DVD player. You want to boot to a Linux hard drive from time-to-time. But you do not want to dual boot the same hard drive (where one hard drive supports two different bootable OSes). What should you do?

Solution
You should purchase a hard drive adapter (aka a caddy) made to interface with the internal DVD player connection. You will lose space for your DVD player if you do this (and have one fewer DVD drives). But if you have a second hard drive, it can go where the DVD player is. (If you change your mind later and want to go back to having a DVD player, you can do that.)

How Do You Change the Orientation of Google Maps?

Problem scenario
You want Google maps to rotate rectangularly when you use your Android device as a GPS in your car. You want to view the map so the width of the screen and height change 90 degrees based on the way you hold the phone (so it responds to gravity). How do you get the screen to adjust to have a layout that is appropriate for holding the smart phone sideways?

Solution
Go to the top of the screen and swipe downwards.
Click the "Portrait" icon.

(It should change to auto rotate). That's it.

A Day That Will Live in Infamy!

FDR proclaimed that December 7th would be a day that would live in infamy. Pearl Harbor was attacked in 1941. 80 years later to the day AWS had a major outage (for the us-east-1 region): https://www.theverge.com/2021/12/7/22822332/amazon-server-aws-down-disney-plus-ring-outage

It is an interesting coincidence.

Many people think that the us-east-1 region is the least reliable of Amazon's regional offerings. Amazon said their "Support Contact Center also relies on the internal AWS network, so the ability to create support cases was impacted …" According to Amazon, and they posted a summary of the outage here (along with the previous quoted sentence), the temporary lack of monitoring contributed to their problem. If you want to read about the recommended practices of monitoring, see this posting. One big takeaway is that to communicate with customers, it is important to not have a single-point-of-failure.

What Are Reliability, Scalability and Maintainability?

Question
You want definitions of some I.T. terms. In the context of application/system design, what are reliability, scalability and maintainability?

Answer

Reliability: Dependability or suitable for production; the property of performing consistently over time; worthy of being trusted at all times due to fault tolerance. A system that can perform despite hardware failures or regional data center failures is said to have reliability.

Scalability: the property to rapidly adjust to greater or lesser workloads; elasticity.

To be scalable a system must handle increased demand with minimal performance penalty; the system must also be able to quickly reduce resource consumption (for the sake of saving monetarily) when workloads contract based on business demands. Scalability is achieved by adding or reducing (but not limited to) the following (usually automatically): processing power (e.g., the number of CPUs, the size of the cache(s) and speeds of the cache(s), memory power (e.g., size and/or speed), and networking bandwidth. A system is said to have scalability when it can scale up/down (changing the quality of the underlying computing component) or can scale out/in (changing the quantity of the underlying computing component) with little notice.

A system with the ability to expand or contract capacity suddenly (either through manual intervention or automated processes) is said to have scalability.

Maintainability: the property of being able to keep the system itself in a useful state throughout its operation; the trait of being able preserve efficiency after it is deployed, reconfigured or optimized.
A system is said to have maintainability if professionals can operate on the system once it is live and/or after changes are made to the system. A common subtrait of maintainable systems is the logical abstraction of components to reduce operational complexity (source page 23 of Designing Data-Intensive Applications by Kleppman).


The presentation of these definitions (and their presentation in a single article as they are here) was influenced by Chapter 1 of Designing Data-Intensive Applications by Kleppman.

What is Cyclomatic Complexity?

Question
What is cyclomatic complexity or McCabe's complexity?

Answer
It refers to the number of times a line of source code is entered in its execution.

Number of executionsLevel of complexity
1 to 10 Not complex
11 to 20Moderately complex
21 to 50Really complex
More than 50Too complex

It is advisable to endeavor to keep the cyclomatic complexity as low as possible (according to this external site); you may want to refactor code beyond a certain threshold. The chart was adapted/taken from pages 474 and 475 of Expert Python Programming.