How Do You Troubleshoot a Script or Program That Automates Tasks when The Logs Do Not Help you?

Problem Scenario
An automated process is failing. You look in the logs and they don’t help you. You have Googled the error. What should you do?

Solution
Has it ever worked? If so, did something change?

If not, Google for the command most recently entered before the error happens. New characters could be added into the command that you do not realize. The command itself may not work (due to an upgrade to the OS or a change in a configuration).

Manually reproduce the process as you believe it is being implemented in a program to the best of your ability. Sometimes the automated process happens in a different user context or in a shell that does not have resources that you assumed were available.

What is Memoization?

Question
In computer programming, what is memoization?

Answer
Memoization is the act of pre-computing or pre-processing certain values for the sake of an algorithm's performance. Rather than perform the same exact operation (which could be very complex and computationally expensive) multiple times, memoization will involve writing code to compute it once and store it in memory as a variable. This optimization can allow the call stack to have less to store (e.g., when it circumvents recursion by accessing a variable's value) and you can reduce CPU consumption (by merely having a precomputed variable in memory).

See also pages 132 and 133 of Cracking the Coding Interview or https://en.wikipedia.org/wiki/Memoization

What Is The Third Way of the Three-Way Handshake?

Question
You want to know discretely what the third way of the three-way handshake is in the context of TCP/IP networking. What is it?

Short Answer
It is the sending of a TCP packet with a flag of "ACK" from the client to the server/destination.

Longer Answer
The third way is sending a TCP packet with the "ACK" flag (of which several potential flags are possible) to the destination:
Client -----> Server

