This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark(iters): | |
def actual_decorator(func): | |
import time | |
def wrapper(*args, **kwargs): | |
total = 0 | |
for i in range(iters): | |
start = time.time() | |
return_value = func(*args, **kwargs) | |
end = time.time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark(func): | |
import time | |
def wrapper(*args, **kwargs): | |
start = time.time() | |
return_value = func(*args, **kwargs) | |
end = time.time() | |
print('[*] Время выполнения: {} секунд.'.format(end-start)) | |
return return_value | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT pp.*, p.name | |
FROM product_photo pp | |
left join product p | |
ON p.id = pp.product_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
url = '' | |
async def get_response(url): | |
async with aiohttp.ClientSession() as session: | |
async with session.get(url) as response: | |
# filename = response.content_disposition.filename | |
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git commit -m "prepare for v1.0.0 release" | |
git tag v1.0.0 | |
git push origin master --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# count pattern occurances in text with overlapping | |
import re | |
def pattern_count(pattern, text): | |
return len(re.findall(f"(?={pattern})", text)) | |
print(pattern_count('ATA', 'CGATATATCCATAG')) | |
print(pattern_count('ACTAT', 'ACAACTATGCATACTATCGGGAACTATCCT')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rename files in folder | |
import os, time | |
folder = "./" | |
search_for = "file" | |
replace_to = "test" | |
time.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
def timing(func): | |
def wrapper(*args, **kwargs): | |
start_time = time() | |
result = func(*args, **kwargs) | |
end_time = time() | |
print( | |
f"Время выполнения функции '{func.__name__}' - " | |
f"{round(end_time-start_time, 3)} сек." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sim.nucls <- function(len=100){ | |
# creates fake nucleotides | |
if(is.numeric(len)){ | |
nucls <- c('A','C','G','T') | |
return(paste(sample(nucls,len,TRUE),collapse="")) | |
}else{ | |
print("ERROR: wrong type of input") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 1:100 { | |
prinln(i) | |
} |
NewerOlder