Skip to content

Instantly share code, notes, and snippets.

View nalaekaw's full-sized avatar
🌮
I'm eating a taco

Nala Ekaw nalaekaw

🌮
I'm eating a taco
  • Dubai
View GitHub Profile
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()
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
SELECT pp.*, p.name
FROM product_photo pp
left join product p
ON p.id = pp.product_id;
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)
git commit -m "prepare for v1.0.0 release"
git tag v1.0.0
git push origin master --tags
@nalaekaw
nalaekaw / pattern_count.txt
Last active December 17, 2021 02:52
Count pattern occurances in text with overlapping
# 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'))
@nalaekaw
nalaekaw / files-rename tool
Last active November 7, 2021 04:25
Tool for remaming files using python
# rename files in folder
import os, time
folder = "./"
search_for = "file"
replace_to = "test"
time.sleep(2)
@nalaekaw
nalaekaw / timing.txt
Last active October 28, 2021 05:36
Decorator - Execution time of a function
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)} сек."
@nalaekaw
nalaekaw / sim_nucls
Last active October 1, 2021 09:23
R function to sumulate DNA sequence
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")
}
}
for i in 1:100 {
prinln(i)
}