TCP is used in HTTP communications. TCP uses a three-way handshake; each way has a specific flag in a TCP packet and a specific source and destination (among the two end point devices involved). When a workstation tries to connect to a website (e.g., https://www.continualintegration.com), the workstation sends a TCP packet with a SYN flag to www.continualintegration.com. Then the server sends a SYN-ACK to the client, and this is the second way. Then the client returns with a TCP packet with an ACK flag to the server, and this is the third way.

To read more, see these:
https://ddos-guard.net/en/terminology/protocols/tcp-3-way-handshake
https://www.techopedia.com/definition/10339/three-way-handshake
What Is The First Way of The Three-Way Handshake?
What Is The Second Way of The Three-Way Handshake?

What Is The Second Way of the Three-Way Handshake?

Question
You want to know discretely what the second way of the three-way handshake is in the context of TCP/IP networking. What is it?

Short Answer
It is the sending of a TCP packet with a flag of "SYN-ACK" from the server/destination to the initiating client (after the first way was completed).

Longer Answer
The second way is sending a TCP packet with the "SYN-ACK" flag (of which several potential flags are possible) to the destination:
Server -----> Client (initiating machine)

TCP is used in HTTP communications. TCP uses a three-way handshake; each way has a specific flag in a TCP packet and a specific source and destination (among the two end point devices involved). When a workstation tries to connect to a website (e.g., https://www.continualintegration.com), the workstation sends a TCP packet with a SYN flag to www.continualintegration.com. Then the server sends a SYN-ACK to the client, and this is the second way.

To read more, see these postings:
https://ddos-guard.net/en/terminology/protocols/tcp-3-way-handshake
https://www.techopedia.com/definition/10339/three-way-handshake
What Is The First Way of the Three-Way Handshake?
What Is The Third Way of the Three-Way Handshake?

What Is The First Way of The Three-Way Handshake?

Question
You want to know discretely what the first way of the three-way handshake is in the context of TCP/IP networking. What is it?

Short Answer
It is the sending of a TCP packet with a flag of "SYN" from the client to the server/destination.

Longer Answer
TCP is used in HTTP communications. TCP uses a three-way handshake; each way has a specific flag in a TCP packet and a specific source and destination (among the two end point devices involved). When a workstation tries to connect to a website (e.g., https://www.continualintegration.com), the workstation sends a TCP packet with a SYN flag to www.continualintegration.com.

The first way is sending a TCP packet with the "SYN" flag (of which several potential flags are possible) to the destination:
Client -----> Server

To read more, see these postings:
https://ddos-guard.net/en/terminology/protocols/tcp-3-way-handshake
https://www.techopedia.com/definition/10339/three-way-handshake
What Is The Second Way of The Three-Way Handshake?
What Is The Third Way of The Three-Way Handshake?

What Does a Colon Mean in Python when You See Something Like This “new_var = a[i:i + counter]”?

Question
You are not familiar with this example of a colon. It appears to be an assignment of a value to itself. You have seen Python function signatures with colons to explain the data type. You have seen colons to signify an if conditional or a for loop. You are not sure what this line of code does:

new_var = a[i:i + counter]

What does this type of colon syntax mean?

Answer
The colon above is not an assignment; the colon in the syntax in the question above is a slice. It is a slice of a list with a starting value "i" (that is inclusive) and a terminating value "i + counter" (that is exclusive). We recommend putting parentheses around the "i + counter" to make it more clear the order of operations.

Here is how we would code the above:

new_var = a[i:(i + counter)]

How Do You Use Python to Find The Latest Prices of Bitcoin, Ethereum, Litecoin and Ripple?

Problem scenario
You want to use Python to calculate the latest price of various cryptocurrencies. What should you do?

Solution
Prerequisite

This assumes you have installed pip.

Procedures
Install the Python package cryptocompare: pip install cryptocompare

Run this program:

import cryptocompare

print(cryptocompare.get_price('BTC', 'USD'))
print(cryptocompare.get_price('BTC', 'USD'))
print(cryptocompare.get_price('ETH', 'USD'))
print(cryptocompare.get_price('LTC', 'USD'))
print(cryptocompare.get_price('XRP', 'USD'))

If you want to receive free cryptocurrency by just learning more, try Coinbase; it is ideal for Americans. For Europeans, the platform/company Iconomi.com can allow you to buy crypto or learn more.

How Do You Solve the Login Prompt Message “Cloud-init…modules:final…Datasource”?

Problem scenario #1
You just installed Linux on a new VM. You boot up your Debian distribution of Linux (e.g., running via Oracle VirtualBox). You see at the login prompt, "cloud-init…running modules:config…DataSourceNone…cc_final_message.py[WARNING]: Used fallback datasource". What should you do?

Problem scenario #2
You recently created a new server. When you boot your Debian/Ubuntu/Mint server, it seems to hang with an error message about "cloud-init cc_final_message_py [warning]: used fallback datasource." What should you do?

Possible Solution #1 (preferred)
Run this command:
sudo touch /etc/cloud/cloud-init.disabled

Possible solution #2 (not recommended, workaround)
Run this command: sudo apt -y remove cloud-init
(This is a workaround. You will no longer have cloud-init. In many cases you will be OK without cloud-init).

Is It a Recommended/Best Practice to Have a Code Freeze?

Problem scenario
You want to have a release. You are concerned that if new code changes are made to the main branch of the relevant repository that the upcoming production release will have a problem. You are not sure if you should allow changes to take place or if should you have a code freeze. Is it a best/recommended practice to have a code freeze going into the release weekend?

Answer
Maybe. It is not clear. For the "Yes" code freezes are recommended:

  • The DevOps Handbook (on page 150) refers to a problem associated with allowing code changes to happen right before a production release; the solution ended up being that only emergency situations would allow for a change to the code close to the production release.
  • This external site explains how a code freeze can help during critical ecommerce shopping days. It says "[a] code freeze is the perfect time to test and optimize to drive higher sales."

For the "No" code freezes are not recommended:

For mixed reviews on code freezes, see these postings:

Is It a Best/Recommended Practice to Check Code in Frequently?

Problem scenario
You read that it was usually a best practice to check code in daily or more frequently to the main branch. Is this always true?

Solution
No, it is not always true. It is advisable to check code in regularly, but you cannot always check code in this frequently.

In some situations a developer would be terminated for checking in code daily. Ideally code should be checked in daily or more frequently than this, but we know every job is different. Journalists and researchers make recommendations, but they are not your employer. It is considered a "fundamental practice" to check code in often (according to page 399 of Continuous Delivery).