Skip to content

Instantly share code, notes, and snippets.

@eminorhan
eminorhan / make_mp4.py
Created August 30, 2023 06:33
make mp4 files from a directory of subdirectories of sequences of png files
import os
import cv2
def create_video_from_pngs(png_folder, output_filepath, frame_rate):
real_png_folder = os.path.join(png_folder, 'imgs')
images = sorted([img for img in os.listdir(real_png_folder) if img.endswith(".png")])
frame = cv2.imread(os.path.join(real_png_folder, images[0]))
height, width, layers = frame.shape
output_filename = os.path.join(output_filepath, f"{os.path.basename(png_folder)}.mp4")
@eminorhan
eminorhan / split_video.sh
Created June 4, 2023 22:08
crop bottom 90 px, turn upside down, split it into 1 min clips
module load ffmpeg/4.2.4
for file in S/*.mp4; do
ffmpeg -i "$file" -vf "crop=in_w:in_h-90,rotate=PI" -codec:v libx264 -codec:a copy -f segment -segment_time 60 -reset_timestamps 1 -map 0 "minute/${file%.mp4}_segment%d.mp4"
done
@eminorhan
eminorhan / bash_for.sh
Last active January 23, 2023 22:45
bash for loop example
for i in 1 3 4 9 11 cat 89 dog 102; do
# commands to be executed go here
echo $i
done
# this will print all the items in the for loop, numbers as well as strings
@eminorhan
eminorhan / main.tex
Created December 12, 2022 00:34
latex pretty paper template
\documentclass[12pt,a4paper]{article}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{setspace}
\usepackage{geometry}
\usepackage{color}
@eminorhan
eminorhan / ez_mv_inline.sh
Last active October 11, 2022 15:36
inline easy move dirs demo
for X in {1..50} ; do mv s2/o$X/* o$X/ ; mv s3/o$X/* o$X/ ; mv s4/o$X/* o$X/ ; mv s5/o$X/* o$X/ ; mv s6/o$X/* o$X/ ; done &
@eminorhan
eminorhan / count_in_tar.sh
Created September 29, 2022 18:06
count number of files in a tar archive without extracting
tar -tf archive.tar | wc -l
@eminorhan
eminorhan / prettify.sty
Last active November 4, 2022 03:34
prettify hyperlinks in latex
\usepackage{hyperref}
\usepackage{xcolor}
\hypersetup{
colorlinks,
linkcolor={red!50!black},
citecolor={blue!50!black},
urlcolor={blue!80!black}
}
@eminorhan
eminorhan / nohup2.sh
Created June 21, 2022 00:22
pipe nohup output to a file with given name instead of deault nohup.out
nohup python -u script.py &> nohup2.out &
@eminorhan
eminorhan / git_repo.sh
Created March 2, 2022 22:07
new github repo
git init
git add . && git commit -m "first commit"
git remote add origin REMOTE_GITHUB_REPO_URL
git remote -v
git push origin master
@eminorhan
eminorhan / count_files.sh
Created February 9, 2022 17:58
count files in current directory
ls -1 | wc -l