Skip to content

Instantly share code, notes, and snippets.

View alexeygrigorev's full-sized avatar
:octocat:
Githubbing

Alexey Grigorev alexeygrigorev

:octocat:
Githubbing
View GitHub Profile
@alexeygrigorev
alexeygrigorev / _cutting-mp4-files.md
Last active February 14, 2021 11:49
Cutting videos with FFMpeg

Cutting videos with FFMpeg without re-encoding

Here's how you use it:

./cut.sh conf2.mp4 out1.mp4 00:00:05 00:53:47
def make_batches(seq, n):
result = []
for i in range(0, len(seq), n):
batch = seq[i:i+n]
result.append(batch)
return result
@alexeygrigorev
alexeygrigorev / progress.py
Last active September 26, 2025 19:47
A function for parallel map with tqdm
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdm
num_threads = 4
pool = ThreadPoolExecutor(max_workers=6)
def map_progress(pool, seq, f):
results = []
@alexeygrigorev
alexeygrigorev / get-winners.py
Last active June 4, 2021 15:12
Running giveaway campaigns on twitter
from glob import glob
from random import shuffle
import requests
coupon_codes = [
'mlbookcamp-1',
'mlbookcamp-2',
'mlbookcamp-3',
'mlbookcamp-4',
@alexeygrigorev
alexeygrigorev / Dockerfile
Created February 15, 2019 12:53
Build libwebp for aws lambda
FROM amazonlinux:2017.03
RUN yum -y install git \
python36 \
python36-pip \
python36-devel \
zip \
gcc \
gcc-c++ \
cmake \
@alexeygrigorev
alexeygrigorev / tqdm_pool.py
Created December 6, 2018 15:36
Track progress of ProcessPoolExecutor with tqdm
from glob import glob
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
import cv2
from PIL import Image
import imagehash
from tqdm import tqdm
@alexeygrigorev
alexeygrigorev / create_python_files.sh
Last active August 16, 2022 15:34
tf.make_tensor_proto
pip install grpcio-tools
wget https://github.com/tensorflow/tensorflow/archive/v1.9.0.zip -O tf-190.zip
unzip tf-190.zip && rm tf-190.zip
wget https://github.com/tensorflow/serving/archive/1.9.0.zip -O tf-serving-190.zip
unzip tf-serving-190.zip && rm tf-serving-190.zip
mv serving-1.9.0/tensorflow_serving tensorflow-1.9.0
@alexeygrigorev
alexeygrigorev / cloudwatch_logs_capturer.py
Created July 18, 2018 12:55
Capturing stdout and sending it to cloudwatch logs
import sys
import time
import threading
from io import StringIO
from multiprocessing import Process
from queue import Queue
import boto3
from botocore.exceptions import ClientError
@alexeygrigorev
alexeygrigorev / mp_capture.py
Created July 16, 2018 08:35
Python stdout sharing between chind & parent processes
import sys
import time
from io import StringIO
import subprocess
from multiprocessing import Process, Pipe
from threading import Thread
@alexeygrigorev
alexeygrigorev / BeanToRecordConverter.java
Created January 17, 2018 13:45
Use reflection to write arbitrary java beans to parquet with Avro
package avro;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.reflect.ReflectData;
import java.util.ArrayList;
import java.util.List;