Using Python How Do You Convert Each Line to Be an Item in a List?

Problem scenario
You have a multi-line variable in Python. You want to convert each line to be its own item in a list. How do you make a multi-line string variable to become a list with the same contents?

Solution
Use the .splitlines() method to manipulate the string in this way.

Here is an example:

list_of_input="""a line here
another line there.
123 abc"""

print(type(list_of_input))
print("Now we convert…")
list_of_input = list(list_of_input.splitlines())
print(type(list_of_input))
print(list_of_input)

How Do You Troubleshoot the Cargo Problem “error[E0658]: use of unstable library feature ‘str_strip’: newly added”?

Problem scenario
You run a cargo command. You get this error:

error[E0658]: use of unstable library feature 'str_strip': newly added
--> /home/jdoe/.cargo/registry/src/github.com-1ecc6299db9ec823/ethbloom-0.10.0/src/lib.rs:69:1
|
69 | / construct_fixed_hash! {
70 | | /// Bloom hash type with 256 bytes (2048 bits) size.
71 | | pub struct Bloom(BLOOM_SIZE);
72 | | }
| |_^
|
= note: see issue #67302 https://github.com/rust-lang/rust/issues/67302 for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try rustc --explain E0658.
error: could not compile ethbloom.

What should you do?

Possible solution
Run this command: rustc --version

Is it 1.45.0 or higher?

Remove rustc. If you are using a Debian/Ubuntu distribution of Linux, run this: sudo apt -y remove rustc

Reinstall rustc with this: sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

(This solution was taken from https://github.com/ogham/dog/issues/26 .)


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

Using a Debian/Ubuntu Distribution of Linux, How Do You Install kubeadm, kubectl, and/or kubelet?

Problem scenario
Using a Debian/Ubuntu distribution of Linux, how do you install kubeadm, kubectl, and/or kubelet?

You want to install kubeadm, kubectl or kubelet (without retrieving the binary of the file from a website and do a regular installation). What do you do?

Solution
Here is another way to install kubectl, kubelet and kubeadm:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt-get -y install kubeadm kubelet kubectl

(If you can download a file from the internet and want to avoid using apt commands, see these links to install kubeadm, kubelet, and kubectl.)

How Do You Find the Menu Option, Button or Feature for an Application in MacOS?

Problem scenario
You are using a familiar application on a Mac. You cannot find a basic command button or menu option. What should you do?

Solution
At the very top of your screen, outside of the application itself, there is a ribbon. There should be drop down menu options specific for the application.

We find that some problems are caused because of time pressure. You may want to read about stress-management or patience. In some cases, you may need to find a new employer (that has reasonable expectations for productivity).

To browse Mac products, see this link.

How Do You Get Both MapReduce Jobs and hadoop CLI Commands to Work Simultaneously without Alternately Changing an XML File Before Each One?

Problem scenario
Hadoop is not working correctly. You can get either a mapreduce job to work or a "hadoop" CLI command to work. But neither work unless you change an .XML file in between each operation.

Map Reduce jobs, when they are failing (and the Hadoop commands are working), there may be an error like this:

2021-01-01 22:47:42,337 INFO mapreduce.Job: Task Id : attempt_1609558624072_0001_m_000003_1, Status : FAILED
Container launch failed for container_1609558624072_0001_01_000008 : org.apache.hadoop.yarn.exceptions.InvalidAuxServiceException: The auxService:mapreduce_shuffle does not exist
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

When the Hadoop jobs are failing (and the Map Reduce jobs are working), there may be an error like this:

Exception in thread "main" java.lang.NullPointerException
at org.apache.hadoop.mapreduce.tools.CLI.displayJobList(CLI.java:784)
at org.apache.hadoop.mapreduce.tools.CLI.displayJobList(CLI.java:769)
at org.apache.hadoop.mapreduce.tools.CLI.listAllJobs(CLI.java:697)
at org.apache.hadoop.mapreduce.tools.CLI.run(CLI.java:428)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:90)
at org.apache.hadoop.mapred.JobClient.main(JobClient.java:1277)

You make changes to a yarn-site.xml file and try one of the jobs. They work alternately. You see that the changes take effect when you run a map reduce job and separately a hadoop command to view the jobs. Either the map reduce job will work or the hadoop command will work. Both will not work unless you make changes to the yarn-site.xml. You have to change the yarn-site.xml file each time before issuing one of the commands. You know you don't need to restart anything because you get different behavior as soon as you make changes to the yarn-site.xml. How do you get both to work simultaneously?

