Skip to content

Instantly share code, notes, and snippets.

@skonik
skonik / upload_to_s3.py
Last active June 3, 2024 16:30
Asyncio S3 Multipart Upload
# Details https://skonik.me/uploading-large-file-to-s3-using-aiobotocore/
import asyncio
import math
import os
import aiobotocore
import aiofiles
AWS_S3_HOST = 'http://localhost:9000'
AWS_SECRET_ACCESS_KEY = 'SECRET_KEY'
@skonik
skonik / .cs
Created January 16, 2020 21:02
Linq GroupJoin
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace tutorials
{
class Customer
@skonik
skonik / vk_bot.py
Last active September 10, 2019 19:05
Python vk meme bot example.
# -*- encoding: utf-8 -*-
import os
import pathlib
from threading import Thread
import requests
import random
import secrets
import uuid
from multiprocessing import Process
@skonik
skonik / python_threads_and_processes.py
Created September 10, 2019 18:53
Python example of using different types of concurrency(without asyncio)
import concurrent.futures
import time
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from datetime import datetime
from functools import wraps
from multiprocessing import Pool, cpu_count, Process
from threading import Thread
import requests
@skonik
skonik / iterator.py
Created September 10, 2019 18:50
Python iterator example
import uuid
# list is iterable
names = ['Elon', 'Guido', 'Bjern']
for name in names:
print(name)
# Elon
# Guido
# Bjern
@skonik
skonik / russian_standards_parsing.py
Last active September 10, 2019 18:38
Python regex example (RU)
import re
text = "ГОСТ Р 54384-2011 - " \
"Сталь. Определение и классификация по химическому составу и ... " \
"ГОСТ 380-94 Сталь углеродистая обыкновенного качества."
gost_pattern = r'(?P<standard_type>гост)\s*(?P<standard_value>[рp]?\s*\d*\d+(?:-\d+)?)'
print(re.findall(gost_pattern, text, re.U + re.I))
# [('ГОСТ', 'Р 54384-2011'), ('ГОСТ', '380-94')]
@skonik
skonik / Dockerfile
Last active September 11, 2019 14:59
python3.6 on alpine with pipenv
FROM alpine:3.10
# Install runtime libs
RUN apk add python3=3.6.8-r2 \
libpq \
libjpeg-turbo
# Enable non buffered output into tty
ENV PYTHONUNBUFFERED 1
# Set default lang