How Do You Eliminate Unwanted Indentation at the Top of Text in WordPress Postings?

Problem scenario
You are using WordPress for your website. In some text, paragraph blocks you use with the “<Code” syntax on some lines of computer programming code. The first word is indented from the left. You do not want this indenting. What should you do so your code looks like code but does not have this indentation problem?

Solution
Do not use the “Paragraph” formatting.

How Do You Assign a Variable in JavaScript from User Input?

Problem scenario
You want to read input and assign it as a variable in JavaScript. What should you do?

Solution
Create a .html file, saved directly on your desktop or in a /var/www/html/ directory on a web server, with the follow content to illustrate how to do this (then open it in a web browser):

<!DOCTYPE html<html<body<h2Use JavaScript to Change Text</h2<pThis example writes “Hello in JavaScript from Continualintegration.com!” into an HTML element with id=”demo”:</p<p id=”demo”</p<scriptvar foo = prompt(“Please enter input and press enter”); …

How Do You List the Repositories in GitHub for a Specific Organization without Using the Web UI?

Problem scenario
How do you use the GitHub API to list repositories for an organization?

Solution
Draft a command like this:

curl -u jdoe https://api.github.com/orgs/foobar/repos | grep git_commits_url

  • Change “jdoe” to the username of your GitHub account
  • Change “foobar” to the name of your organization

Why Does a PHP Program Call to a Python Program Work from the Back-End but Not from the Front-End?

Problem scenario
In your PHP program, the Python binary is executing regardless of how the PHP program is run (e.g., from a command line with the php command or when downloaded from a web browser). The PHP program will launch Python programs if the PHP program is invoked from the back-end with PHP. But Python programs are not being interpreted by Python when a web browser loads the PHP file.

How Do You Troubleshoot a Web UI Problem with GitLab?

Problem scenario
When you are using GitLab, you receive various 500 errors. The web UI is not working correctly. What should you do?

Possible solution #1
1. Go to the back-end of the GitLab server. Run this: sudo gitlab-ctl tail
2. Reproduce the web UI problems that you are having. Examine the output.

Possible solution #2
You may want to install Fiddler on your desktop to get more details about the front-end.

How Do You Use Multi-Line String Variables in JavaScript?

Problem scenario
You want to present multiple lines in an “alert” message in JavaScript. How do you have new lines with text in JavaScript?

Possible Solution #1 (less preferred)
Use syntax like this:

var y = `
line1
line2
line3
`;

Possible Solution #2 (preferred)

var z = [
line1,
line2,
line3
].join(“\n”);

You could use this stand-alone file multiline.html:

<!DOCTYPE html<html<body<h2This demonstrates a multi-line variable in JavaScript</h2<p id=”demo”</p<scriptline1 = “aaa”
line2 = “bbb”
line3 = “ccc”

var z = [
line1, …

How Do You Create a Function in JavaScript?

Problem scenario
You want to create a function in JavaScript. This way you can use code over-and-over. How do you use a function in JavaScript?

Solution
Call this file contint.html

<!DOCTYPE html<html<body<h2This demonstrates accepting input and using a function in JavaScript</h2<p id=”demo”</p<scriptx = 5
var foo = prompt(“Please enter a number”);

function contintFunction(p1, …

How Do You Get Nginx Logs to be in JSON format?

Problem scenario
The book Expert Python Programming (page 278) says 12 Factor app recommends that the application should not be aware of the format of the logs. JSON format for logs can be beneficial for various purposes. You want Nginx’s access logs — but not error logs — to be in JSON format. What do you do?

Solution
Use a file like this for your nginx.conf.

How Do You Find the Web UI of a GitLab Server on Your Network?

Problem scenario
You inherited a GitLab server on your network to manage. You want to find the front end of the URL. What should you do?

Solution
Find the external IP address. Log into the back-end. If it has access to the internet, run this command: curl icanhazip.com

If you have no access to the internet, run this command: ip addr show

Use the IP addresses exhaustively in a web browser with a port in this fashion (where ppp should be replaced with the port number you want to try): http://x.x.x.x:pppp

The port number may be one to five numbers long.