Skip to content

Instantly share code, notes, and snippets.

@manero6
manero6 / Vagrantfile
Created March 29, 2021 17:25
Vagrant Fedora all Spins (LibVirt and VirtualBox)
# -*- mode: ruby -*-
# vi: set ft=ruby :
VM_BOX = ENV["VM_BOX"] || "fedora/33-cloud-base"
VM_RAM = ENV["VM_RAM"] || "1536"
VM_CPU = ENV["VM_CPU"] || "2"
### Fedora Spins -> https://spins.fedoraproject.org
spins = %w(
gnome
@manero6
manero6 / script.py
Last active March 23, 2022 09:07
The parent_directory function returns the name of the directory that's located just above the current working directory. Remember that '..' is a relative path alias that means "go up to the parent directory". Fill in the gaps to complete this function.
import os
def parent_directory():
# Create a relative path to the parent
# of the current working directory
relative_parent = os.path.join("..")
# Return the absolute path of the parent directory
return os.path.abspath(relative_parent)
print(parent_directory())
@manero6
manero6 / ffmpeg2x265.sh
Last active May 23, 2022 20:01
Re-encode videos to x265 with ffmpeg
if [ $# -ne 0 ]
then
for VIDEO in "$@"
do
VIDEO_NAME=$(echo "$VIDEO" | cut -d. -f1)
VIDEO_x265="$VIDEO_NAME".x265.mp4
ffmpeg -i "$VIDEO" -c:v libx265 "$VIDEO_x265" \
&& RESULT="$RESULT$(\
echo "Successfully converted -> $VIDEO_NAME" && \
echo " original: %2s $(ls -lh "$VIDEO" | cut -d' ' -f5)" && \
@manero6
manero6 / ffmpeg-bestcrop.py
Last active October 9, 2023 10:49
Run cropdetect and print 10 most detected crops
#!/usr/bin/env python3
import re
import sys
import subprocess
try:
file_to_crop = sys.argv[1]
except:
print("Please provide a video file.")
@manero6
manero6 / ffmpeg-list4concat.sh
Last active September 28, 2023 15:53
Bash script to create a formatted list to be used when concatenating with FFmpeg
#!/bin/bash
if [ $# = 1 ]
then
LIST=`ls | grep -i "$1" | sed -e "s/^/file '/" -e "s/$/'/"`
if [[ -f list ]]
then
read -p "Do you want to overwrite the already existing 'list' file? (y/N) " yn
case $yn in
[yY]* ) echo -e "\nOverwriting already existing 'list' file with the following content:\n"
@manero6
manero6 / hours2seconds
Last active October 19, 2023 09:19
Simple bash script to calculate total seconds from hours, minutes and seconds
#!/bin/bash
HOU=0
MIN=0
SEC=0
if [[ $# -ge 4 ]]
then
echo "Please provide from 0 to a maximum of 3 arguments"
exit 1
@manero6
manero6 / zip2m3u
Last active October 18, 2022 07:09
Create .m3u playlist for multi-disc games (unzip .bin/.cue, create .chd files, create .m3u playlist)
#!/bin/bash
IFS=$'\n'
ARGUMENTS=$#
GAME_ZIP="$1"
GAME_NOZIP="${GAME_ZIP%.zip}"
GAME_NODISC="${GAME_NOZIP% *isc*}"
GAME_DIR=$GAME_NODISC
DISC=1
@manero6
manero6 / speedtest-loop.sh
Last active September 21, 2023 09:41
Speedtest-cli loop printing only download and upload rates
#!/bin/bash
for ((COUNTER=1; COUNTER>0; COUNTER++))
do
echo "$(date +%c) => Test nr: $COUNTER" && \
speedtest-cli 2>/dev/null | grep -E "^Download|^Upload"
done
@manero6
manero6 / clip-cleaner.sh
Last active October 19, 2023 09:17
simple script based on xclip to filter out stuff from the clipboard
#!/bin/bash
# put current clipboard in a variable
XCLIP_CLIPBOARD="$(xclip -o -selection clipboard)"
XCLIP_SELECTION=$XCLIP_CLIPBOARD
if [ $# -ge 1 ]
then
# print the initial string aka the current clipboard
echo "=> 1st string: $XCLIP_CLIPBOARD"
@manero6
manero6 / yt-dlp-mkdir.sh
Last active September 28, 2023 15:42
download with yt-dlp in a new directory that gets its name from the last part of the given URL
#!/bin/bash
ROOT_DIRECTORY=`basename "$(pwd)"`
ARGUMENTS_NR=$#
ARGUMENTS=$@
yt-dlp-mkdir () {
for i in $ARGUMENTS
do
declare -a DIRECTORY="(`basename $i | tr "-" " "`)"