How Do You Write a BubbleSort Algorithm in Python That Runs in O(n) in a Best Case Scenario?

Problem scenario
You want to use BubbleSort in Python that runs in O(n) time when the list to be sorted is already in perfect order.  How do you write such a program?

Solution
Use this code for BubbleSort with a refinement:

def refinedBubbleSort(coollist):
needtoswap = True
x = len(coollist)-1 # x is now the index value of last item in list
while x 0 and needtoswap:
needtoswap = False
for i in range(x): # start with leftmost number and iterate to the xth position one space at a time
if coollist[i] coollist[i+1]: # swap if left item in pair is greater than right item
needtoswap = True
coollist[i],coollist[i+1] = coollist[i+1],coollist[i]
x = x-1 # Go through the list from rightmost item until the leftmost item
coollist = [1,2,3,4,5,6,7,8,9,10]
refinedBubbleSort(coollist)
print(coollist) …

How Do You Install Sysdig in an Existing Debian-Based Docker Container?

Problem scenario
You want to monitor Docker containers.  Therefore you want to install Sysdig to try it out.  How do you install Sysdig in a pre-existing Docker container?

Solution
Run these three commands:
apt-get -y update
apt-get -y install curl
curl -s https://s3.amazonaws.com/download.draios.com/stable/install-sysdig | bash

How Do You Get a DNS Server That Was Working to Work Again?

Problem scenario
Your DNS server does not seem to be working any more.  What should you do?

Solution
1.  Can you ping it? 
2.  Log into it.  Run these commands to ensure that there is activity on a port:

sudo netstat -anlp | grep :53
nmap -Pn 127.0.0.1

If there is no activity, start the service with this command:
sudo systemctl start named.service

What Do You Need to Do to Get a RHEL Server to Be a DNS Server?

Problem scenario
You have a RHEL server in AWS.  You want it to be a DNS server.  What do you do?

Solution
For security reasons, you should have the network that this DNS server will serve be behind a firewall.  Following a short Question and Answer guide like this is fine for testing and learning.  However, denial of service attacks are more possible when a primary DNS server engages in recursive look ups (page 857 of A Practical Guide to Fedora and RedHat Enterprise Linux).

A List of Kubernetes Books

Some of these items are books, practice exams or DVDs related to Kubernetes. This list was updated on 4/5/20.

Amazon EKS: User Guide
Building Enterprise JavaScript Applications: Learn to build and deploy robust JavaScript applications using Cucumber, Mocha, Jenkins, Docker, and Kubernetes
Building Microservice Systems with Docker and Kubernetes – Training DVD
Certified Kubernetes Application Developer (CKAD) Complete Video Learning Certification Exam Set (DVD)
Cloud Native DevOps with Kubernetes: Building,

How Do You Change The Port That GitLab Listens on?

Problem scenario
By default GitLab runs on port 8080.  You want to run something else on the server with GitLab.  How do you change the port that GitLab uses?

Solution
1.  Edit the /etc/gitlab/gitlab.rb file.

Find the stanzas with for the “external_url”.

Change it from this:  http://x.x.x.x/

to this:  http://x.x.x.x:555

(where x.x.x.x is either the external IP address or FQDN of the gitlab server and 555 is the desired non-standard port number that you want GitLab to listen on).

What Can You Do to Set up Jira when It Hangs Forever with No Error Messages?

Problem scenario
You connect your Jira instance to an empty SQL database.  For the first time you log into the web UI to set things up.  When you try to create a task, project or story, the web UI hangs forever.  If you close out of the web UI, you have to start all over.  

What do you do when you first connect to a Jira instance via its web UI and it prompts you for a language and other initial settings but hangs when you try to create a task or story?

How Do You Know If a Program Ended Because It Completed Successfully, Had an Error, or Another User Interactively Terminated the Running Program?

Problem scenario
You believe that there are three main ways a program runs:  one it completed successfully, two an error made the program stop, or three another user on the server interactively terminated the program when it was still running.  You want to identify which one of these three possibilities happened.  How do you know if the program that just ran stopped because it completed successfully, had an error, or another user manually killed the running program?

What Is a Dockerfile and What Is a Docker Image?

Question / Problem scenario
You know what a Docker container is.  What is a Dockerfile and what is a Docker image?

Answer to What is a Dockerfile?
“Dockerfiles are used to define how a container should look at build time, but they do not manage the container’s ongoing state, and cannot be used to manage the Docker host system.” (Page 5 of Docker Up & Running by Matthias &