Skip to content

Instantly share code, notes, and snippets.

View MechaDragonX's full-sized avatar

Raghav Vivek MechaDragonX

View GitHub Profile
@MechaDragonX
MechaDragonX / rename_sub_files.py
Last active March 8, 2025 08:07
Messy code to rename a folder of subtitles files from an extrernal source with names akin to the video files in it so they play automatically in MPV or VLC. I have to do this often since I download Japaense language subtitles from Netflix or other sources to match western created rips of anime and movies. The parts of the name cannot be obtained…
import os
dir = os.path.dirname(os.path.realpath(__file__))
print(dir)
before_number_name = input('Please provide file name before number.\nExample: Given "[Sokudo] The Melancholy of Haruhi Suzumiya 2006 - 01 [1080p BD][AV1][dual audio]",\npaste "[Sokudo] The Melancholy of Haruhi Suzumiya 2006 - ": ')
print()
after_number_name = input('Please provide file name after number.\nExample: Given "[Sokudo] The Melancholy of Haruhi Suzumiya 2006 - 01 [1080p BD][AV1][dual audio]",\npaste " [1080p BD][AV1][dual audio]": ')
print()

HashSets

Intro

Before I can talk about HashSets, I need to talk about Sets overall. A Set is a data structure, like ArrayLists (or Lists in some other languages), but like Stacks, Queues, etc., it is considered an Advanced Data Type in (ADT Java. There is an entire class on these data structures in college, and we go into some detail in HL. HL covers the material found in UW's CSE 145, which is considered to be general overview off data structures. That all aside, let's get into the main part of this.

Dictionaries and Key-Value Pairs

I like to explain what a Set is using the concept of a Dictionary in C# and some other languages. This is not how Parker explains it, but it makes a advanced connection easier to grasp (I don't think it's that hard, but it's considered advanced). A Dictionary is declared liked this in C#:

Dictionary dict = new Dictionary();