Problem scenario
You are using a Red Hat derivative of Linux. How do you install pip (e.g., on CentOS or Fedora)?
Solution
Run this command: sudo dnf install python3-pip
A Technical I.T./DevOps Blog
Problem scenario
You are using a Red Hat derivative of Linux. How do you install pip (e.g., on CentOS or Fedora)?
Solution
Run this command: sudo dnf install python3-pip
Problem scenario
You try to log into GitLab for the first time, but you get this error:
"502 Whoops, GitLab is taking too much time to respond."
What should you do?
Solution
Go to the back end of the server. Run the top command. Is the left most load average above 1 (e.g, 1.08)?
The top line of the results of the top command will look something like this:
load average: 1.08, 1.93, 3.99
The left most number is 1.08. This is above 1.00. GitLab is sensitive to loads. You may need to stop other processes or use a server with more CPUs, faster CPUs, and more memory (RAM). If you are using an AWS server and want to resize your EC-2 instance, you may want to see this posting. If you are using GCP and want to resize your VM, you may want to see this posting.
Problem scenario
You want to list the namespaces for a given user in Linux. You want the output to be in JSON. What should you do?
Solution
Run this command: lsns -J
Problem scenario
You have a Python program that takes a picture with a USB-attached camera. But when the crontab runs the program, the program does not work. You want vlc or some camera application to launch and capture a photo when the Python program is run with a crontab execution. You want a solution to work if you are logged into a terminal with Putty with no desktop GUI logged in. What do you do?
Solution
1. Install fswebcam. (In our experience vlc works best in a desktop GUI environment.)
For Debian/Ubuntu Linux, run this command to install fswebcam: sudo apt-get -y install fswebcam libjpeg8-dev imagemagick
For CentOS/RHEL/Fedora, run these commands:
sudo yum -y install gd gd-devel git
git clone https://github.com/fsphil/fswebcam.git
cd fswebcam
sudo ./configure --prefix=/usr
sudo make
sudo make install
2. To use it, run this command: fswebcam -r 640x480 --jpeg 85 -D 1 /tmp/usb_camera_photo.jpg
3. You are done. You may want to have Python invoke the bash command above. (Remember that import subprocess, import os, import system are potential ways of invoking a Bash command. There are security risks associated with these.)
Problem scenario
You want to see every PowerShell 5 command available. What should you do?
Solution
This may not show every PowerShell v. 5 command, but it will show many: Get-Command
Another was is to open Windows PowerShell then go to View -> Show Command Add-On. The list will be different if you are running Windows in Google Cloud Platform or AWS.
Problem scenario
You wrote a Dockerfile. You are using it to try to create a Docker image. When you run the "docker build" command you get some error messages. The errors include one or more of the following:
1) A MarkupSafe fatal error related to Python.h.
2) A C extension not being compiled.
3) An invalid syntax error related to async (e.g., "Jinja2/jinja2/asyncfilters.py").
You need to base the image off Ubuntu. What should you do?
Solution
Problem scenario
You use del and pop to remove items from lists. You noticed that pop is slower than del. Why is this the case?
Solution
There are two reasons. One, pop returns the value that is removed. Two, pop acts as a function call as opposed to a primitive action. Whereas the del invokes a primitive action (a non-recursive function call), pop involves recursion.
Basically, another operation has to take place with pop compared to del.
This program will have three function calls. If you run this program, you will see the number of function calls because we import cProfile and use it:
import cProfile
a = 1, 2, 3, 4, 5
contintlist = list(a)
cProfile.run('del contintlist[3]')
This program will have four function calls:
import cProfile
a = 1, 2, 3, 4, 5
contintlist = list(a)
cProfile.run('contintlist.pop(3)')
You can run the above programs to see for yourself.
This program prints out "4":
a = 1, 2, 3, 4, 5
contintlist = list(a)
x = contintlist.pop(3)
print(x)
This next program is very similar, but it does not run:
a = 1, 2, 3, 4, 5
contintlist = list(a)
x = del contintlist[3]
print(x)
This program will print out something like this:
File "t.py", line 3
x = del contintlist[3]
^
SyntaxError: invalid syntax
You see that pop does a return which is an additional function (as the profiler output of the first two programs will show). The del invocation is faster, but it returns nothing.
Problem scenario
You want to use the MVC model without Microsoft technologies. You want to try out the Spring framework to leverage its inverse-of-control. How do you quickly deploy the Spring framework?
Solution
Prerequisites
i. This assumes that you have installed Git. If you need to install it, try this command:sudo yum -y install git
ii. This assumes that you have installed Maven. If you need assistance, see this posting.
Procedures
(The below was adapted from this external website.)
1. Run these commands:
git clone https://github.com/spring-guides/gs-spring-boot-docker.git
cd gs-spring-boot-docker/complete
mvn package && java -jar target/gs-spring-boot-docker-0.1.0.jar
2. From a web browser, go to the server's IP address over port 8080. That is compose a URL like this where x.x.x.x is the external IP address of the server: http://x.x.x.x:8080
Place that URL that you just created in a web browser. You should see displaying "Hello Docker World".
Problem scenario
You recently migrated to WordPress. There are small windows of text on the left or right side of your blog. They are not posts. You do not know how to modify them. What should you do to modify them or add advertisement banners to your website?
Solution
These sidebar text rectangles are called "Footers" in WordPress. To modify them, delete them, or create new ones do the following three steps:
Problem scenario
You have C++ installed. You want to know what version it is. What do you do?
Solution
Possible solution #1
Run this command: /usr/bin/cpp -v
Look for the word "version". Use CTRL-c to exit out.
Possible solution #2
Run these two commands:
. /opt/intel/bin/iccvars.sh intel64
icc -v
(Taken from https://superuser.com/questions/465949/how-to-know-what-version-of-c-compiler-is-installed-on-linux-server)