Skip to content

Instantly share code, notes, and snippets.

@AmirAref
AmirAref / config_cinnamon.bash
Last active June 7, 2024 05:40
create backup, restore and see cinnamon desktop configurations
# deCOMPILE and old config
cd
cp /path_to_backup_dconf/user ~/.config/dconf/test
printf %s\\n "user-db:test" > db_profile
DCONF_PROFILE=~/db_profile dconf dump / > old_settings
# remove unused files
rm -f ~/db_profile ~/.config/dconf/test
@AmirAref
AmirAref / merge_softsub.bash
Created October 1, 2022 18:42
merge the movie file and subtitle file to a softsub movie fileby ffmpeg
ffmpeg -i movie_name.mp4 -f srt -i movie_subtitle.srt -c:v copy -c:a copy -c:s mov_text movie_name.SoftSub.mp4
@AmirAref
AmirAref / compressor.sh
Created September 30, 2022 11:56
this is a bash script to compress all directories to their own file by tar
for d in */;
do
tar -cvfz $d > "${d%/}.tar.gz" && echo $d;
done
@AmirAref
AmirAref / movies_folders.py
Created September 15, 2022 15:08
this a simple python script to create folders for movies files and move them to the new fodlers
import os
from glob import glob
from pathlib import Path
import re
import shutil
def main():
# grab movies files
movie_files = [item for item in glob('*.mp4')]
@AmirAref
AmirAref / subtitle.py
Created August 27, 2022 19:22
a simple cli tool to change the subtitle files delay and fix the encoding.
import pysubs2
from optparse import OptionParser
from charset_normalizer import detect
def main():
# parse the options
parser = OptionParser("python %prog [options] --shift 2s FILE.srt")
parser.add_option("-s", "--shift", dest="shift", type=int,
help="shift the subtitle time forward.")
# check the options values
@AmirAref
AmirAref / remove_vurtualenvs.bash
Created July 24, 2022 19:38
a bash script to find and remove the virtualenv folders
find . -wholename '*venv/bin/activate' | awk -F'bin' '{print $1}' | xargs -I '{}' rm -r '{}'
@AmirAref
AmirAref / find_big_files.bash
Created July 24, 2022 19:25
a bash script to find the files bigger than 1 MegaByte
find . -size +1M | xargs -I '{}' ls -sh '{}' | sort -h -k1rn
@AmirAref
AmirAref / YoutubeInfo.py
Last active November 22, 2023 16:03
get the info of videos in youtube by links
from yt_dlp import YoutubeDL
from pandas import DataFrame
def extract_info(urls : list):
# check parameter type
if type(urls) == str:
urls = [urls]
# extract info
data = []
with YoutubeDL({'ignoreerrors':True}) as ytdl:
@AmirAref
AmirAref / product_iterate.py
Created June 14, 2022 06:18
use `itertools` to product all items that possible with some lists
import itertools
# index 1 and 2 always will be one, but the index 1 and 3 will be different (zero or one)
data = [ ['0', '1'], ['1'], ['1'], ['0', '1'] ]
a = itertools.product(*data)
print(list(a))
@AmirAref
AmirAref / convert_m4a_to_mp4.bash
Created June 9, 2022 13:34
a bash script to convert the all m4a files to the mp3 by ffmpeg
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
NC='\033[0m' # No Color]'