Posts

Reminder

 Simple program that takes in a certain amount of hours, minutes and seconds, then a description of the notification to ping the user with after that amount of time has passed. Makes use of the modules time and the previous module used, win10toast. import time from win10toast import ToastNotifier print ( "This program will send a windows notification after a given amount of time." ) hours = int ( input ( "Enter hours: " )) minutes = int ( input ( "Enter minutes: " )) seconds = int ( input ( "Enter seconds: " )) description = input ( "Enter your description of the reminder: " ) toast = ToastNotifier() total_time = seconds + minutes * 60 + hours * 3600 time.sleep(total_time) toast.show_toast( "Reminder" , description , icon_path = r"C:\Users\Conan\Desktop\rand\36466-200.ico" )

Toast notifications

Image
 The previous project required windows notifications, so that it can ping me with new manga releases. I couldn't get the log in thing from the previous project working, but I'll at least get this running for now. The title and description part was simple enough, as it's just strings that I can change into whatever I want. The icon was a little more difficult as I have to enter the path of the image, and the image specifically has to be in ico file format. The next thing to worry about is having the program run in the background, without an active window. Looked it up, and apparently I have to place the shebang in the front so python knows which version and virtual environment it should use, and some other thing I'll do tomorrow. #!/usr/bin/env python3 import time from win10toast import ToastNotifier toast = ToastNotifier() while True : toast.show_toast( "Sample notificaiton" , "sample description" , icon_path = r"C:\Users\Conan\Desktop\rand\...

Mangadex

 I use mangadex pretty much daily to read manga and stuff, and recently I found out that I constantly go on it every now and then to check if there was an update on anything I read. So I decided to write a script that goes and checks my following list and gives me a notification when there is an update. It didn't work out. Using the requests module again, I tried just doing it off the bat, which didn't work because it required me to log in first of all. I thought that I'll just log in and that'll be that. How foolish I was.  So, usually, if you want to log in, you send a post request to the login page of said website, which contains the username and password of the account you want to log in as. You do this by creating a session, which will retain the cookies used for logging in, which I wanted so that I can refresh the page every few minutes without logging in again. So you go to the website and find the <input> tag's names and put them in a dictionary like s...

Find (Ctrl + F)

Just like the find function in webpages and text editors, this code takes a file, and a given string to find in that file. Once it has been found, it returns the line it was found in, and the line number of that line. If nothing is found, nothing is returned, and it also returns multiple results if there are multiple times where that string shows up. def find (): fo = open ( input ( "Enter the name of your file: " ) , "r+" ) context = input ( "Enter the search paramaters: " ) lines = fo.readlines() for x in range ( 0 , len (lines)): if context in lines[x]: print ( "The given is in the file, within the line, " , lines[x]) print ( "In line number" , x- 1 )

Comparing two file's characters

Using the previous code that I made, this compares the characters used in both files and returns which characters one has that the other does not.  def compare (): file1 = characters() file2 = characters() in_file1_not_file2 = [] in_file2_not_file1 = [] for x in file1: if x not in file2: in_file1_not_file2.append(x) for x in file2: if x not in file1: in_file2_not_file1.append(x) print ( "Characters in first file but not in second file:" , in_file1_not_file2) print ( "Characters in second file but not in first file:" , in_file2_not_file1)

Get Characters

 A program that returns every character used in a text file. It ignores if the letter is in uppercase or not.  def characters (): fo = open ( input ( "Enter the name of your file: " ) , "r+" ) character_list = [] character = "__" while character != "" : character = fo.read( 1 ) try : character = character.lower() except : pass if character not in character_list and character != " \n " and character != "" : character_list.append(character) return character_list

Clap sequence

 The clap sequence is a sequence that generates a list using the previous list's numbers. It starts with [1], and then the frequency of the same numbers in a row is added, followed by the actual number itself. Therefore, the next sequence would be [1, 1], as there is one 1, then it would be [2, 1], as there are two 1s, then [1, 2, 1, 1], as there is one 2 and one 1. array = [ 1 ] for sentinel in range ( 0 , 10 ): count = 1 new_array = [] for x in range ( 0 , len (array)): number = array[x] try : if array[x] == array[x+ 1 ]: count += 1 else : new_array.append(count) new_array.append(number) count = 1 except IndexError as e: new_array.append(count) new_array.append(number) array = new_array print (array) This is the outcome: [1, 1] [2, 1] [1, 2, 1, 1] [1, 1, 1, 2, 2, 1] [3, 1, 2, 2, 1, 1] [1, 3, 1, 1, 2, 2, 2, 1] [1, 1, 1, 3, 2, 1...