How Do You Fix a Python Program that Returns “Killed”?

Problem scenario
You are trying to write a Python program. It returns “Killed” on a Linux terminal. How should you fix this?

Possible Solution #1
Refactor your code. There is a programming method called “brute force” which is a reference to creating an exhaustive number of possibilities and processing those possibilities. This method will not work for certain problems because the input size is too large.

 » Read more..

How Do You Find the Vertical Scroll Bar to Browse Emails in Apple Mail?

Problem Scenario
You are using Apple Mail. You want to scroll up and down to see the senders and subjects of emails. You cannot find the vertical scroll bar. What should you do?

Solution
Increase or decrease the window’s vertical length by clicking and holding a horizontal edge of the window with the mouse and moving the edge in one direction. After you do this the vertical scroll bar should appear.

 » Read more..

How Do You Troubleshoot the Python Problem “UnicodeEncodeError: ‘ascii’ codec can’t encode character”?

Problem scenario
You are trying to print out a variable in Python. But you get an error like this: “UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xa0’ in position 70567: ordinal not in range(128)”

What should you do?

Solution
Root cause: A variable needs to be encoded as UTF instead of the default ASCII encoding.

Procedures
Assuming that var1 is a variable holding the results of a requests.get(url),

 » Read more..

How Do You Briefly Look at the Conditions of Kubernetes Nodes?

Problem scenario
What is a good command to see the overall health of your Kubernetes servers (nodes)?

Solution
Run this command: kubectl describe nodes

 » Read more..

How Do You Delete a Trail from CloudTrail?

Problem scenario
You want to delete a trail from CloudTrail so you can delete an S3 bucket (to avoid AWS charges). How do you do this?

Solution
Warning: You may be able to delete the non-empty S3 bucket that the Trail was supposed to use without deleting the Trail.

Procedures

  1. Log into the AWS Management Console (i.e.,

 » Read more..

How Do You Analyze Java Thread Dumps?

Problem scenario
You run Java programs on your Linux server. You want to view content of Java thread dumps. What should you do?

Solution
Prerequisites
Install Java if it has not already been installed. See this posting if you need assistance.

You may or may not want to learn more about what a Java thread is;

 » Read more..

How Do You Get Python to Search a Web Page for a Specific Pattern?

Problem scenario
How do you write a Python 3 program to parse the text of a web page and determine if a string is on the web page or not?

Solution
Change the “yoururl” variable assignment and the “searchterm” assignment below to what you desire. Then run the program below:

import re
import requests
yoururl = ‘http://www.continualintegration.com/’
searchterm = “learned”
r = requests.get(yoururl)
found = re.search(searchterm,  » Read more..

How Do You Write a Program to Test if Integers Are in Order?

Problem scenario
You need to write a Python program to see if a list of unique integers is in order. You can copy the list and sort it to compare the ideal state to the list provided. The program must print out if a number swap can place two numbers in the correct order. The program must print out if a given number is already in order.

Here are the requirements of the Python program:

  • generate a list of numbers (either by random or hard-code a list)
  • sort the list
  • find if incorrectly placed numbers share a spot with another number that if swapped,

 » Read more..

How Do You Configure Nginx to Listen to Messages Sent via HTTP?

Problem scenario
You have Nginx configured. The access logs never pick up any POST message content. You get 405 error messages. What do you do?

Solution
This will send a message payload — but not via POST. It may not work for your situation. To get a message to be sent to a website (a listening web service), craft a URL that does not necessarily exist,

 » Read more..

How Do You Troubleshoot “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — winrm-elevated (LoadError)”?

Problem scenario
You run a Vagrant command. But you get this message: “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — winrm-elevated (LoadError)”

What should you do?

Solution
Run this command:

vagrant plugin install winrm-elevated  » Read more..