Problem scenario
Using a web-based email that is powered by roundcube, how do you change the time zone?
Solution
- Log in it.
- Go to Settings -> Preferences -> User Interface -> Time zone
- Change the time zone to your desired preference.
A Technical I.T./DevOps Blog
Problem scenario
Using a web-based email that is powered by roundcube, how do you change the time zone?
Solution
Problem scenario
List operations such as .sort() will change previous copies of the list.
String operations such as .replace("old_pattern", "new_pattern", count), will not change the variable or its copies; these operations will return a string after the replace operation has run on the original string.
Why is this behavior happening?
Solution
In-place changes and mutability are factors. Strings are generally immutable whereas copies of lists are usually shallow.
program1.py shows how lists are mutable with inplace changes happening to a copy; program2.py shows how strings are immutable and have no inplace changes to them when the .replace method is used.
# Filename: program1.py
one_list = ['dog', 'cat', 'horse', 'cow']
print(one_list)
print("Above is one_list before modifications have happened.")
copy_of_list = one_list
one_list.append('hamster')
one_list.sort()
print("The one_list was modified earlier in the execution of this program.")
print(one_list)
print("The one_list is above and the copy_list is below")
print(copy_of_list)
print("The .append and .sort methods change copies of the string in addition to the string itself.")
print("You may want to use deep copies instead of shallow copies if you don't want copies to be modified with the original.")
# Filename: program2.py:
first_string = "aaaaaaaaaaaaaaaaaabcdefgh"
second_string = first_string.replace('a', 'z', -1)
print("The replace method was invoked earlier in the execution of this program.")
print(" ")
print(first_string)
print("first_string is above; second_string is below")
print(second_string)
print("Now you can see how the .replace method only emphemerally returns a string after operating on it.")
print("The .replace method does not change the string it operates on. The operations can be saved to a new variable if you want to use .replace.")
The replace method of a string does not modify the variable it operates on. It returns the modified string. With list manipulations, the copy of the list can be changed (unless you copy like this new_list = old_list[:]).
Problem scenario
You are using Chef and the Kitchen command line tool. If a kitchen command fails, how can you find out the root cause?
Solution
With the command that fails, re-run it with this at the end: --log-level=debug
To learn more about the verbosity of kitchen commands, see this: https://docs.chef.io/workstation/ctl_kitchen/#options
Problem scenario
You are running a Python script. You keep getting "SyntaxError: invalid syntax" and a line number. You can find nothing wrong with the syntax on the specified line number. What do you do?
Possible solution #1
Look at the line with code, as opposed to blank line(s), above it. Is there a missing quote, brace, bracket or parentheses?
Possible solution #2
Are you trying to use an "if" statement on one line? Make sure you have an "else" statement. Without an "else" clause, you can get "SyntaxError: invalid syntax". Here are four lines of code that are minimally correctly written:
f = 5
a = "unique"
x = f
print("scissors" if a == "unique" else "rocks")
# You could try to eliminate the 'else "rocks"' portion and run the program to see the error.
Problem scenario
You have an iCloud, iTunes, iMessage, FaceTime, or some other Apple account online. You want to cancel your account and destroy or delete the data. What do you do?
Solution
1. Log into your Apple.com account (e.g., https://appleid.apple.com/#!&page=signin).
2. Go here: https://privacy.apple.com/
3. Go to "Request to delete your account"
4. Follow the prompts.
To browse Mac products, see this link.
Problem scenario
You want to pass more than one subnet to an "aws eks" command.
You tried to delimit the list with commas (or separate two subnet IDs with commas). You received this error message:
An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The subnet ID 'subnet-0abcd1234,subnet-zyxw9876' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidSubnetID.NotFound; Request ID: Proxy: null)
What should you do?
Solution
Separate the subnet IDs with a space. Here is an example of the correct syntax:
aws eks create-nodegroup --cluster-name coolname --nodegroup-name "variousmachines" --subnets subnet-0abcd1234 subnet-zyxw9876 --node-role arn:aws:iam::<removed>:role/nameofroll --remote-access ec2SshKey=pairname,sourceSecurityGroups=sg-0securitygroup1,sg-0securitygroup2
# It is worth noting that the security groups are passed with commas and no spaces.
# But subnets are passed with spaces and no commas
# If you want to see what security groups you can choose from, run this command:
# aws eks describe-cluster --name contint --query 'cluster.resourcesVpcConfig.securityGroupIds'
# If you want to see what subnets you can choose from, run this command:
# aws eks describe-cluster --name foo --query 'cluster.resourcesVpcConfig.subnetIds'
# If you can remember a pattern in the name of the relevant role (i.e., "foobar"), try a command like this to find the exact IAM role:
# aws iam list-roles | grep -i foobar
Problem scenario
You have read about the Google Datastore and Google Firestore. But you do not know the differences. What are they?
Solution
Go here.
Problem scenario
You want each line of a file to have a prefix or suffix attached. How do you print out this combination of a fixed string with each individual line of the file?
Solution
cat foobar.txt | awk '{ print "prefix" $1 "suffix" }'
Question
Normally when you use the man page, you just type man nameofcommand. But you have seen integer numbers between 1 and 9 (inclusive) between the "man" and the command's name. What do those numbers signify?
Answer
This legend was taken from "man man" on a Linux server:
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
Problem scenario
You have a list in Python that you copy into another variable. You change the original list and the copied version changes. Why does the copied version get copied and what can you do to overcome this?
Solution
There is something called a "deep" copy and a "shallow" copy. This program will illustrate both the problem and the solution:
list_a = [3, 6, 7]
list_b = list_a
list_c = list_a[:]
list_a.append(4)
print(list_b)
print("list_b, a shallow copy, is above; list_a is below")
print(list_a)
print("a different copy of list_a is below")
print(list_c)
For more information, read the following links: StackOverflow.com and geeksforgeeks.com.