К основному контенту

Сообщения

Сообщения за февраль, 2020

Repeat Linux command every x seconds

watch -n 5 "ps -ef | grep COPY" watch -n 10 "psql -U postgres -c \"select clock_timestamp() - query_start as duration, substr(query,1,50) from pg_stat_activity where pid <> pg_backend_pid() and state='active' order by 1 desc\"" for i in {1..10}; do ps -ef | grep COPY; date ; sleep 5; done while true; do ps -ef | grep COPY ; date ; sleep 5; done

Python несколько трюков

(1) Swapping values x, y = 1, 2 print(x, y) x, y = y, x print(x, y) (2) Combining a list of strings into a single one sentence_list = ["my", "name", "is", "George"] sentence_string = " ".join(sentence_list) print(sentence_string) fruits = ['apple', 'mango', 'orange'] print(', '.join(fruits)) numbers = [1, 2, 3, 4, 5] print(', '.join(map(str, numbers))) items = [1, 'apple', 2, 3, 'orange'] print(', '.join(map(str, items))) row = [100, "android", "ios", "blackberry"] print(', '.join(str(x) for x in row)) print(*row, sep=', ') (3) Splitting a string into a list of substrings sentence_string = "my name is George" sentence_string.split() print(sentence_string) (4) Initialising a list filled with some number [0]*1000 # List of 1000 zeros [8.2]*1000 # List of 1000 8.2's (5) Merging dictionaries x...