diff --git a/README.md b/README.md index ec9989c..4a8c52f 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,35 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Agnish Ghosh + + + SiddheshKukade +
+ Siddhesh Bhupendra Kuakde +
+ + rahulkarda
Rahul Karda
- - + + + + N00rAhmed +
+ Noor Ahmed +
+ + + + Khushi260 +
+ Khushi Jha +
+ muratonuryildirim @@ -108,14 +129,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Vallabh Chugh
- - - - N00rAhmed -
- Noor Ahmed -
- + + Abbhiishek @@ -129,8 +144,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
YUNGH OG
- - + Farhan-2222 @@ -152,26 +166,12 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Raihan Khan - - - SiddheshKukade -
- Siddhesh Bhupendra Kuakde -
- ArshErgon
Mohd Arsh Ali
- - - - Khushi260 -
- Khushi Jha -
@@ -303,6 +303,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 + + + devtayade +
+ Null +
+ drk1rd @@ -317,6 +324,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Null + + + nabroleonx +
+ Abel Ayalew +
+ rohitgarud21 @@ -324,6 +338,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Null + + + smeax +
+ Null +
+ + tolgakurtuluss @@ -338,14 +360,20 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Srinjoy Pati + + + personal-use1 +
+ Null +
+ Shradha-Suman
Shradha
- - + NishantPacharne @@ -359,6 +387,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Aditya Tiwari
+ + + + + Asmita-Dutta +
+ Null +
@@ -387,15 +423,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Olayinka Adeyemi
- - + parinzee
Parinthapat P.
- + + iamrahul8 @@ -417,6 +453,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Sayan Roy + + + shubhajitroy123 +
+ Shubhajit Roy +
+ Tanya-1109 @@ -489,6 +532,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Arijit Ghosh + + + Yaswanth820 +
+ Balaji Yaswanth Vankala +
+ Danuragtiwari @@ -509,15 +559,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Heshanthaka
- + + Gokul-Ks
Gokul_Zuzu
- - + KuSantosh100 @@ -552,15 +602,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Raj Saha
- + + ramonsaraiva
Ramon Saraiva
- - + riyajaiswal25 @@ -595,15 +645,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Anjali Chauhan
- + + anshrusia200
Ansh Rusia
- - + arpitbhardwaj @@ -632,13 +682,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Rohit Purkait - - - devtayade -
- Null -
- yashbrid03 @@ -668,13 +711,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Mubeen Ahmad - - - nabroleonx -
- Abel Ayalew -
- neocollege @@ -688,15 +724,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Smit Shah
- - + SameerSahu007
Sameer Sahu
- + + shatanikmahanty diff --git a/scripts/Base_Conversion/README.md b/scripts/Base_Conversion/README.md deleted file mode 100644 index 51f0e31..0000000 --- a/scripts/Base_Conversion/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# BASE CONVERSION IN PYTHON -- Various functions for interconversion of bases -- Conversion of Binary to Decimal -- Conversion of Octal to Decimal -- Conversion of Hexadecimal to Decimal -- Conversion of Decimal to Binary -- Conversion of Decimal to Octal -- Conversion of Decimal to Hexaecimal \ No newline at end of file diff --git a/scripts/Base_Conversion/main.py b/scripts/Base_Conversion/main.py deleted file mode 100644 index 8fe0a0f..0000000 --- a/scripts/Base_Conversion/main.py +++ /dev/null @@ -1,162 +0,0 @@ - -#Function to calculate x raised to the power y -def Power( x , y ) : - - if (y == 0) : - return 1 - - else : - - ans = x**y - return ans - - -#Function to convert Binary to Decimal -def BinaryToDecimal( n ) : - - ans = 0 - x = 1 - m = int(n) - - while m > 0 : - b = m%10 - ans += b*x - x = x*2 - m = m//10 - - return ans - - -#Function to convert Octal to Decimal -def OctalToDecimal( n ) : - - ans = 0 - x = 1 - m = int(n) - - while m > 0 : - b = m%10 - ans += b*x - x = x*8 - m = m//10 - - return ans - - -#Function to convert Hexadecimal to Decimal -def HexadecimalToDecimal( n ): - - ans = 0 - x = 1 - s = len( n ) - - for i in range( s-1 , -1 , -1 ) : - if n[i] >= '0' and n[i] <= '9' : - ans += x*(int(n[i])) - - elif n[i] >= 'A' and n[i] <= 'F' : - ans += x*(ord(n[i]) - ord('A') + 10) - - x = x*16 - - return ans - - -#Function to convert Decimal to Binary -def DecimalToBinary( n ) : - L = [] - while(n>0): - rem = n%2 - L.append(rem) - n = n//2 - #L = L[::-1] - - dec = 0 - for i in range(0,len(L)): - dec = dec + L[i]*(10**i) - - return dec - -#Function to convert Decimal to Octal -def DecimalToOctal( n ) : - - ans = 0 - count = 0 - - while (n > 0) : - lastDigit = n%8 - ans += lastDigit*(10**(count)) - n = n//8 - - count += 1 - - return ans - - -#Function to convert Decimal to Hexadecimal -def DecimaltoHexadecimal( n ) : - - ans = '' - - while (n > 0) : - lastDigit = n%16 - if (lastDigit >= 0 and lastDigit <=9 ) : - ans = ans + str(lastDigit) - - elif (lastDigit >= 10 and lastDigit <= 15) : - a = chr(ord('A') + (lastDigit-10)) - ans = ans + a - - n = n//16 - - return ans[::-1] - -while True: - print('1 -> Calculate Exponents') - print('2 -> convert Binary to Decimal ') - print('3 -> convert Octal to Decimal ') - print('4 -> convert Hexadecimal to Decimal ') - print('5 -> convert Decimal to Binary ') - print('6 -> convert Decimal to Octal ') - print('7 -> convert Decimal to Hexadecimal ') - print('0 -> Exit') - - - n = int(input('\nEnter: ')) - - if n == 1: - a,b = int(input("Enter Base :\n")),int(input("Enter Superscript : \n")) - print("The result is : ",Power(a,b), "\n") - - elif n == 2: - b = int(input("Enter Binary Number:\n")) - print("Corresponding Decimal Number is : ", BinaryToDecimal(b), "\n") - - elif n == 3: - b = int(input("Enter Octal Number:\n")) - print("Corresponding Decimal Number is : ", OctalToDecimal(b), "\n") - - elif n == 4: - b = (input("Enter Hexadecimal Number:\n")) - print("Corresponding Decimal Number is : ", HexadecimalToDecimal(b), "\n") - - elif n == 5: - b = int(input("Enter Decimal Number:\n")) - print("Corresponding Binary Number is : ", DecimalToBinary(b), "\n") - - elif n == 6: - b = int(input("Enter Decimal Number:\n")) - print("Corresponding Octal Number is : ", DecimalToOctal(b), "\n") - - elif n == 7: - b = int(input("Enter Decimal Number:\n")) - print("Corresponding Hexadecimal Number is : ", DecimaltoHexadecimal(b), "\n") - - elif n == 0: - - exit() - - else: - print("\nNo such option exists!! ") - - diff --git a/scripts/Brick-Breaker-Python/README.md b/scripts/Brick-Breaker-Python/README.md new file mode 100644 index 0000000..bb1a550 --- /dev/null +++ b/scripts/Brick-Breaker-Python/README.md @@ -0,0 +1,4 @@ +# Brick-Breaker-Python +Brick breaker game in which there is a ball that bounces of a platform to break a brick wall and the player has to keep the ball going by making sure the paddle is always there to bounce off the ball back. + +The game will have three layers of bricks, and each layer of brick will have a different hit capacity, which means some bricks will break in a single hit, some will require a double hit and some will require three hits. diff --git a/scripts/Brick-Breaker-Python/main.py b/scripts/Brick-Breaker-Python/main.py new file mode 100644 index 0000000..009060b --- /dev/null +++ b/scripts/Brick-Breaker-Python/main.py @@ -0,0 +1,229 @@ +import pygame +import math + +pygame.init() + +WIDTH, HEIGHT = 800, 600 +win = pygame.display.set_mode((WIDTH, HEIGHT)) +pygame.display.set_caption("Brick Breaker") + +FPS = 60 +PADDLE_WIDTH = 100 +PADDLE_HEIGHT = 15 +BALL_RADIUS = 10 + +LIVES_FONT = pygame.font.SysFont("comicsans", 40) + + +class Paddle: + VEL = 5 + + def __init__(self, x, y, width, height, color): + self.x = x + self.y = y + self.width = width + self.height = height + self.color = color + + def draw(self, win): + pygame.draw.rect( + win, self.color, (self.x, self.y, self.width, self.height)) + + def move(self, direction=1): + self.x = self.x + self.VEL * direction + + +class Ball: + VEL = 5 + + def __init__(self, x, y, radius, color): + self.x = x + self.y = y + self.radius = radius + self.color = color + self.x_vel = 0 + self.y_vel = -self.VEL + + def move(self): + self.x += self.x_vel + self.y += self.y_vel + + def set_vel(self, x_vel, y_vel): + self.x_vel = x_vel + self.y_vel = y_vel + + def draw(self, win): + pygame.draw.circle(win, self.color, (self.x, self.y), self.radius) + + +class Brick: + def __init__(self, x, y, width, height, health, colors): + self.x = x + self.y = y + self.width = width + self.height = height + self.health = health + self.max_health = health + self.colors = colors + self.color = colors[0] + + def draw(self, win): + pygame.draw.rect( + win, self.color, (self.x, self.y, self.width, self.height)) + + def collide(self, ball): + if not (ball.x <= self.x + self.width and ball.x >= self.x): + return False + if not (ball.y - ball.radius <= self.y + self.height): + return False + + self.hit() + ball.set_vel(ball.x_vel, ball.y_vel * -1) + return True + + def hit(self): + self.health -= 1 + self.color = self.interpolate( + *self.colors, self.health/self.max_health) + + @staticmethod + def interpolate(color_a, color_b, t): + # 'color_a' and 'color_b' are RGB tuples + # 't' is a value between 0.0 and 1.0 + # this is a naive interpolation + return tuple(int(a + (b - a) * t) for a, b in zip(color_a, color_b)) + + +def draw(win, paddle, ball, bricks, lives): + win.fill("white") + paddle.draw(win) + ball.draw(win) + + for brick in bricks: + brick.draw(win) + + lives_text = LIVES_FONT.render(f"Lives: {lives}", 1, "black") + win.blit(lives_text, (10, HEIGHT - lives_text.get_height() - 10)) + + pygame.display.update() + + +def ball_collision(ball): + if ball.x - BALL_RADIUS <= 0 or ball.x + BALL_RADIUS >= WIDTH: + ball.set_vel(ball.x_vel * -1, ball.y_vel) + if ball.y + BALL_RADIUS >= HEIGHT or ball.y - BALL_RADIUS <= 0: + ball.set_vel(ball.x_vel, ball.y_vel * -1) + + +def ball_paddle_collision(ball, paddle): + if not (ball.x <= paddle.x + paddle.width and ball.x >= paddle.x): + return + if not (ball.y + ball.radius >= paddle.y): + return + + paddle_center = paddle.x + paddle.width/2 + distance_to_center = ball.x - paddle_center + + percent_width = distance_to_center / paddle.width + angle = percent_width * 90 + angle_radians = math.radians(angle) + + x_vel = math.sin(angle_radians) * ball.VEL + y_vel = math.cos(angle_radians) * ball.VEL * -1 + + ball.set_vel(x_vel, y_vel) + + +def generate_bricks(rows, cols): + gap = 2 + brick_width = WIDTH // cols - gap + brick_height = 20 + + bricks = [] + for row in range(rows): + for col in range(cols): + brick = Brick(col * brick_width + gap * col, row * brick_height + + gap * row, brick_width, brick_height, 2, [(0, 255, 0), (255, 0, 0)]) + bricks.append(brick) + + return bricks + + +def main(): + clock = pygame.time.Clock() + + paddle_x = WIDTH/2 - PADDLE_WIDTH/2 + paddle_y = HEIGHT - PADDLE_HEIGHT - 5 + paddle = Paddle(paddle_x, paddle_y, PADDLE_WIDTH, PADDLE_HEIGHT, "black") + ball = Ball(WIDTH/2, paddle_y - BALL_RADIUS, BALL_RADIUS, "black") + + bricks = generate_bricks(3, 10) + lives = 3 + + def reset(): + paddle.x = paddle_x + paddle.y = paddle_y + ball.x = WIDTH/2 + ball.y = paddle_y - BALL_RADIUS + + + def display_text(text): + text_render = LIVES_FONT.render(text, 1, "red") + win.blit(text_render, (WIDTH/2 - text_render.get_width() / + 2, HEIGHT/2 - text_render.get_height()/2)) + pygame.display.update() + pygame.time.delay(3000) + + run = True + while run: + clock.tick(FPS) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + break + + keys = pygame.key.get_pressed() + + if keys[pygame.K_LEFT] and paddle.x - paddle.VEL >= 0: + paddle.move(-1) + if keys[pygame.K_RIGHT] and paddle.x + paddle.width + paddle.VEL <= WIDTH: + paddle.move(1) + + ball.move() + ball_collision(ball) + ball_paddle_collision(ball, paddle) + + for brick in bricks[:]: + brick.collide(ball) + + if brick.health <= 0: + bricks.remove(brick) + + # lives check + if ball.y + ball.radius >= HEIGHT: + lives -= 1 + ball.x = paddle.x + paddle.width/2 + ball.y = paddle.y - BALL_RADIUS + ball.set_vel(0, ball.VEL * -1) + + if lives <= 0: + bricks = generate_bricks(3, 10) + lives = 3 + reset() + display_text("You Lost!") + + if len(bricks) == 0: + bricks = generate_bricks(3, 10) + lives = 3 + reset() + display_text("You Won!") + + draw(win, paddle, ball, bricks, lives) + + pygame.quit() + quit() + + +if __name__ == "__main__": + main() diff --git a/scripts/Calculate_your_age_script/script.py b/scripts/Calculate_your_age_script/script.py new file mode 100644 index 0000000..50ac689 --- /dev/null +++ b/scripts/Calculate_your_age_script/script.py @@ -0,0 +1,48 @@ +import time +from calendar import isleap + +# judge the leap year +def judge_leap_year(year): + if isleap(year): + return True + else: + return False + + +# returns the number of days in each month +def month_days(month, leap_year): + if month in [1, 3, 5, 7, 8, 10, 12]: + return 31 + elif month in [4, 6, 9, 11]: + return 30 + elif month == 2 and leap_year: + return 29 + elif month == 2 and (not leap_year): + return 28 + + +name = input("input your name: ") +age = input("input your age: ") +localtime = time.localtime(time.time()) + +year = int(age) +month = year * 12 + localtime.tm_mon +day = 0 + +begin_year = int(localtime.tm_year) - year +end_year = begin_year + year + +# calculate the days +for y in range(begin_year, end_year): + if (judge_leap_year(y)): + day = day + 366 + else: + day = day + 365 + +leap_year = judge_leap_year(localtime.tm_year) +for m in range(1, localtime.tm_mon): + day = day + month_days(m, leap_year) + +day = day + localtime.tm_mday +print("%s's age is %d years or " % (name, year), end="") +print("%d months or %d days" % (month, day)) \ No newline at end of file diff --git a/scripts/Copy to clipboard/README.md b/scripts/Copy to clipboard/README.md new file mode 100644 index 0000000..3948af5 --- /dev/null +++ b/scripts/Copy to clipboard/README.md @@ -0,0 +1,6 @@ +# Copy to Clipboard +A tool that will help you to copy the contents of a file having any size without opening that file +## Usage/Examples +```sh +$ clipboard.py +``` diff --git a/scripts/Copy to clipboard/clipboard.py b/scripts/Copy to clipboard/clipboard.py new file mode 100644 index 0000000..1742b1e --- /dev/null +++ b/scripts/Copy to clipboard/clipboard.py @@ -0,0 +1,29 @@ +import os +import sys +import platform +import subprocess + +# Seeing if the file exists +if os.path.exists(sys.argv[1]): + # Open Only if the file exists on the computer + f = open(sys.argv[1], "r") + # Storing the Content of the file in the f_contents variable + f_contents = f.read() + # closing the opened file + f.close() +else: + # If the file Doesn't Exists + print("File Not found : copy2clip ") + exit(1) +# Storing the current OS version +whatos = platform.system() +# If Darwin or Ubuntu +if whatos == "Darwin": + subprocess.run("pbcopy", universal_newlines=True, input=f_contents) + print("success: copied to clipboard") +# If Windows +elif whatos == "Windows": + subprocess.run("clip", universal_newlines=True, input=f_contents) + print("success: copied to clipboard") +else: + print("failed: clipboard not supported") diff --git a/scripts/Dice Roll/main.py b/scripts/Dice Roll/main.py new file mode 100644 index 0000000..99e3369 --- /dev/null +++ b/scripts/Dice Roll/main.py @@ -0,0 +1,10 @@ +import random +b=input("Do you want to roll the dice?y/n: ") +if b=='y': + a=int(input("Number of times you want to roll: ")) + print("Result: ") + for i in range(0,a): + ans=random.randint(1,6) + print(i+1,".",ans) +else: + print("Good Bye!") \ No newline at end of file diff --git a/scripts/Dice Roll/readme.md b/scripts/Dice Roll/readme.md new file mode 100644 index 0000000..eb0ebb6 --- /dev/null +++ b/scripts/Dice Roll/readme.md @@ -0,0 +1,5 @@ +Dice Roll Game with PYTHON + +#Steps : +Run - python main.py +Have a fun time!! diff --git a/scripts/Lyrics Scraper/LyricsScraper.py b/scripts/Lyrics Scraper/LyricsScraper.py new file mode 100644 index 0000000..8f680f7 --- /dev/null +++ b/scripts/Lyrics Scraper/LyricsScraper.py @@ -0,0 +1,22 @@ +import requests +from bs4 import BeautifulSoup + + +def get_lyrics(artist, song): + song_url = 'http://www.azlyrics.com/lyrics/' + artist + '/' + song + '.html' + + response = requests.get(song_url) + + soup = BeautifulSoup(response.content, 'html.parser') + try: + lyrics = soup.find( + 'div', class_='col-xs-12 col-lg-8 text-center').find_all('div')[5].text + print(lyrics) + except AttributeError: + print("Please make sure you have entered the correct name(i.e. Don't add spaces between words)!") + + +artist = input( + "Enter the name of the artist/band: ").strip().lower().replace(' ', '') +song = input("Enter the name of the song: ").strip().lower().replace(' ', '') +get_lyrics(artist, song) diff --git a/scripts/Lyrics Scraper/README.md b/scripts/Lyrics Scraper/README.md new file mode 100644 index 0000000..95cf968 --- /dev/null +++ b/scripts/Lyrics Scraper/README.md @@ -0,0 +1,9 @@ +# Lyrics scraper + +This simple script scrapes [Azlyrics](http://www.azlyrics.com) given the artist and the song name. + +## Usage + +It's pretty straight-forward, just install the requiremnts and run it. + +`pip install -r requirements.txt` diff --git a/scripts/Lyrics Scraper/requirements.txt b/scripts/Lyrics Scraper/requirements.txt new file mode 100644 index 0000000..d779dbe --- /dev/null +++ b/scripts/Lyrics Scraper/requirements.txt @@ -0,0 +1,2 @@ +bs4 +requests \ No newline at end of file diff --git a/scripts/Text_Game/Text_Game.py b/scripts/Text_Game/Text_Game.py index ae410e1..6df50fa 100644 --- a/scripts/Text_Game/Text_Game.py +++ b/scripts/Text_Game/Text_Game.py @@ -1,11 +1,7 @@ import random import time import sys -# print(""" β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–ˆβ–ˆ -# β–„β”€β”€β”€β–„β–€β–ˆβ–„β–„β–„β–„ -# ─ β–„β–€β”€β–ˆβ–„β–„ -# ▄▄▄▀───▀▄ -# ▀────────▀▀ """) + def start(): # story generated @@ -105,7 +101,7 @@ def level2(): print('You are running far away from the robots') time.sleep(2) - print(""" β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–ˆβ–ˆ + print(""" β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–ˆβ–ˆ β–„β”€β”€β”€β–„β–€β–ˆβ–„β–„β–„β–„ ─ β–„β–€β”€β–ˆβ–„β–„ ▄▄▄▀───▀▄ @@ -188,59 +184,160 @@ def level2(): ´´´´´¢¢¢¢¢¢¢¢¢¢¢¢´ ´´´´´´´¢¢¢¢¢¢¢¢ """) +# question_one = '' + # while question_one != 'run away' and question_one != 'shoot robot in head': + items = '' + while items != 'tank' and items != 'bomb' and items != 'mech suit': + items = input("which item do you choose - the mech suit, tank or bomb : ") - items = input("which item do you choose - the mech suit, tank or bomb : ") + if (items == 'tank'): + time.sleep(3) + print('oh no the cyborg has ripped through the tank') + time.sleep(3) + print('you are running away to find safety') + time.sleep(3) + print('but the cyborg has seen you and captured you') - if (items == 'tank'): - time.sleep(3) - print('oh no the cyborg has ripped through the tank') - time.sleep(3) - print('you are running away to find safety') - time.sleep(3) - print('but the cyborg has seen you and captured you') + elif (items == 'bomb'): + time.sleep(3) + print('you throw the bomb and it exlodes') + time.sleep(3) + print('but it doesnt even lay a scratch on him') + time.sleep(3) + print('because he is made from vibranium') + time.sleep(3) + print('you are instantly captured now') - elif (items == 'bomb'): - time.sleep(3) - print('you throw the bomb and it exlodes') - time.sleep(3) - print('but it doesnt even lay a scratch on him') - time.sleep(3) - print('because he is made from vibranium') + elif (items == "mech suit"): + time.sleep(3) + print('you are now in the mech suit') + time.sleep(3) + print('the cyborg is running towards you') + time.sleep(3) + print('this suit is highly advanced and gives you a ton of diffrent options') + suit_options() +# question_one = '' + # while question_one != 'run away' and question_one != 'shoot robot in head': +def combat_option(): + combat_moves = '' + while combat_moves != 'right hook' and combat_moves != 'head butt': time.sleep(3) - print('you are instantly captured now') + combat_moves = input("do you want to throw a right hook or head butt: ") + if (combat_moves == 'right hook'): + time.sleep(3) + print('wow your right hook to the cyborg was so DEVASTATING that it has killed him') + level3() + elif (combat_moves == 'head butt'): + time.sleep(3) + print('incredible your head butt has KNOCKED OUT the cyborg') + level3() - elif (items == "mech suit"): - time.sleep(3) - print('you are now in the mech suit') +def suit_options(): time.sleep(3) - print('the cyborg is running towards you') - time.sleep(3) - print('this suit is highly advanced and gives you a ton of diffrent options') + select_option = '' + while select_option != 'rocket fist' and select_option != 'missile' and select_option != 'body slam': + select_option = input("what would you like to use: rocket fist, missile, body slam: ") - time.sleep(3) - select_option = input("what would you like to use: rocket fist, missile, body slam: ") + if (select_option == "rocket fist"): + time.sleep(3) + print('good the cyborg is extremely disorientated') + combat_option() + # def combat_option(): + # combat_moves = '' + # while combat_moves != 'right hook' and combat_moves != 'head butt': + # time.sleep(3) + # combat_moves = input("do you want to throw a right hook or head butt: ") + # if (combat_moves == 'right hook'): + # time.sleep(3) + # print('wow your right hook to the cyborg was so DEVASTATING that it has killed him') + # level3() + # elif (combat_moves == 'head butt'): + # time.sleep(3) + # print('incredible your head butt has KNOCKED OUT the cyborg') + # level3() - if (select_option == "rocket fist"): - time.sleep(3) - print('good the cyborg is extremely disorientated') - time.sleep(3) - combat_moves = input("do you want to throw a right hook or head butt: ") - if (combat_moves == 'right hook'): + elif (select_option == 'missile'): time.sleep(3) - print('wow your right hook to the cyborg was so DEVASTATING that it has killed him') - elif (combat_moves == 'head butt'): + print('oh no the cyborg is made from vibranium') time.sleep(3) - print('incredible your head butt has KNOCKED OUT the cyborg') - elif (select_option == 'missile'): + print('the cyborg punches you and takes you back to the robots') + elif (select_option == 'body slam'): + time.sleep(3) + print('the cyborg has been knocked unconsious good job') + time.sleep(3) + print('u have enough time to run') + level3() + +def level3(): + time.sleep(3) + print('after that battle you are completely drained and are trying to find safety') + time.sleep(3) + print('after walking for hours you come across a strange looking object') + time.sleep(3) + print('the strange looking object looks like a computer from the past') + time.sleep(4) + print(""" +β–β–“β–ˆβ–€β–€β–€β–€β–€β–€β–€β–€β–€β–ˆβ–“β–Œβ–‘β–„β–„β–„β–„β–„β–‘ +β–β–“β–ˆβ–‘β–‘β–€β–‘β–‘β–€β–„β–‘β–‘β–ˆβ–“β–Œβ–‘β–ˆβ–„β–„β–„β–ˆβ–‘ +β–β–“β–ˆβ–‘β–‘β–„β–‘β–‘β–„β–€β–‘β–‘β–ˆβ–“β–Œβ–‘β–ˆβ–„β–„β–„β–ˆβ–‘ +β–β–“β–ˆβ–„β–„β–„β–„β–„β–„β–„β–„β–„β–ˆβ–“β–Œβ–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘ +β–‘β–‘β–‘β–‘β–„β–„β–ˆβ–ˆβ–ˆβ–„β–„β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘ + + """) + time.sleep(3) + print('there is a video recording on it') +# question_one = '' + # while question_one != 'run away' and question_one != 'shoot robot in head': + message = '' + while message != 'yes' and message != 'no': + message = input('Do you want to play the recording: ') + if message == 'yes': + time.sleep(2) + print('...') + time.sleep(2) + print('..') + time.sleep(2) + print('.') time.sleep(3) - print('oh no the cyborg is made from vibranium') + print('Computer: We have found a way to end the war') time.sleep(3) - print('the cyborg punches you and takes you back to the robots') - elif (select_option == 'body slam'): + print('We have ...') + time.sleep(5) + print("Computer: We have created an algorithm which can search and terminate all AI organisms") + time.sleep(2) + print('Computer: OH NO') time.sleep(3) - print('the cyborg has been knocked unconsious good job') + print('Computer: the machines have invaded our base') time.sleep(3) - print('u have enough time to run') + print("/@)|Β¬!}{") + algorithm() + +def algorithm(): + time.sleep(3) + initiate = '' + while initiate != 'start' and initiate != 'terminate': + initiate = input('If you wish to initiate this algorithm please type start or if you wish to terminate the algorithm please type terminate: ') + if (initiate == 'start'): + time.sleep(3) + print('....') + time.sleep(3) + print('beep') + time.sleep(3) + print('boop') + time.sleep(3) + print('boop') + time.sleep(3) + print('beep') + time.sleep(3) + print('Congratulations you have sucessfully killed all of the robots in this timeline !!!!!!') + + + elif (initiate == 'terminate'): + time.sleep(3) + print('WTF !!!!') + + + # option to play again at completion of game play_again = "yes" diff --git a/scripts/Tic-Tac-Toe/main.py b/scripts/Tic-Tac-Toe/main.py new file mode 100644 index 0000000..91e79a9 --- /dev/null +++ b/scripts/Tic-Tac-Toe/main.py @@ -0,0 +1,40 @@ +def check(m): + if ( (m[0][0] == m[0][1] == m[0][2] != 0) + or (m[1][0] == m[2][0] == m[0][0] != 0 ) + or (m[0][0] == m[1][1] == m[2][2] != 0) + or (m[1][0] == m[1][2] == m[1][2] != 0) + or (m[2][0] == m[2][1] == m[2][2] != 0) + or (m[0][1] == m[1][1] == m[2][1] != 0) + or (m[0][2] == m[1][2] == m[2][2] != 0) + or (m[0][2] == m[1][1] == m[2][0] != 0) ): + return 1 + else: + return 0 + + +def display(m): + for i in range(3): + for j in range(3): + print(m[i][j],end = "\t") + print("\n") + + +a=input("Want to play tic-tac-toe?y/n: ") +if a== "y": + m = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] + while True: + i,j= int(input("X: enter row no.")), int(input("enter column no.")) + m[i][j]="X" + display(m) + if check(m)== 1: + print("Congratulations you won!") + break + + i,j= int(input("O: enter row no.")), int(input("enter column no.")) + m[i][j]="O" + display(m) + if check(m)== 1: + print("Congratulations you won!") + break +else: + print("Good Bye!") \ No newline at end of file diff --git a/scripts/Tic-Tac-Toe/readme.md b/scripts/Tic-Tac-Toe/readme.md new file mode 100644 index 0000000..456a99c --- /dev/null +++ b/scripts/Tic-Tac-Toe/readme.md @@ -0,0 +1,5 @@ +Tic Tac Toe with PYTHON + +#Steps : +Run - python main.py +Have a fun time!! diff --git a/scripts/Voice_Assited_Musicplayer/.gitignore b/scripts/Voice_Assited_Musicplayer/.gitignore new file mode 100644 index 0000000..71f6e2b --- /dev/null +++ b/scripts/Voice_Assited_Musicplayer/.gitignore @@ -0,0 +1,49 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +# C extensions +*.so + +# Distribution / packaging +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +# Sphinx documentation +docs/_build/ \ No newline at end of file diff --git a/scripts/Voice_Assited_Musicplayer/README.md b/scripts/Voice_Assited_Musicplayer/README.md new file mode 100644 index 0000000..cf2a96b --- /dev/null +++ b/scripts/Voice_Assited_Musicplayer/README.md @@ -0,0 +1,33 @@ +# Voice_assisted_musicplayer +This project contains Ai powered voice activated music player system. +The system supports mp3,wav and mpeg audio files. +It can also play songs according to yor emotion(files need to be stored in voice_assisted_musicplayer/Songs/[-] **folder name according to your choice**) +It can also load music files form other directories. + +To run the program execute the assistant.py file and say the desired song according to your mood +# preview +![image](https://user-images.githubusercontent.com/115635715/195788102-1906c8b2-edd7-456b-9a10-7130bfb19704.png) + +![image](https://user-images.githubusercontent.com/115635715/195788334-144aab6a-bb67-42a1-a427-63ceef34a8fe.png) + + +## Features of the music player: +-backward button
+-forward button
+-pause/play button
+-progress bar
+-volume button
+-delete button
+-load file button
+ + +## Requirements:
+pyttsx3
+SpeechRecognition
+os
+datetime
+pickle
+tkinter
+pygame
+mutagen
+time
diff --git a/scripts/Voice_Assited_Musicplayer/Songs/happy/Happy (from Despicable Me 2) G I R L - 320Kbps.mp3 b/scripts/Voice_Assited_Musicplayer/Songs/happy/Happy (from Despicable Me 2) G I R L - 320Kbps.mp3 new file mode 100644 index 0000000..f9caed2 Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/Songs/happy/Happy (from Despicable Me 2) G I R L - 320Kbps.mp3 differ diff --git a/scripts/Voice_Assited_Musicplayer/Songs/sad/Lewis Capaldi - Before You Go - Copy (2).mp3 b/scripts/Voice_Assited_Musicplayer/Songs/sad/Lewis Capaldi - Before You Go - Copy (2).mp3 new file mode 100644 index 0000000..ad56a0d Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/Songs/sad/Lewis Capaldi - Before You Go - Copy (2).mp3 differ diff --git a/scripts/Voice_Assited_Musicplayer/assistant.py b/scripts/Voice_Assited_Musicplayer/assistant.py new file mode 100644 index 0000000..bbe1d9c --- /dev/null +++ b/scripts/Voice_Assited_Musicplayer/assistant.py @@ -0,0 +1,84 @@ +import pyttsx3 +import speech_recognition as sr +import datetime +import os +from player import run + +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) + +playlist = [] + + +def speak(audio): + engine.say(audio) + engine.runAndWait() + + +def bot_answer(answer): + print("assistant:", answer) + + +def greetings(): + global playlist + hour = int(datetime.datetime.now().hour) + if(hour >= 0 and hour < 12): + speak("good morning") + elif hour >= 12 and hour < 18: + speak("good afternoon") + else: + speak("good evening") + + speak("welcome to py-Musicplayer") + bot_answer('say playlist name to play') + playlist = os.listdir('Songs') + bot_answer(playlist) + + +def action_taker(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Listening...") + speak("listening") + r.adjust_for_ambient_noise(source, duration=5) + audio = r.listen(source) + + try: + print("recognizing...") + speak("recognizing") + command = r.recognize_google(audio) + print(f'User:{command}\n"') + + except Exception as e: + print(e) + bot_answer("Say that again please....") + + return "None" + return command + + +greetings() +while True: + command = action_taker().lower() + song_playlist = list(map(str.lower, playlist)) + + if any(command in s for s in song_playlist): + get_ind = song_playlist.index(command) + playlist_name = playlist.index(command) + playlist_name = playlist[get_ind] + playlist_dir = os.path.abspath("./Songs/"+playlist_name) + bot_answer('Playing: '+playlist_name + + 'playlist for you with Musicplayer') + speak('playing:'+playlist_name+'playlist for you with music player') + print(playlist_dir) + run(playlist_dir) + elif 'stop' in command: + speak('good bye,have a good day') + bot_answer('exit') + engine.stop() + break + else: + bot_answer('did not get the playlist...') + speak('did not get the playlist') + print(playlist) diff --git a/scripts/Voice_Assited_Musicplayer/images/image2.gif b/scripts/Voice_Assited_Musicplayer/images/image2.gif new file mode 100644 index 0000000..5c621b0 Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/images/image2.gif differ diff --git a/scripts/Voice_Assited_Musicplayer/images/next.gif b/scripts/Voice_Assited_Musicplayer/images/next.gif new file mode 100644 index 0000000..5fca996 Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/images/next.gif differ diff --git a/scripts/Voice_Assited_Musicplayer/images/pause.gif b/scripts/Voice_Assited_Musicplayer/images/pause.gif new file mode 100644 index 0000000..ff7a306 Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/images/pause.gif differ diff --git a/scripts/Voice_Assited_Musicplayer/images/play.gif b/scripts/Voice_Assited_Musicplayer/images/play.gif new file mode 100644 index 0000000..7ece421 Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/images/play.gif differ diff --git a/scripts/Voice_Assited_Musicplayer/images/previous.gif b/scripts/Voice_Assited_Musicplayer/images/previous.gif new file mode 100644 index 0000000..e5bccfa Binary files /dev/null and b/scripts/Voice_Assited_Musicplayer/images/previous.gif differ diff --git a/scripts/Voice_Assited_Musicplayer/player.py b/scripts/Voice_Assited_Musicplayer/player.py new file mode 100644 index 0000000..941ab41 --- /dev/null +++ b/scripts/Voice_Assited_Musicplayer/player.py @@ -0,0 +1,293 @@ +import time +import os +import pickle +import tkinter as tk +from tkinter import Label, filedialog +from tkinter import PhotoImage +from pygame import mixer +from mutagen.mp3 import MP3 +import tkinter.ttk as ttk +from tkinter import messagebox + + +class Player(tk.Frame): + def __init__(self, song_path, master=None): + super().__init__(master) + self.master = master + self.song_path = song_path + self.pack() + mixer.init() + + if os.path.exists('songs.pickle'): + with open('songs.pickle', 'rb') as f: + self.playlist = pickle.load(f) + else: + self.playlist = [] + + self.current = 0 + self.paused = True + self.played = False + self.song_length = 0 + + self.page_layouts() + self.track_config() + self.control_widgets() + self.song_list() + self.retrieve_songs2() + + def page_layouts(self): + self.track = tk.LabelFrame(self, text='Song Track', + font=("times new roman", 15, "bold"), + bg="black", fg="white", bd=5, relief=tk.GROOVE) + self.track.config(width=400, height=300) + self.track.grid(row=0, column=0, padx=1) + + self.tracklist = tk.LabelFrame(self, text=f'PlayList - {str(len(self.playlist))}', + font=("times new roman", 12, "bold"), + bg="black", fg="white", bd=5, relief=tk.GROOVE) + self.tracklist.config(width=190, height=200) + self.tracklist.grid(row=0, column=1, pady=1) + + self.controls = tk.LabelFrame(self, + font=("times new roman", 15, "bold"), + bg="black", fg="white", bd=2, relief=tk.GROOVE) + self.controls.config(width=410, height=80) + self.controls.grid(row=2, column=0, pady=1, padx=1) + + self.music_slider = tk.LabelFrame(self, + font=("times new roman", 15, "bold"), + bg="black", fg="white", bd=5, relief=tk.GROOVE) + self.music_slider.config(width=410, height=80) + self.music_slider.grid(row=3, column=0, pady=1, padx=1) + + self.func = tk.LabelFrame(self, + font=("times new roman", 12, "bold"), + bg="black", fg="white", bd=5, relief=tk.GROOVE) + self.func.config(width=250, height=210) + self.func.grid(row=3, column=1) + + self.promo = tk.LabelFrame(self, + bg="black", fg="white", bd=5, relief=tk.GROOVE) + self.promo.config(width=50, height=50) + self.promo.grid(row=2, column=1) + + def track_config(self): + self.views = tk.Label(self.track, image=img) + self.views.configure(width=400, height=240) + self.views.grid(row=0, column=0) + + self.musictrack = tk.Label(self.track, font=("times new roman", 16, "bold"), + bg="white", fg="dark blue") + self.musictrack['text'] = 'MP3 Player' + self.musictrack.config(width=30, height=1) + self.musictrack.grid(row=1, column=0, padx=10) + + def control_widgets(self): + self.loading = tk.Button( + self.controls, bg='green', fg='white', font=10) + self.loading['text'] = 'Load Songs' + self.loading['command'] = self.retrieve_songs + self.loading.grid(row=0, column=0, padx=10) + + self.prev = tk.Button(self.controls, image=prev) + self.prev['command'] = self.prev_song + self.prev.grid(row=0, column=1) + + self.pause = tk.Button(self.controls, image=pause) + self.pause['command'] = self.pause_song + self.pause.grid(row=0, column=2) + + self.next = tk.Button(self.controls, image=next_) + self.next['command'] = self.next_song + self.next.grid(row=0, column=3) + + self.volume = tk.DoubleVar(self) + self.slider = tk.Scale(self.controls, from_=0, + to=10, orient=tk.HORIZONTAL) + self.slider['variable'] = self.volume + self.slider.set(5) + mixer.music.set_volume(1) + self.slider['command'] = self.change_volume + self.slider.grid(row=0, column=4, padx=10, pady=4) + + self.mu_slider = ttk.Scale(self.music_slider, from_=0, to=100, + orient=tk.HORIZONTAL, value=0, length=390) + self.mu_slider.grid(pady=20, padx=10) + + self.status_bar = Label(self.music_slider, text="Time Elapsed: 0/0") + self.status_bar.grid(pady=1) + + self.delet = tk.Button(self.func, text="Delete", bg='green', fg='white', font=15) + self.delet['command'] = self.delete_songs + self.delet.grid(row=0, column=1, padx=39, pady=29) + + self.prom = tk.Label(self.promo, text="artgoblin's work", font=("times new roman", 10, "bold", "italic"), + bg="grey", fg="black") + self.prom.grid(row=0, column=2, padx=20, pady=12) + + def song_list(self): + self.scrollbar = tk.Scrollbar(self.tracklist, orient=tk.VERTICAL) + self.scrollbar.grid(row=0, column=1, rowspan=5, sticky='ns') + + self.list = tk.Listbox(self.tracklist, selectmode=tk.SINGLE, + yscrollcommand=self.scrollbar.set, selectbackground='sky blue') + self.enum_songs() + self.list.config(height=17) + self.list.bind('', self.play_song) + + self.scrollbar.config(command=self.list.yview) + self.list.grid(row=0, column=0, rowspan=5) + + def retrieve_songs2(self): + self.songlist2 = [] + os.chdir(self.song_path) + + for files in os.listdir(self.song_path): + try: + if files.endswith(".mp3"): + + self.songlist2.append(files) + elif files.endswith(".wav"): + + self.songlist2.append(files) + elif files.endswith(".mpeg"): + + self.songlist2.append(files) + except: + pass + + with open('songs2.pickle', 'wb') as f: + pickle.dump(self.songlist2, f) + self.playlist = self.songlist2 + self.tracklist['text'] = f'PlayList - {str(len(self.playlist))}' + self.list.delete(0, tk.END) + + self.enum_songs() + + def retrieve_songs(self): + self.songlist = [] + + directory = filedialog.askdirectory() + for root_, dirs, files in os.walk(directory): + for file in files: + if os.path.splitext(file)[1] == '.mp3': + path = (root_ + '/' + file).replace('\\', '/') + self.songlist.append(path) + elif os.path.splitext(file)[1] == '.mpeg': + path = (root_ + '/' + file).replace('\\', '/') + self.songlist.append(path) + elif os.path.splitext(file)[1] == '.wav': + path = (root_ + '/' + file).replace('\\', '/') + self.songlist.append(path) + + with open('songs.pickle', 'wb') as f: + pickle.dump(self.songlist, f) + self.playlist = self.songlist + self.tracklist['text'] = f'PlayList - {str(len(self.playlist))}' + self.list.delete(0, tk.END) + self.enum_songs() + + def enum_songs(self): + for index, song in enumerate(self.playlist): + self.list.insert(index, os.path.basename(song)) + + def play_song(self, event=None): + if event is not None: + self.current = self.list.curselection()[0] + for i in range(len(self.playlist)): + self.list.itemconfigure(i, bg="white") + + print(self.playlist[self.current]) + mixer.music.load(self.playlist[self.current]) + self.m = mixer.music.load(self.playlist[self.current]) + self.musictrack['anchor'] = 'w' + self.musictrack['text'] = os.path.basename(self.playlist[self.current]) + + self.pause['image'] = play + self.paused = False + self.played = True + self.list.activate(self.current) + self.list.itemconfigure(self.current, bg='sky blue') + + mixer.music.play() + self.update_progress() + + def update_progress(self): + song_mut = MP3(self.playlist[self.current]) + self.song_length = song_mut.info.length + slider_position = int(self.song_length) + self.mu_slider.config(to=slider_position) + pos_ms = mixer.music.get_pos() / 1000 + self.mu_slider.config(value=pos_ms) + clock = time.strftime('%M:%S', time.gmtime(self.song_length)) + clock2 = time.strftime('%M:%S', time.gmtime(pos_ms)) + self.status_bar.config(text=f'Time Elapsed: {clock2} / {clock} ') + self.after(1000, self.update_progress) + + def pause_song(self): + if not self.paused: + self.paused = True + mixer.music.pause() + self.pause['image'] = pause + else: + if self.played == False: + self.play_song() + self.paused = False + mixer.music.unpause() + self.pause['image'] = play + + def prev_song(self): + if self.current > 0: + self.current -= 1 + else: + self.current = 0 + self.list.itemconfigure(self.current + 1, bg='white') + self.play_song() + + def next_song(self): + if self.current < len(self.playlist) - 1: + self.current += 1 + else: + self.current = 0 + self.list.itemconfigure(self.current - 1, bg='white') + self.play_song() + + def change_volume(self, event=None): + self.v = self.volume.get() + mixer.music.set_volume(self.v / 10) + + def delete_songs(self, event=None): + items = map(int, self.list.curselection()) + for item in items: + self.list.delete(item) + self.playlist.pop(item) + self.tracklist['text'] = 'Total Songs: ' + str(len( self.playlist)) + + + + + +def run(song_path): + global img, prev, play, next_, pause + root = tk.Tk() + root.title('MP3 Player') + root.geometry("572x458") + + def on_closing(): + + if messagebox.askokcancel("Quit", "Do you want to quit?"): + + mixer.music.stop() + root.destroy() + root.protocol("WM_DELETE_WINDOW", on_closing) + + os.path.join(os.path.curdir, 'file.name') + + img = PhotoImage(file=os.path.join(os.path.curdir, 'images/image2.gif')) + next_ = PhotoImage(file=os.path.join(os.path.curdir, 'images/next.gif')) + prev = PhotoImage(file=os.path.join(os.path.curdir, 'images/previous.gif')) + play = PhotoImage(file=os.path.join(os.path.curdir, 'images/play.gif')) + pause = PhotoImage(file=os.path.join(os.path.curdir, 'images/pause.gif')) + + app = Player(song_path, master=root) + app.mainloop() \ No newline at end of file diff --git a/scripts/checksum/README.md b/scripts/checksum/README.md new file mode 100644 index 0000000..4737b31 --- /dev/null +++ b/scripts/checksum/README.md @@ -0,0 +1,29 @@ +# Checksum + +This script can generate checksums from md5, sha1, sha224, sha256, sha384, and sha512. +Additionally, for another layer of secret it can create signed checksums using HMAC and a provided secret. +Lastly, to provide actual value to the script it can also verify if a checksum matches the file it was generated from. + +Examples: + +Generate a sha1 checksum +``` +python checksum.py -H sha1 -f test.txt -g +# b29d28bc5239dbc2689215811b2a73588609f301 +``` + +Generate a signature +``` +python checksum.py -f test.txt -s secret +# 3YYMCthY4hFxQj1wPF3uAg== +``` + +Verify a checksum +``` +python -H sha1 -f test.txt -v b29d28bc5239dbc2689215811b2a73588609f301 +``` + +Verify a signature +``` +python -f test.txt -s secret -v 3YYMCthY4hFxQj1wPF3uAg== +``` \ No newline at end of file diff --git a/scripts/checksum/checksum.py b/scripts/checksum/checksum.py new file mode 100644 index 0000000..eca87d5 --- /dev/null +++ b/scripts/checksum/checksum.py @@ -0,0 +1,92 @@ +import os +import sys +import hmac +import base64 +import hashlib +import argparse + +def checksum(hash, seed=None): + hashs = { + "md5": hashlib.md5, + "sha1": hashlib.sha1, + "sha224": hashlib.sha224, + "sha256": hashlib.sha256, + "sha384": hashlib.sha384, + "sha512": hashlib.sha512 + } + method = hashs.get(hash, hashlib.md5)() + if seed is not None: + method.update(seed.encode("utf-8")) + else: + method.update(os.urandom(32)) + return method.hexdigest() + +def sign(hash, message, secret): + hashs = { + "md5": hashlib.md5, + "sha1": hashlib.sha1, + "sha224": hashlib.sha224, + "sha256": hashlib.sha256, + "sha384": hashlib.sha384, + "sha512": hashlib.sha512 + } + method = hashs.get(hash, hashlib.md5)() + digest = hmac.new(secret.encode("utf-8"), + msg=message.encode(), + digestmod=hashs.get(hash, hashlib.md5)).digest() + signature = base64.b64encode(digest).decode("utf-8") + return signature + +def verify(hash, input, check, secret=None): + challenge = None + if secret is not None: + challenge = sign(hash, input, secret) + else: + challenge = checksum(hash, input) + return "Valid! :D" if challenge == check else "Invalid :(" + +def main(): + description = "Checksum tool to generate, sign, and verify" + parser = argparse.ArgumentParser(description=description) + parser.add_argument("-g", "--generate", dest="generate", + action="store_true", help="Generates checksum") + parser.add_argument("-s", "--sign", dest="sign", default=None, + help="Signs input using HMAC") + parser.add_argument("-H", "--hash", dest="hash", default="md5", + help="Hash method (md5, sha1, sha224, sha256, sha384, sha512)") + parser.add_argument("-v", "--verify", dest="verify", default=None, + help="Checksum or signature used to verify against file / stdin") + parser.add_argument("-f", "--file", dest="file", + type=argparse.FileType("r"), default=sys.stdin, + help="File / stdin to create checksum, make signature, or verify from") + arguments = parser.parse_args() + + if arguments.verify is not None: + if not arguments.file: + print("Missing input to generate checksum from") + sys.exit(1) + if arguments.sign is not None: + print(verify(arguments.hash, arguments.file.read(), + arguments.verify, arguments.sign)) + return + else: + print(verify(arguments.hash, arguments.file.read(), + arguments.verify)) + return + elif arguments.generate: + if not arguments.file: + print("Missing input to generate checksum from") + sys.exit(1) + print(checksum(arguments.hash, arguments.file.read())) + return + elif arguments.sign is not None: + if not arguments.file: + print("Missing input to generate checksum from") + sys.exit(1) + print(sign(arguments.hash, arguments.file.read(), arguments.sign)) + return + print("Missing function (-g, -s, -v)") + sys.exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/scripts/csv_to_json/README.md b/scripts/csv_to_json/README.md deleted file mode 100644 index 5f2d167..0000000 --- a/scripts/csv_to_json/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# CSV to EXCEL -This simple script will convert CSV file to json. - -## Usage - -* requires pandas -* Use `pip install pandas` -* Run `python script.py` diff --git a/scripts/csv_to_json/script.py b/scripts/csv_to_json/script.py deleted file mode 100644 index 7f8e6b0..0000000 --- a/scripts/csv_to_json/script.py +++ /dev/null @@ -1,15 +0,0 @@ -import pandas as pd -import os,json - -def csv_to_json(): - file = input("Enter csv path: ") - df = pd.read_csv(file) - name=os.path.basename(file).replace("csv","json") - data =df.to_dict("r") - with open(file,'w') as f: - json.dump(df, d) - - print(f"file saved at {name}") - - -csv_to_json() \ No newline at end of file diff --git a/scripts/typing-speed-checker/README.md b/scripts/typing-speed-checker/README.md deleted file mode 100644 index 1c1c9db..0000000 --- a/scripts/typing-speed-checker/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Typing Speed Checker - -You can check someone's typing speed with this simple Python script. It uses python's inbuild time module to test the user's typing speed. diff --git a/scripts/typing-speed-checker/main.py b/scripts/typing-speed-checker/main.py deleted file mode 100644 index 35be6fb..0000000 --- a/scripts/typing-speed-checker/main.py +++ /dev/null @@ -1,32 +0,0 @@ -from time import time - -print("PARAGRAPH:") -print() - -typingString = "Medical transcription, also known as MT, is an allied health profession dealing with the process of transcribing voice-recorded medical reports that are dictated by physicians, nurses and other healthcare practitioners. Medical reports can be voice files, notes taken during a lecture, or other spoken material." - -words = len(typingString.split()) - -print(typingString) - -print("\nAfter finishing the test, press the enter key to see your time and speed (in WPM)") -input("\nPress any key to Start:") - -try: - print("\nTimer Started\n") - start = time() - t = input() - end = time() - if t == typingString: - total = round(end - start, 2) - print("\nCongrats! You typed everything correctly.") - print("You took was %s seconds" % total) - total = int(total) / 60 - print("Your speed was %s wpm" % (str(words // total))) - - else: - print("\nWrongly entered") - print("Try again") - -except KeyboardInterrupt: - print("") \ No newline at end of file