How Do You Create a List of Strings in Golang?

Problem scenario
Lists have a fixed length number of discrete items. You want the items in the list to be strings. How do you create a list of strings in Golang?

Solution
1. Use this program called animal.go:

package main

import “fmt”

func main() {
var x [10]string
x[0] = “dog”
x[1] = “cat”
x[2] = “hamster”
x[3] = “rabbit”
x[4] = “chicken”

for i := 0; …

How Do You Get SonarQube to Use a New Database Connection and Change It from the Previous One It Was Working with?

Problem scenario
You try to start an old SonarQube instance but with a new database connection. In the web.log file you see a message like this: “Can not connect to database. Please check connectivity and settings.” What should you do?

Solution
Go to sonar.properties. Find the connection string for the new database. It should look something like this:

sonar.jdbc.url=jdbc:oracle://FQDN:1521:XE

The default port for Oracle databases is 1521.

How Do You Delete Browser Data from Chrome when Your First Attempt Failed?

Problem scenario
In Chrome you deleted browsing data including cookies and autofill form data. You closed the browser and reopen it, but old URLs still show up. What should you do?

Solution
Go to History -Clear browsing data -and go to “Time Range” (the drop down menu). Choose “All time” and then go to “Clear data”.

How Do You Find Out if a GitHub Repository’s Branch is Protected or Not?

Problem scenario
Using the API you want to know if a given GitHub repository’s branch is protected. What do you do?

Solution
Draft the four commands below. Replace “jdoe” with the GitHub username. Replace “organizationname” with the organization name in your repo. Replace “repositoryname” with the repository name. Replace “master” with the branch you want to check. Then run the four commands below.

How Do You Create Your Own RPM Package (Binary File) for Your Own C Program?

Problem scenario
You want to know more about RPM packaging so you can create your own .rpm file (a custom RPM package file).  In other words you want to create your own RPM package (a binary file).  You want it for installing an uncompiled C program you wrote.  The uncompiled C program is one .c file and very simple.  You don’t know how to use a spec (specification) file to create your own RPM package file. 

How Do You Get curl to Work when the Web Page is Working?

Problem scenario
You can download a file with Lynx and wget. But curl is not working. What should you do?

Solution
First, try to curl the web page without redirecting the output. If the curl command creates a file, it does not necessarily give you an accurate depiction. You may want to examine the file with a text editor. What you see without redirecting the output to a file (that is allowing the output to echo to the screen) may provide a clue.

How Do You Save a Linux Machine where You Overwrote the PATH Variables Such That No Command Will Work?

Problem scenario
The server seems to be in a hopeless condition. You want to recover the server, but no commands in Linux are working. You get “command not found” with simple commands such as ls. You cannot use sudo, cat, rm, or reboot. What should you do?

Solution
Use absolute paths. For example, use this command:

/bin/sudo reboot

If there is a new file that is causing the problem,

In Python, How Do You Call a Function as a New Thread with the threading Module?

Problem scenario
(The old problem scenario was “You want to write a program to call a unbound function in a new thread with the threading module. How do you do this?”)

You want to write a program to call a function in a new thread with the threading module. How do you do this?

Solution
Run this program (e.g., python foobar.py):

from threading import Thread
from time import sleep

def threaded_invoker():
for i in range(7):
print(“the function is processing”)
sleep(1)

if __name__ == “__main__”:
thread = Thread(target = threaded_invoker)
thread.start()
thread.join()
print(“Threading completed.”)

How Do You Examine an .xz File in the /var/log Directory (with No “tar” in Its Extension)?

Problem scenario
You have an mail.xz file in /var/log/ that has nor “tar” in its name. You want to view its contents. What do you do to view or use an .xz file with no “tar” in its name?

Solution
If you are new at this, copy the log to the /tmp/ directory (assuming this .xz file has no sensitive data or no one else uses this server).

How Do You Create and Store an Application-Level Secret on the AWS Cloud?

Problem scenario
You want to create and save an application-level secret in AWS. What do you do?

Solution
Use Secrets Manager.

Procedures

  1. Log into the AWS console.
  2. Go to “Secrets Manager”
  3. Click “Store a new secret”
  4. For the secret type choose “Other type of secrets”.
  5. For the left-most field,