How Do You Change the Resolution of the Screen Size So You Can See the Entire Window/GUI Application?

Problem scenario
You are using a Windows or Mac laptop or workstation with an external monitor. In the external monitor when you maximize applications, you cannot see the very top or very bottom of the window. You cannot see the lower portion of the bottom toolbar or ribbon. How do you get the resolution to fit in the screen and not extend beyond your monitor's size?

Solution
Root cause: The problem is not with the computer; the problem is with the monitor's settings.

Procedures

  1. Push a physical button on the monitor. (The solution is not with the OS configuration.)
  2. Go to Image Control -> Custom Scaling -> Overscan
  3. Turn Overscan "Off" (instead of "On" or "Auto"). Now when you maximize a window you will be able to see the top of it. It will be like a normal monitor configuration.

To buy a new HP Pavilion monitor, click on this link.

How Do You Sort a Dictionary in Python and Use It?

Problem scenario
You want to use a sorted dictionary in Python. What do you do?

Solution
Create a sorted list based on the dictionary's keys. Use the list as keys to summon the dictionary's values.

contint_dict = {}
contint_dict["a_test"] = "123"
contint_dict["b_test"] = "456"
contint_dict["c_test"] = "789"
sorted_dict_list = sort1ed(contint_dict.items())  # sorted_dict_list is a list, not a dictionary.
list_of_keys = sorted(contint_dict.keys())

for key_pair in sorted_dict_list:
    print(key_pair)

print("")
print("Above are key-pairs.  Below are just values.  Below demonstrates a very useful")
print("way to use a list and a dictionary (for sorting).")
print("")

for key in list_of_keys:
    print(contint_dict[key])

How Do You Troubleshoot “conntrack not found in system path” when You Run a kubeadm Command?

Problem scenario
You try to run "kubeadm init", but you receive this error:

[ERROR FileExisting-conntrack]: conntrack not found in system path
[preflight] If you know what you are doing, you can make a check non-fatal with --ignore-preflight-errors=...

What should you do?

Solution
Install conntrack.

If you are using SUSE Linux run this:

sudo zypper -n install conntrack-tools

If you are using Debian/Ubuntu Linux:

sudo apt -y install conntrack

How Do You Troubleshoot the Flask Message “LookupError: the converter ‘str’ does not exist”?

Problem scenario
You are trying to pass a string parameter to a Flask application via a call to a URL. You get the message "LookupError: the converter 'str' does not exist." What should you do?

Solution
Use the term "string" instead of "str".

Here is an example of incorrect syntax:
@app.route("/ccc/", strict_slashes=False)

This shows the correct syntax:
@app.route("/ccc/", strict_slashes=False)

What is Writing Your Own Provisioner in Terraform?

Question
You have heard there is such a thing as customer provisioners (not providers) in Terraform. What is a custom-built provisioner in Terraform?

Answer
There are generic provisioners such as "file", "local-exec", and "remote-exec".

To learn about provisioners, see this: https://www.terraform.io/docs/language/resources/provisioners/

Custom provisioners exist; you can create your own provisioner beyond the generic three ("file", "local-exec", and "remote-exec"). To learn more about writing your own (e.g., a plugin or special word for a Terraform provisioner), you can read this GitHub.com posting.

How Do You Go to an ELB from Your Workstation?

Problem scenario
You can go to an ELB's FQDN via an EC-2 instance (with a curl command). But you cannot go to an ELB from your workstation (with a web browser). What should you do?

Possible solution #1
From the EC-2 instance, can you use nslookup FQDNofELB (where FQDNofELB is the FQDN of the ELB)? This should provide you with the IP address (the last of the IP addresses in the results). You can test it from the EC-2 instance by using curl on it or from your workstation going to it in a web browser. Run nslookup x.x.x.x where x.x.x.x is the IP address of the ELB. This should give you a different FQDN that should be accessible from the internet.

