| import concurrent.futures | |
| import time | |
| start = time.perf_counter() | |
| def do_something(seconds): | |
| print(f'Sleeping {seconds} second(s)...') | |
| time.sleep(seconds) | |
| return f'Done Sleeping...{seconds}' | |
| with concurrent.futures.ProcessPoolExecutor() as executor: | |
| secs = [5, 4, 3, 2, 1] | |
| results = executor.map(do_something, secs) | |
| # for result in results: | |
| # print(result) | |
| finish = time.perf_counter() | |
| print(f'Finished in {round(finish-start, 2)} second(s)') |
Wednesday, 15 April 2020
Python Multiprocessing : Run Code in Parallel Using the Multiprocessing Module
Python Threading : Run Code Concurrently Using the Threading Module
import concurrent.futures
import time
start = time.perf_counter()
def do_something(seconds):
print(f'Sleeping {seconds} second(s)...')
time.sleep(seconds)
return f'Done Sleeping...{seconds}'
with concurrent.futures.ThreadPoolExecutor() as executor:
secs = [5, 4, 3, 2, 1]
results = executor.map(do_something, secs)
# for result in results:
# print(result)
# threads = []
# for _ in range(10):
# t = threading.Thread(target=do_something, args=[1.5])
# t.start()
# threads.append(t)
# for thread in threads:
# thread.join()
finish = time.perf_counter()
print(f'Finished in {round(finish-start, 2)} second(s)')
Monday, 13 April 2020
Ansible to convert extra variable into lowercase or uppercase
{{ ansible_var | lower }}
{{ ansible_var | upper }}
Thursday, 9 April 2020
python Math Function
import math
def sin(x):
if 2 * x == pi:
return 0.99999999
else:
return None
pi = 3.14
print(sin(pi/2))
print(math.sin(math.pi/2))
Thursday, 26 March 2020
Python Pandas to read excel .csv file and get all values under specific column and skip null value
import os
from selenium import webdriver
import time
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
df = pd.read_csv(r"xxx.csv")
queue = df["Messages"].dropna().tolist()
print (queue)
Tuesday, 10 March 2020
Python Pandas to read excel .csv file and get all values under specific column
import os
from selenium import webdriver
import time
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
df = pd.read_csv(r"xxx.csv")
queue = df["Messages"].tolist()
print (queue)
powershell script to trigger message in slack using web hock
$uriSlack = "URL"
$body = ConvertTo-Json @{
pretext = "test"
text = "test"
color = "#142954"
}
try {
Invoke-RestMethod -uri $uriSlack -Method Post -body $body -ContentType 'application/json' | Out-Null
} catch {
Write-Error (Get-Date) ": Update to Slack went wrong..."
}
Subscribe to:
Comments (Atom)
Git
1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...
-
https://github.com/crossplane-contrib
-
https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html
-
awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \ <(grep 'cpu ...