How Do You Iterate Through Two Lists of Unequal Length in Python?

Problem scenario
You want to iterate through two lists and perform some operation. The lists are not equal length. You want to iterate through them in some type of step-by-step fashion despite their lack of equality. What should you do?

Solution
Use this as an example:

list_a = [1, 2, 3]
list_b = [”dog”, “cat”, “rat”, “chicken”]

i = 0
j = 0

while (i < …

How Do You Write Python Code to Test if a Dictionary Exists?

Problem scenario
You want to test if a dictionary exists or not. You know its name if/when it exists. What do you do?

Solution

# Suggested usage: 1) run it is as it is.
# 2) uncomment out the dictionary_name1 definition stanza.
# Then run this program again.

#dictionary_name1 = “good_dict”

if ‘dictionary_name1’ in locals():
print(“IT IS IN LOCALS”)
else:
print(“IT IS NOT IN LOCALS”)

if ‘dictionary_name1’ in globals():
print(“IT IS IN GLOBALS”)
else:
print(“IT IS NOT IN GLOBALS”) …

How Do You Install Troubleshoot the Kubernetes Error “dial tcp x.x.x.x:10248 connection refused”?

Problem scenario
You are trying to run “kubeadm init”, but you get this error:

“failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.”

What should you do?

Solution
Is the kubelet service running? Run this: sudo systemctl status kubelet

To install the kubelet, see this posting for How Do You Install the kubelet on any type of Linux?

How Do You Troubleshoot the Kubernetes Error “[ERROR Port-10250]: Port 10250 is in use”?

Problem scenario
You are trying to run a kubeadm command. But you get this error:

[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Port-10250]: Port 10250 is in use
[preflight] If you know what you are doing, you can make a check non-fatal with –ignore-preflight-errors=…

What should you do?

Solution
Remove the kubelet that snap installed;

How Do You Troubleshoot a Python MapReduce Job That Returns “Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1”?

Problem scenario
Your Python MR (mapreduce) job is failing. You do not know why.

You may or may not get an error like this: “Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1”

Other symptoms you may experience is the MapReduce job takes a great deal of time. It seems to hang. What should you do?

Solution

  1. Determine which map .py file you are using and which reduce .py file that you are using.

How Do You Install SUSE when It Fails with a Kernel Error with Little Information?

Problem scenario
Linux SUSE won’t install. When the installation process is happening it stops with an abortive error that exits the pretty GUI menu sequence. You get “linuxrc 7.0.15 (Kernel 5.3.18-lp152.19-default) an error occurred during the installation.” What should you do to install SUSE?

Possible Solution #1
Start over. When you see this window “YaST2 The system has an active network connection.

How Do You Harden a Website Application?

Problem scenario
You want to ensure you web application is protected from buffer overflows, injection attacks and other vulnerabilities that could reveal sensitive information. How do you harden a website application and follow security recommended practices?

Possible Solution #1
Endeavor to prevent injection attacks. Minify the website application by not allowing file uploads and limit POST requests to 2 MB (page 28 of Node.js Security by Liran Tal).