Skip to content

Instantly share code, notes, and snippets.

View nazarovsky's full-sized avatar

Alexander Nazarovsky nazarovsky

View GitHub Profile
# script is used to send keyboard strokes WASD (2 sec) to run in circles in LEGO FORTINTE
# after 40 times it presses F5 to eat some food (bind this to USE and select slot with FOOD in interface)
import ctypes
from ctypes import wintypes
import time
from time import sleep
import random
user32 = ctypes.WinDLL('user32', use_last_error=True)
@nazarovsky
nazarovsky / apply_curves.py
Created October 17, 2022 06:21
apply_curves
from struct import unpack
from scipy import interpolate
from PIL import Image
import numpy
import scipy
import sys
class Filter:
@nazarovsky
nazarovsky / docin-dl.py
Last active October 17, 2022 06:21 — forked from drelatgithub/docin-dl.py
Docin document downloader
###############################################################################
#
# Docin document downloader
#
# Valid as of 2022-16-08
#
###############################################################################
import argparse
import os
from types import SimpleNamespace
@nazarovsky
nazarovsky / running_block_mean_and_std
Created March 30, 2022 20:35
Calculate mean and var values for all images in the folder by combining mean and var of individual images
# variance calculation algorithm for two datasets of different lengths is taken from
# Chan, Tony F.; Golub, Gene H.; LeVeque, Randall J. (1979), "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances." (PDF), Technical Report STAN-CS-79-773, Department of Computer Science, Stanford University.
# http://i.stanford.edu/pub/cstr/reports/cs/tr/79/773/CS-TR-79-773.pdf
import os, sys
import numpy as np
import tifffile as tiff # pip install tifffile
TIF_FOLDER = 'img'
EXT = '.tiff'
@nazarovsky
nazarovsky / ETTreader.m
Created April 16, 2021 11:35
Matlab script to read Electricity Transformer Dataset (ETDataset) https://github.com/zhouhaoyi/ETDataset
% script to read https://github.com/zhouhaoyi/ETDataset
clear all; clc;
fileName = 'ETTm1.csv';
fileID = fopen(fileName);
C = textscan(fileID,'%s %f %f %f %f %f %f %f %f %f', 'HeaderLines',1, 'Delimiter',',');
fclose(fileID);
A = cell2mat(C(:,2:7));
T = datetime(cell2mat(C{1}) , 'InputFormat','yyyy-MM-dd HH:mm:ss');
OT = cell2mat(C(:,8));
@nazarovsky
nazarovsky / make_images.py
Created November 19, 2019 10:34
make image frames from video
# cuts video to frames with defined stepsize
import numpy as np
import cv2
import os, sys, glob
from pathlib import Path
from argparse import ArgumentParser
DEFAULT_VIDEO_FNAME = Path('_input/saved_utv_8_1.mkv')
@nazarovsky
nazarovsky / ffmpeg_to_gif
Created September 3, 2019 10:39
ffmpeg: cut segment, convert into gif and integrate subtitles
Ms.avi = Avengers: Infinity war
ffmpeg -ss 2:11:55 -i Ms.avi -r 1/1 Palette.png
ffmpeg -y -ss 2:11:38 -t 43 -i Ms.avi -filter_complex "fps=8,scale=420:-1:flags=lanczos,subtitles=Ms.srt:force_style='Fontsize=32',palettegen" palette.png
ffmpeg -y -ss 2:11:38 -t 43 -i Ms.avi -i palette.png -filter_complex "fps=8,scale=420:-1:flags=lanczos,subtitles=Ms.srt:force_style='Fontsize=32'[x];[x][1:v]paletteuse" output.gif
Ms.srt
0
00:00:06,300 --> 00:00:07,800
МУЦАРАЕВА ВКЛЮЧИ