How Do You Troubleshoot the Boto3 Error “AttributeError: ‘ec2.ServiceResource’ object has no attribute ‘terminate_instances'”?

Problem scenario
You are trying to terminate some EC-2 instances. But you see a message like this:

“AttributeError: ‘ec2.ServiceResource’ object has no attribute ‘terminate_instances'”
“AttributeError: ‘ec2.ServiceResource’ object has no attribute ‘destroy_instances'”
“AttributeError: ‘ec2.ServiceResource’ object has no attribute ‘delete_instances'”

What should you do?

Solution
Rewrite the terminate portion to look like this:

ec2.instances.filter(InstanceIds=[’i-0abcd1234′, ‘i-0wxyz9999’]).terminate() …

How Do You Use Boto and CloudFormation to Delete a Stack?

Problem scenario
You want to delete a CloudFormation Stack with Boto. What do you do?

Solution
Run a program like this (but replace “continualstack” with the name of the stack you deployed):

import boto3
cloudf = boto3.client(‘cloudformation’, region_name=’us-west-1′, aws_access_key_id=’AKIAMNOPQRST’, aws_secret_access_key=’FOOBAR1234/ZYXWV987654′)
json_stack=open(‘lampstack.json’, ‘r’).read()
cloudf.delete_stack(StackName=’continualstack’) …

How Do You Eliminate Old Email Settings in Mozilla Thunderbird on Windows?

Problem scenario
You keep opening Mozilla Thunderbird in Windows, and it keeps finding the old settings. You want a fresh installation. What should you do?

Solution
Overview: Totally remove Thunderbird and reinstall it.

Procedure

  1. Close Thunderbird
  2. Install CCleaner. It can be downloaded from here: https://www.ccleaner.com/ccleaner/download. (The free version will work.)
  3. Open it.

How Do You Troubleshoot the Python Errors “NameError: name ‘copy’ is not defined” or “object has no attribute ‘copy'”?

Problem scenario
You are running a Python program. But you get “NameError: name ‘copy’ is not defined” or “object has no attribute ‘copy'”. What should you do?

Solution
Use “import copy” at the top of the program.

How Do You Troubleshoot the Hadoop Error “ApplicationClientProtocolPBClientImpl.getApplicationReport”?

Problem scenario
You are running a Hadoop command, but you get this message:

java.net.ConnectException: Your endpoint configuration is wrong; For more details see: http://wiki.apache.org/hadoop/UnsetHostnameOrPort, while invoking ApplicationClientProtocolPBClientImpl.getApplicationReport over null after 3 failover attempts. Trying to failover after sleeping for 22088ms.
2020-12-20 18:54:36,679 INFO ipc.Client:

What should you do?

Possible Solution
Is Resource Manager running? Start a new terminal and run “jps” to find out.

How Do You Determine the GitHub Enterprise URL for the API Endpoint?

Problem scenario
You want to run some curl commands to invoke a GitHub Enterprise URL. You tried using “https://api.github.foobar.com/…”, but you get a message about the URL not resolving. How can you find out what the API endpoint is?

Possible Solution
Try “https://github.foobar.com/api/v3/…” instead. Although Github.com uses the “api” immediately after the “https://” constructor (and to the left of the “github…” section),

How Do You Write a Python Program to Find if The “Read more” Preview on a Web Page is Visible for Every Web Page Previewed?

Problem scenario
Sometimes the “Read more” or “Continue reading” hyperlink in the page preview of your website (e.g., when you search for a word), is not visible. You know that some of your web page previews on your website don’t have the “Read more” hyperlink at the end. This makes the preview appear to have the entire web page. You need to identify the postings that don’t have the “Read more.” How do you use Python to find the pages that have previews that have no “Read more” hyperlink?

How Do You Write a Python Function to Determine if There Are Three or More Unique Characters in a String?

Problem scenario
You want a function to tell you if there are three unique characters in a string. For example “ababababa” would have fewer than three unique characters. But “abc” would have three or more unique characters. How do you write a function that does this that solves in linear time?

Solution

variable_to_test = “aaaaaaaaaaaabbbbbb”

def two_unique(s):
flag = “There are only two unique characters in the string!”
dict_a = {}
for string_portion in s:
if string_portion in dict_a:
pass
else:
dict_a[string_portion] = 1
key_counter = 0
for key in dict_a.keys():
key_counter = key_counter + 1; …