Possible solution #2
Check the security groups's rules to ensure they allow for inbound connectivity. From the EC-2 instance, can you use traceroute FQDNofELB (where FQDNofELB is the FQDN of the ELB)? This should resolve the IP address. If you use the IP address of the ELB, you can determine if there is an intermediate firewall blocker between your workstation and the ELB. The AWS Security Groups could be configured to block connectivity from one workstation.

Possible solution #3
Create a Route 53 record for the FQDN. If you need to find the IP address, use "traceroute" from the EC-2 instance. Alternatively you could use nslookup FQDNofELB where FQDNofELB is the FQDN of the load balancer.

Possible solution #4
For the clients that need access, update the local hosts file so it maps the FQDN to the IP address.

Possible solution #5
Wait. If you wait 30 minutes, public DNS servers can update on their own. We have found newly-created ELBs to work immediately. In some cases it may not be Amazon's fault, but the routing tables don't update for the ELB's DNS name that does not resemble an FQDN of a server's name; ELBs have both types of names (one that is a longer alphanumeric string and a second one that resembles the IP address but looks more like an FQDN of a server) and an external IP address.

Possible solution #6
Supposedly this works:

'Use an A record rather than a CNAME in Route53.

In the AWS Management Console, choose "A record" and then move the radio button labeled "Alias" to "Yes." Then select your ELB from the dropdown menu.' It was taken from https://serverfault.com/questions/469094/issues-with-ec2-elastic-load-balancer-dns-and-routing

Possible solution #7
Was the ELB recently deleted? If you run a kubectl command to get the ELB, but the ELB was recently deleted via the web console, it will not work. Try running commands like these to verify you copied the correct ELB:

aws elb describe-load-balancers | grep -i dnsname
aws elbv2 describe-load-balancers | grep -i dnsname

How Do You Use a Nested Dictionary in Python?

Problem scenario
You want to create a dictionary of dictionaries in Python. You want to use them. What do you do?

Solution
Here is an example/illustration:

contint_dict = {}
contint_dict["a_test"] = "123"
contint_dict["b_test"] = "456"
contint_dict["c_test"] = "789"

color_animal_dict = {}
color_animal_dict["blue"] = "dog"
color_animal_dict["orange"] = "cat"
color_animal_dict["green"] = "goat"

days_dict = {}
days_dict["Tuesday"] = "midnight"
days_dict["Wednesday"] = "noon"
days_dict["Thursday"] = "evening"

big_dictionary = {}
big_dictionary["dict_1"] = contint_dict
big_dictionary["dict_2"] = color_animal_dict
big_dictionary["dict_3"] = days_dict

print(big_dictionary["dict_1"]["b_test"])
print(big_dictionary["dict_2"]["green"])
print(big_dictionary["dict_3"]["Wednesday"])

super_dictionary = {}
super_dictionary["top_of_nested"] = big_dictionary
print(super_dictionary["top_of_nested"]["dict_3"]["Wednesday"])

You may also want to see this: https://pypi.org/project/nested_dict/

Object-Oriented Programming Quiz

1. What are the three types of design patterns?
__________________

2. As a recommended practice in OOP, which is preferred?

a. Object composition
b. Class inheritance
c. Programming to an implementation
d. none of the above

3. Polymorphism happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

The sources for C are these:
https://www.geeksforgeeks.org/difference-between-compile-time-and-run-time-polymorphism-in-java/
https://www.nerd.vision/post/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming

4. Inheritance happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

5. Composition in OOP happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

6. With encapsulation, what is exposed?

a. Methods
b. Data
c. Both of the above
d. None of the above.

7. When can objects (as in OOP) exist?

a. Objects can exist at compile time
b. Objects can exist at run time
c. Both of the above
d. None of the above

8. What is another term for parent class?

a. Ancestor class
b. Base class
c. Superclass
d. All of the above
e. None of the above

9. Which of the following programming languages allow for multiple inheritance of classes? Choose all that apply.

a. Python
b. Java
c. C++
d. C#
e. None of the above


To see the answers, click here.

