Discover instance ID using wget or curl:
wget -q -O - http://169.254.169.254/latest/meta-data/instance-id
curl http://169.254.169.254/latest/meta-data/instance-id
Considering cell G4 is the target:
=(LEN(G4)-LEN(SUBSTITUTE(G4;"search";"")))/LEN("search")
Generating an UUID4 using query:
SELECT LOWER(CONCAT(
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'),
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-',
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-',
'4',
LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-',
HEX(FLOOR(RAND() * 4 + 8)),
LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-',
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'),
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'),
LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0')))\c postgres;
CREATE USER "full.name" WITH PASSWORD 'letmein';
ALTER ROLE "full.name" WITH LOGIN;
GRANT bi_users TO "full.name";
GRANT "outro.user" TO "full.name";Update a secret
kubectl create secret generic production-tls \
--from-file=./tls.key --from-file=./tls.crt --dry-run -o yaml | \
kubectl apply -f -Check if a file exists:
import os.path
os.path.isfile(fname)arr = [1,2,3]
# Add elements
arr.append(4)
arr.append(4)
# Get the number of unique elements
uniques = set(arr)Python copies object by reference. Use copy() if you need a local copy:
oldDict = {"a": False}
newDict = oldDict.copy()
newdict["a"] = TrueGet and remove an element from the dictionary:
d = {'a': 10, 'b': 20, 'c': 30}
d.pop('b') #20
d # {'a': 10, 'c': 30}Substrings:
string = "Hello"
string[:2] # 'He'
string[2:] # 'llo'
string[-1:] # 'o'Create a requirements.txt file:
pip freeze > requirements.txt