diff --git a/.gitignore b/.gitignore index 01589f0..a295864 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *.pyc __pycache__ - diff --git a/PlayGong/gong.wav b/PlayGong/gong.wav deleted file mode 100755 index 8149d5a..0000000 Binary files a/PlayGong/gong.wav and /dev/null differ diff --git a/PlayGong/playgong.py b/PlayGong/playgong.py deleted file mode 100755 index 70fa80d..0000000 --- a/PlayGong/playgong.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python3 - -"""This file is read every hour to signal a break should be made in working.""" - -from playsound import playsound - -playsound("gong.wav") diff --git a/README.md b/README.md deleted file mode 100644 index 323a68f..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# PersonnalScripts -Various personnal scripts to automate stuff diff --git a/SubtitlesUpdater/subtitles_updater.py b/SubtitlesUpdater/subtitles_updater.py deleted file mode 100755 index b486047..0000000 --- a/SubtitlesUpdater/subtitles_updater.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python3 - -"""Script for changing timelines of out-of-sync subtitles.""" - -import argparse -from typing import List, Tuple - - -def main(): - """Create a new file with update timeline, given the offset in seconds.""" - - parser = argparse.ArgumentParser() - parser.add_argument('file', help='file containing the subtitles to update') - parser.add_argument( - 'offset', help='number of seconds to update the file with' - ) - args = parser.parse_args() - file = args.file - offset = int(args.offset) - - output: List[str] = [] - - with open(file, 'r') as subtitles: - for line in subtitles.readlines(): - if '-->' in line: - start: str = line.split(' --> ')[0] - new_start: str = get_new_timeline(start, offset) - - end: str = line.split(' --> ')[1] - new_end: str = get_new_timeline(end, offset) - - new_line: str = "{} --> {}".format(new_start, new_end) - output.append(new_line) - - else: - output.append(line) - - new_file = "UPDATED.{}".format(file) - - with open(new_file, 'w') as newfile: - newfile.write(''.join(output)) - - -def convert_time_to_total_seconds(hrs: int, mns: int, scs: int) -> int: - """Take hours, minutes, seconds, Return total seconds.""" - - minutes: int = hrs * 60 + mns - seconds: int = minutes * 60 + scs - - return seconds - - -def convert_time_to_h_m_s(seconds: int) -> Tuple[int, int, int]: - """Take total seconds, Return hours, minutes, seconds.""" - - minutes: int = seconds // 60 - hours = minutes // 60 - minutes %= 60 - seconds %= 60 - - return hours, minutes, seconds - - -def get_new_timeline(string: str, offset: int) -> str: - """Convert timeline.""" - - hours: str = string.split(':')[0] - minutes: str = string.split(':')[1] - seconds: str = string.split(':')[2].split(',')[0] - milliseconds: str = string.split(',')[1] - - temp_seconds = convert_time_to_total_seconds( - int(hours), int(minutes), int(seconds) - ) - temp_seconds += offset - new_hours, new_minutes, new_seconds = convert_time_to_h_m_s(temp_seconds) - new_h = "{0:02d}".format(new_hours) - new_m = "{0:02d}".format(new_minutes) - new_s = "{0:02d}".format(new_seconds) - - new_string: str = "{}:{}:{},{}".format( - new_h, - new_m, - new_s, - milliseconds - ) - - return new_string - - -if __name__ == '__main__': - main() diff --git a/SubtitlesUpdater/test_subtitles_updater.py b/SubtitlesUpdater/test_subtitles_updater.py deleted file mode 100644 index 80f763d..0000000 --- a/SubtitlesUpdater/test_subtitles_updater.py +++ /dev/null @@ -1,117 +0,0 @@ -"""Tests for the subltitles script.""" - -import unittest -import prog - -class TestScript(unittest.TestCase): - """Test all the elements in the script.""" - - def test_convert_time_to_total_seconds(self): - """Take hours, minutes, seconds, Return total seconds.""" - - seconds = prog.convert_time_to_total_seconds(1, 43, 33) - self.assertEqual(seconds, 6213) - - seconds = prog.convert_time_to_total_seconds(2, 0, 0) - self.assertEqual(seconds, 7200) - - seconds = prog.convert_time_to_total_seconds(2, 59, 59) - self.assertEqual(seconds, 10799) - - def test_convert_time_to_h_m_s(self): - """Take total seconds, Return hours, minutes, seconds.""" - - hours, minutes, seconds = prog.convert_time_to_h_m_s(6213) - self.assertEqual((hours, minutes, seconds), (1, 43, 33)) - hours, minutes, seconds = prog.convert_time_to_h_m_s(7200) - self.assertEqual((hours, minutes, seconds), (2, 0, 0)) - hours, minutes, seconds = prog.convert_time_to_h_m_s(10799) - self.assertEqual((hours, minutes, seconds), (2, 59, 59)) - - def test_offset(self): - """Combine the conversions with an offset in between.""" - - offset: int = -18 - hours: int = 0 - minutes: int = 0 - seconds: int = 36 - - temp_seconds: int = prog.convert_time_to_total_seconds( - hours, minutes, seconds - ) - - temp_seconds += offset - - new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s( - temp_seconds - ) - - self.assertEqual((new_hours, new_minutes, new_seconds), (0, 0, 18)) - - offset: int = -20 - hours: int = 0 - minutes: int = 4 - seconds: int = 5 - - temp_seconds: int = prog.convert_time_to_total_seconds( - hours, minutes, seconds - ) - - temp_seconds += offset - - new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s( - temp_seconds - ) - - self.assertEqual((new_hours, new_minutes, new_seconds), (0, 3, 45)) - - offset: int = 73 - hours: int = 2 - minutes: int = 52 - seconds: int = 50 - - temp_seconds: int = prog.convert_time_to_total_seconds( - hours, minutes, seconds - ) - - temp_seconds += offset - - new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s( - temp_seconds - ) - - self.assertEqual((new_hours, new_minutes, new_seconds), (2, 54, 3)) - - offset: int = 73 - hours: int = 2 - minutes: int = 59 - seconds: int = 49 - - temp_seconds: int = prog.convert_time_to_total_seconds( - hours, minutes, seconds - ) - - temp_seconds += offset - - new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s( - temp_seconds - ) - - self.assertEqual((new_hours, new_minutes, new_seconds), (3, 1, 2)) - - def test_get_timeline(self): - """Correct string is outputted""" - - original_timeline: str = "00:04:05,080" - new_timeline: str = prog.get_new_timeline(original_timeline, -18) - self.assertNotEqual(original_timeline, new_timeline) - self.assertEqual(new_timeline, "00:03:47,080") - - original_timeline: str = "00:04:06,373" - new_timeline: str = prog.get_new_timeline(original_timeline, -29) - self.assertNotEqual(original_timeline, new_timeline) - self.assertEqual(new_timeline, "00:03:37,373") - - -if __name__ == '__main__': - unittest.main() diff --git a/SetupCockpit/arch_based_installs.sh b/arch_based_installs.sh similarity index 100% rename from SetupCockpit/arch_based_installs.sh rename to arch_based_installs.sh diff --git a/SetupCockpit/.bash_aliases b/bash_aliases similarity index 100% rename from SetupCockpit/.bash_aliases rename to bash_aliases diff --git a/SetupCockpit/clone_projects.sh b/clone_projects.sh similarity index 100% rename from SetupCockpit/clone_projects.sh rename to clone_projects.sh diff --git a/SetupCockpit/debian_based_installs.sh b/debian_based_installs.sh similarity index 100% rename from SetupCockpit/debian_based_installs.sh rename to debian_based_installs.sh diff --git a/SetupCockpit/separator.sh b/separator.sh similarity index 100% rename from SetupCockpit/separator.sh rename to separator.sh diff --git a/SetupCockpit/setup_cockpit.sh b/setup_cockpit.sh similarity index 100% rename from SetupCockpit/setup_cockpit.sh rename to setup_cockpit.sh diff --git a/system_info.sh b/system_info.sh deleted file mode 100755 index 1bbd2b9..0000000 --- a/system_info.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# This script will return the following set of system information: - -# - Hostname information: -echo -e "\e[31;43m***** HOSTNAME INFORMATION *****\e[0m" -hostnamectl -echo "" - -# - File system disk space usage: -echo -e "\e[31;43m***** FILE SYSTEM DISK SPACE USAGE *****\e[0m" -df -h -echo "" - -# - Free and used memory in the system: -echo -e "\e[31;43m***** FREE AND USED MEMORY *****\e[0m" -free -echo "" - -# - System uptime and load: -echo -e "\e[31;43m***** SYSTEM UPTIME AND LOAD *****\e[0m" -uptime -echo "" - -# - Logged-in users: -echo -e "\e[31;43m***** CURRENTLY LOGGED-IN USERS *****\e[0m" -who -echo "" - -# - Top 5 processes as far as memory usage is concerned -echo -e "\e[31;43m***** TOP 5 MEMORY-CONSUMING PROCESSES *****\e[0m" -ps -eo %mem,%cpu,comm --sort=-%mem | head -n 6 -echo "" -echo -e "\e[1;32mDone.\e[0m" -