Solution
Restart DFS and YARN servcices. Use stop-dfs.sh and stop-yarn.sh scripts. Then use start-dfs.sh and start-yarn.sh scripts.

You must restart the DFS and YARN services. Yes, you see different behavior immediately after changing the yarn-site.xml or mapred-site.xml files. However, for the changes to take full effect, you must restart the services. Then both the mapreduce jobs and the hadoop CLI commands will work.

How Do You Solve “Could not find foobar in any of the sources” after a bundle Command?

Problem scenario
You run a bundle command (e.g., bundle exec foobar create). It fails with an error such as "Could not find foobar in any of the sources".

What should you do?

Solution
Remove the relevant Gemfile.lock file (e.g., in the directory you are running bundle) if you are allowed to. Are you using a variety of bundle commands? Each one could create a Gemfile.lock file so be aware of this. To learn more about the basics of bundle, see this.

If you cannot delete the Gemfile.lock file, try this external posting.

What Does the “^” Operator in Python Do?

Problem scenario
In Python you try operations like these two:

5 ^ 6
9 ^ 10

Both return "3". Why is this?

Solution
The exclusive or (aka XOR) symbol "^" "copies the bit if it is set in one operand but not both." (Taken from https://www.tutorialspoint.com/python/python_basic_operators.htm)

Here are some integers with their binary representation one space away:

3 11

5 101
6 110

9 1001
10 1010

5 is represented as 101. 6 is represented as 110. The 1 is set in the middle and right-most position of the binary values. Thus it returns a 3 which is associated with "11" in binary notation.

7 ^ 8 returns 15. 15 in binary notation is 1111.

7 111
8 1000

If we remember that ^ "copies the bit if it is set in one operand but not both." (taken from https://www.tutorialspoint.com/python/python_basic_operators.htm), we would expect it to return 1111. The integer equivalent of 1111 is "15".

To view more binary equivalents, see this https://www.convertbinary.com/numbers/.

How Do You Connect over Port 5986 on a Windows Server?

Problem scenario
Port 5986 is blocked from your Linux server to your Windows server. You have used the nmap command and see that it is filtered. You believe there are no intermediate firewalls or OS firewalls blocking this port. What should you do?

Solution
This assumes you have no firewall blocking port 5986 for incoming connections to the Windows server. nmap will report 5986 is filtered despite there being nothing blocking this port if wsman's listener has not been properly configured.*

  1. Run this script on the Windows server:
$hostName = $env:COMPUTERNAME
$serverCert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $hostName
Export-Certificate -Cert $serverCert -FilePath c:\vagrant\PsRemoting-Cert1.cer
Get-ChildItem c:\vagrant\PsRemoting-Cert1.cer
Enable-PSRemoting -Force
New-Item -Path WSMan:\localhost\Listener\ -Transport HTTPS -Address * -CertificateThumbPrint $serverCert.Thumbprint -Force
  1. That is it. SSL termination will not be done unless you configure it. You may need to bypass ssl-verification. But connectivity over port 5986 is not achievable.

* When winrm over HTTPS is not configured, port 5986 can show as filtered in the nmap results. This is contrary to the definition of filtered on the nmap page: "Filtered means that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed."

How Do You Install Incubed (in3) for Bash?

Problem scenario
You want to do Blockchain development with Ethereum using Bash. How do you install Incubed (in3) for Bash on a Debian distribution of Linux (such as Ubuntu or Linux Mint)?

Solution
Run these commands:

sudo apt -y update
sudo apt-get -y install software-properties-common
sudo add-apt-repository ppa:devops-slock-it/in3
sudo apt -y install jq in3 in3-dev

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

How Do You Troubleshoot the AWS Error “Subnets specified must be in at least two different AZs”?

Problem scenario
You run an AWS CLI command, but you get this error message:
"An error occurred (InvalidParameterException) when calling the CreateCluster operation: Subnets specified must be in at least two different AZs"
How do you find subnets in different availability zones?

Solution
Run commands such as these (but replace the "us-west-x" and "us-east-x" with the availability zones that you use):

aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-west-1a]'
aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-west-1b]'
aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-west-1c]'
aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-east-2a]'
aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-east-2b]'
aws ec2 describe-subnets --query 'Subnets[?AvailabilityZone==us-east-2c]'

Now you will see more subnet IDs for your original command. You can supply that original command accordingly and re-run it successfully.