Object-Oriented Programming Quiz & Answers

1. What are the three types of design patterns?
__________________

Answer: Creational, behavioral, structural. Source: Page XV of Design Patterns: Elements of Reusable Object-Oriented Software

2. As a recommended practice in OOP, which is preferred?

a. Object composition
b. Class inheritance
c. Programming to an implementation
d. none of the above

Answer: A. Source: Page 20 of Design Patterns: Elements of Reusable Object-Oriented Software

3. Polymorphism happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

Answer: C, but B could be an acceptable answer. For B, the source is page 361 of Design Patterns: Elements of Reusable Object-Oriented Software; apparently with C++, it is just at run-time.

The sources for C are these:
https://www.geeksforgeeks.org/difference-between-compile-time-and-run-time-polymorphism-in-java/
https://www.nerd.vision/post/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming

4. Inheritance happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

Answer: A. Source: Page 19 of Design Patterns: Elements of Reusable Object-Oriented Software and https://www.quora.com/What-is-meant-by-%E2%80%9Cinheritance-is-compile-time-and-composition-is-runtime%E2%80%9D

5. Composition in OOP happens at which time?

a. Compile time
b. Run time
c. Both of the above
d. None of the above

Answer: B Page 19 of Design Patterns: Elements of Reusable Object-Oriented Software. Source: https://www.quora.com/What-is-meant-by-%E2%80%9Cinheritance-is-compile-time-and-composition-is-runtime%E2%80%9D

6. With encapsulation, what is exposed?

a. Methods
b. Data
c. Both of the above
d. None of the above.

Answer: A. Source: https://www.nerd.vision/post/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming

7. When can objects (as in OOP) exist?

a. Objects can exist at compile time
b. Objects can exist at run time
c. Both of the above
d. None of the above

Answer: B. Page 361 of Design Patterns: Elements of Reusable Object-Oriented Software and
https://www.quora.com/When-an-object-is-created-is-it-during-compile-time-or-during-run-time.

8. What is another term for parent class?

a. Ancestor class
b. Base class
c. Superclass
d. All of the above
e. None of the above

Answer: D. Source: Page 361 of Design Patterns: Elements of Reusable Object-Oriented Software.

9. Which of the following programming languages allow for multiple inheritance of classes? Choose all that apply.

a. Python
b. Java
c. C++
d. C#
e. None of the above

Answer: A and C. Sources: Page 188 of Programming Interviews Exposed by Mongan, Kindler and Giguere (for why C is correct and B and D are incorrect). Page 118 of Learning Python for why A is correct.

How Do You Troubleshoot “timed out waiting for the condition” after Running “kubeadm init”?

Problem scenario
You run "sudo kubeadm init", and you get this message:

[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.

[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.

        Unfortunately, an error has occurred:
                timed out waiting for the condition

        This error is likely caused by:
                - The kubelet is not running
                - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

        If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
                - 'systemctl status kubelet'
                - 'journalctl -xeu kubelet'

        Additionally, a control plane component may have crashed or exited when started by the container runtime.
        To troubleshoot, list all containers using your preferred container runtimes CLI.

        Here is one example how you may list all Kubernetes containers running in docker:
                - 'docker ps -a | grep kube | grep -v pause'
                Once you have found the failing container, you can inspect its logs with:
                - 'docker logs CONTAINERID'

error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster

What should you do?

Solution
If this is for production or something with sensitive data, we would be concerned and have no real solution for you. However if there is no real SLA, if you are doing development (e.g., for a test or proof-of-concept), just continue. Ignore the above error, as it will likely not affect you or block you. You may have "ready" nodes with the above error. Run "kubectl get nodes". You may just need to install flannel with these commands and continue:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml

kubectl -n kube-system apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml

You may need to log into the worker nodes and create /run/flannel/subnet.env (create the path if necessary). Here is the suggested content of this subnet.env file:

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

We were surprised that the above message could be ignored without it affecting Kubernetes' functionality. However for something important you may want to look into the error.