Skip to content

Instantly share code, notes, and snippets.

View ecatanzani's full-sized avatar
🎯
Focusing

Enrico Catanzani ecatanzani

🎯
Focusing
View GitHub Profile
@ecatanzani
ecatanzani / latex.py
Last active January 2, 2023 15:59
LaTeX AutoImager
import os
import math
import shutil
import argparse
def buildTEX(
lc_files: list,
output_tex_file: str,
nr: int = 4,
nc: int = 4,
@ecatanzani
ecatanzani / reader.py
Created November 24, 2022 18:33
ffmpeg video reader - test
import cv2
import numpy
import subprocess as sp
def get_video_info(video_file):
cap = cv2.VideoCapture(video_file)
framerate = cap.get(5) #frame rate
# Get resolution of input video
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
@ecatanzani
ecatanzani / find_files.py
Created October 12, 2022 16:17
utility to find files
import os
from glob import glob
import multiprocessing as mp
keywords = ['argparse']
main_folder = 'path_to_main_folder'
py_files = []
if os.path.isdir(main_folder):
@ecatanzani
ecatanzani / size.py
Created May 27, 2022 08:23
sub-directory file size - recursive
import os
mb_scale_factor: float = pow(1024, 2) # If you want result expressed in MB
def get_dir_size(path: str) -> float:
total: int = 0
with os.scandir(path) as it:
for entry in it:
if entry.is_file():
total += entry.stat().st_size
@ecatanzani
ecatanzani / testData.py
Created February 17, 2021 13:43
ROOT DATA file check
#!/usr/bin/env python3
from argparse import ArgumentParser
from ROOT import TFile
def TestROOTFile(path: str = "") -> bool:
_tmp_file = TFile(path)
if _tmp_file and not _tmp_file.IsOpen():
return False
elif _tmp_file and _tmp_file.IsOpen() and _tmp_file.IsZombie():
@ecatanzani
ecatanzani / file_check.sh
Created October 19, 2020 07:28
Check empty files in list
#!/usr/bin/env bash
_LIST=$1
echo "Reading files in ${_LIST}"
while IFS="" read -r line || [ -n "${line}" ]
do
if [[ -s ${line} ]]; then echo "${line}: NOT EMPTY"; else echo "${line}: EMPTY"; fi
cat ${line} >> test_if_empty.txt
done < ${_LIST}
@ecatanzani
ecatanzani / sHosts.py
Created August 31, 2019 15:20
Remote hosts viewer
import subprocess
import os
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
@ecatanzani
ecatanzani / builder.sh
Last active November 14, 2018 10:32
Docker based compiler
#!/usr/bin/env bash
SOURCE="$1"
EXITPATH="$2"
FILE=${SOURCE##*/}
BASE=${FILE%.*}
echo -e "\e[31mReaching tmp dir...\e[0m"
cd /tmp &&
@ecatanzani
ecatanzani / eSender.py
Last active July 13, 2018 05:35
Simple notification emailer with Python
# Simple email notification sender
# Developed by Enrico Catanzani
# Release 3.2
#!/usr/bin/python3
import smtplib
import os.path as op
from email.mime.multipart import MIMEMultipart