How Do You Create an Issue for a Repository in a GitHub Organization the API?

Problem scenario
You are running this command:

curl -u jdoe:$password -X PUT -d ‘{“title”: “Look at this bug”, “body”: “This is a serious problem here.”, “assignees”: [ “jdoe” ], “milestone”: 1, “labels”: [ “bug” ]}’ https://api.github.com/repos/$orgname/$reponame/issues

The message in the response you receive is “Not Found”. You found documentation that refers to an “owner” being in the URL. You see “POST /repos/:owner/:repo/issues” (with no reference to the organization).

 » Read more..

How Do You Read in User Input with Golang?

Problem scenario
You want to read in user input with Golang. What should you do?

Solution
This program will illustrate how you accept user input with a Golang program:

package main

import (
“bufio”
“fmt”
“os”
)

func main() {
fmt.Println(“Please enter some text:”)
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString(‘\n’)
fmt.Println(“The text you entered was this: “, text)
}  » Read more..

How Do You Write an Ansible Playbook to Install a Yum Package?

Problem scenario
How do you use the yum module in an Ansible playbook to install a yum package?

Solution
Prerequisites
This assumes you have installed Ansible and configured a managed node to work with it. If you need assistance with this, see this posting.

Procedures
1. On the Ansible control server,

 » Read more..

How Do You Create a GCP VM to Be a Web Server?

Problem scenario
You have a GCP server. You can run curl commands to its URL via localhost. But with a URL constructed with the server’s external IP address the curl command times out. You cannot reach the URL from your workstation. How do you get the GCP server to present the web service to other machines?

Solution
Modify the firewall rule by following these steps below.

 » Read more..

How Do You Install Firefox on a Windows Server with PowerShell?

Problem scenario
You want to install Firefox on a Windows server without using the traditional GUI method. What should you do?

Solution
1. Open PowerShell ISE as Administrator (right click it, go to More -Run as Administrator).
2. Run this script (e.g., firefox.ps1):

# This script was mostly taken from https://forum.pulseway.com/topic/1940-install-firefox-with-powershell/

# www.continualintegration.com changed the version number of Firefox and added some comments
# Silent Install Firefox

# Download URL: https://www.mozilla.org/en-US/firefox/all/

# Path for the workdir
$workdir = “c:\installer\”

# Check if work directory exists if not create it

If (Test-Path -Path $workdir -PathType Container)
{ Write-Host “$workdir already exists” -ForegroundColor Red}
ELSE
{ New-Item -Path $workdir -ItemType directory }

# Download the installer

$source = “https://download.mozilla.org/?product=firefox-58.0.1-SSL&os=win64&lang=en-US”
$destination = “$workdir\firefox.exe”

# Check if Invoke-Webrequest exists otherwise execute WebClient

if (Get-Command ‘Invoke-Webrequest’)
{
Invoke-WebRequest $source -OutFile $destination
}
else
{
$WebClient = New-Object System.Net.WebClient
$webclient.DownloadFile($source,  » Read more..

How Do You Set the S3 Policy to Archive after 60 Days?

Problem scenario
You want items in an S3 bucket to be archived automatically after they are 60 days old. What do you do?

Solution
1. Log into the AWS console.
2. Click on your S3 bucket.
3. Click on the “Management” tab on the right.
4. Click on “Add lifecycle rule”
5. Give the rule a name. Click “Next.”
6.

 » Read more..

How Do You Delete an Aurora Database when You Get an Error about It Not Being Started?

Problem scenario
You are trying to delete an Aurora database but you get this error: “This database is not started.” What do you do?

Possible Solution #1 (with the web console)
1. Log into the web console.
2. Go to “Amazon RDS”.
3. Go to “Databases”
4. Click on the Aurora cluster of the database you want to delete or its parent.

 » Read more..

How Do You Find the Default Directory for Tomcat when It Acts as a Web Server?

Problem scenario
Your Tomcat server is has been configured to serve as a web server. You have access to the back-end Linux server. But you do not know what directory corresponds with the URL of the host. How do you find what the default directory is for files that are presented on the web?

Solution
From the back-end, run this: sudo find / -name index.html | grep tomcat

Look for a WEB-INF or webapps directory.

 » Read more..

How Do You Troubleshoot an Error Such as “UnboundLocalError: local variable ‘foobar’ referenced before assignment”?

Problem scenario
You run a Python program. You receive this message: “UnboundLocalError: local variable ‘foobar’ referenced before assignment”

What should you do?

Solution
Initialize the variable (e.g., foobar = 0). If you do so inside a function wherein foobar, that may work. If you want it to be available globally throughout your program, you will initialize it outside of a function.

 » Read more..

How Do You Troubleshoot Golang Using Hexademical Values?

Problem scenario
Your Golang program has variables with values that look like this:

{0xc4200457e8 [97 49]}

You think the that underlying variables should have regular alphabetic string values. What should you do?

Solution
Use the .string() function.

When you use strings.Builder for a variable, the value will be a hexadecimal value. To retrieve the string value that you intend,

 » Read more..