From 9ded49046f04e2d2cf170d5a6e5baec427ba3a38 Mon Sep 17 00:00:00 2001 From: Aarya Chopkar Date: Tue, 4 Oct 2022 15:51:14 +0530 Subject: [PATCH 1/9] Added Snake game to play --- scripts/SnakeGame/SnakeGame.md | 10 ++ scripts/SnakeGame/SnakeGame.py | 175 +++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 scripts/SnakeGame/SnakeGame.md create mode 100644 scripts/SnakeGame/SnakeGame.py diff --git a/scripts/SnakeGame/SnakeGame.md b/scripts/SnakeGame/SnakeGame.md new file mode 100644 index 0000000..0f67829 --- /dev/null +++ b/scripts/SnakeGame/SnakeGame.md @@ -0,0 +1,10 @@ +## Snake Game +GUI based Snake game, where you can play it directly without installing any dependencies. + +## How to install? +`1.` Download the file rock_paper_scissor.py +`2.` Open CMD (Command Prompt) +`3.` Run python rock_paper_scissor.py +`4.` Follow the instructions and enjoy! + +Enjoy and play with your friends \ No newline at end of file diff --git a/scripts/SnakeGame/SnakeGame.py b/scripts/SnakeGame/SnakeGame.py new file mode 100644 index 0000000..18825c2 --- /dev/null +++ b/scripts/SnakeGame/SnakeGame.py @@ -0,0 +1,175 @@ +import turtle +import time +import random + +delay = 0.1 +score = 0 +high_score = 0 + +#Window Screen +wn = turtle.Screen() +wn.title("SNAKE GAME") +wn.bgcolor("black") + +wn.setup(width=600,height=600) +wn.tracer(0) + +#Head of Snake +head = turtle.Turtle() +head.shape("square") +head.color("green") +head.penup() +head.goto(0, 0) +head.direction = "stop" + +#Food in the game +food = turtle.Turtle() +food.speed(0) +food.shape("circle") +food.color("red") +food.penup() +food.goto(0, 100) + +#Score +pen = turtle.Turtle() +pen.speed(0) +pen.shape("turtle") +pen.color("white") +pen.penup() +pen.hideturtle() +pen.goto(0, 250) +pen.write("Score : 0 High Score : 0", align="center", + font=("Times New Roman", 24, "bold")) + + +#Assigning key values +def goup(): + if head.direction != "down": + head.direction = "up" + +def godown(): + if head.direction != "up": + head.direction = "down" + +def goright(): + if head.direction != "left": + head.direction = "right" + +def goleft(): + if head.direction != "right": + head.direction = "left" + +def move(): + if head.direction == "up": + y = head.ycor() + head.sety(y+20) + + if head.direction == "down": + y = head.ycor() + head.sety(y-20) + + if head.direction == "right": + x = head.xcor() + head.setx(x+20) + + if head.direction == "left": + x = head.xcor() + head.setx(x-20) + +wn.listen() +wn.onkeypress(goup, "Up") +wn.onkeypress(godown, "Down") +wn.onkeypress(goleft, "Left") +wn.onkeypress(goright, "Right") + + +#Main Loop +segments = [] + +while True: + wn.update() + #for collisions with border + if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290: + time.sleep(1) + head.goto(0, 0) + head.direction = "stop" + + #hiding segments of snake + for segment in segments: + segment.goto(1000,1000) + #clearing the segments + segments.clear() + + #reset score + score = 0 + + #reset delay + delay = 0.1 + + pen.clear() + pen.write("Score : {} High Score : {} ".format( + score, high_score), align="center", font=("Times New Roman", 24, "bold")) + + #checking collision with food + if head.distance(food) < 20: + x = random.randint(-270, 270) + y = random.randint(-270, 270) + food.goto(x, y) + d = ["red","yellow","blue"] + colors = random.choice(d) + food.color(colors) + e = ["circle","square","triangle"] + shapes = random.choice(e) + food.shape(shapes) + + + #adding new segment + new_segment = turtle.Turtle() + new_segment.speed(0) + new_segment.color("green") + new_segment.shape("square") + new_segment.penup() + segments.append(new_segment) + + delay -= 0.001 + score += 10 + + if score>high_score: + high_score = score + pen.clear() + pen.write("Score : {} High Score : {} ".format( + score, high_score), align="center", font=("Times New Roman", 24, "bold")) + + #moving segments in reverse order + for i in range(len(segments)-1,0,-1): + x = segments[i-1].xcor() + y = segments[i-1].ycor() + segments[i].goto(x,y) + if len(segments) > 0: + x = head.xcor() + y = head.ycor() + segments[0].goto(x, y) + + move() + + #Checking collisions with body + for segment in segments: + if segment.distance(head) < 20: + time.sleep(1) + head.goto(0,0) + head.direction = "stop" + + #hide segments + for segment in segments: + segment.goto(1000,1000) + segment.clear() + + score = 0 + delay = 0.1 + pen.clear() + pen.write("Score : {} High Score : {} ".format( + score, high_score), align="center", font=("Times New Roman", 24, "bold")) + time.sleep(delay) + +turtle.done() + From a12b9931cad0c0658bfbc9f8e0cb562f9306d846 Mon Sep 17 00:00:00 2001 From: mclmza Date: Tue, 4 Oct 2022 13:54:56 +0200 Subject: [PATCH 2/9] Added crawl Google search --- scripts/Crawl Google Results/README.md | 9 +++++++++ scripts/Crawl Google Results/main.py | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 scripts/Crawl Google Results/README.md create mode 100644 scripts/Crawl Google Results/main.py diff --git a/scripts/Crawl Google Results/README.md b/scripts/Crawl Google Results/README.md new file mode 100644 index 0000000..17fe464 --- /dev/null +++ b/scripts/Crawl Google Results/README.md @@ -0,0 +1,9 @@ +# Crawl Google results +This is a simple script that lets you collect results provided by Google. + +## Usage + +* 3 packages required requests, BeautifulSoup and fake_useragent +* Use `pip install requests`, `pip install bs4` and `pip install fake_useragent` +* Add path to your csv file and output excel file WITH EXTENSTION `.csv` and `.xlsx` +* Run `python main.py "query search"` diff --git a/scripts/Crawl Google Results/main.py b/scripts/Crawl Google Results/main.py new file mode 100644 index 0000000..8937182 --- /dev/null +++ b/scripts/Crawl Google Results/main.py @@ -0,0 +1,24 @@ +import sys +import webbrowser + +import requests +from bs4 import BeautifulSoup +from fake_useragent import UserAgent + +if __name__ == "__main__": + print("Googling.....") + url = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) + res = requests.get(url, headers={"UserAgent": UserAgent().random}) + # res.raise_for_status() + with open("project1a.html", "wb") as out_file: # only for knowing the class + for data in res.iter_content(10000): + out_file.write(data) + soup = BeautifulSoup(res.text, "html.parser") + links = list(soup.select(".eZt8xd"))[:5] + + print(len(links)) + for link in links: + if link.text == "Maps": + webbrowser.open(link.get("href")) + else: + webbrowser.open(f"http://google.com{link.get('href')}") \ No newline at end of file From 667ffa6742c15e411751d08fe127140544fbfdaa Mon Sep 17 00:00:00 2001 From: Advaita Saha Date: Tue, 4 Oct 2022 20:23:44 +0530 Subject: [PATCH 3/9] Create checker.yml --- .github/workflows/checker.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/checker.yml diff --git a/.github/workflows/checker.yml b/.github/workflows/checker.yml new file mode 100644 index 0000000..24f4a90 --- /dev/null +++ b/.github/workflows/checker.yml @@ -0,0 +1,19 @@ +name: Check if a PR has a valid Issue + +on: + pull_request_target: + types: [ edited, synchronize, opened, reopened ] + +jobs: + checker: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Issue Validator + uses: HarshCasper/validate-issues-over-pull-requests@v0.1.1 + id: validator + with: + prbody: ${{ github.event.pull_request.body }} + prurl: ${{ github.event.pull_request.url }} From e9e90e61335a17eaefe48c6ced59cc03494433bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Oct 2022 14:53:56 +0000 Subject: [PATCH 4/9] docs(contributor): contrib-readme-action has updated readme --- README.md | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cd4b662..fe7233b 100644 --- a/README.md +++ b/README.md @@ -116,21 +116,28 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Montek + + + Mr-DJ +
+ Samuel Jonathan +
+ agnxsh
Agnish Ghosh
- + + kriptonian1
Sawan Bhattacharya
- - + Prajwol-Shrestha @@ -165,15 +172,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Dishant Nagpal
- + + SiddheshKukade
Siddhesh Bhupendra Kuakde
- - + aswin2108 @@ -208,15 +215,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Heshanthaka
- + + sarthakroy2002
Sarthak Roy
- - + anjali1102 @@ -251,15 +258,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Yash Nilesh Brid
- + + mer747
Null
- - + smit-sms From 821ae33553d0a9e5bd250268af3a6dccc880e7dd Mon Sep 17 00:00:00 2001 From: Advaita Saha Date: Tue, 4 Oct 2022 20:25:10 +0530 Subject: [PATCH 5/9] Update checker.yml --- .github/workflows/checker.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checker.yml b/.github/workflows/checker.yml index 24f4a90..f7974b6 100644 --- a/.github/workflows/checker.yml +++ b/.github/workflows/checker.yml @@ -1,4 +1,4 @@ -name: Check if a PR has a valid Issue +name: PR has a valid Issue? on: pull_request_target: @@ -17,3 +17,21 @@ jobs: with: prbody: ${{ github.event.pull_request.body }} prurl: ${{ github.event.pull_request.url }} + + - name: PR has a valid Issue + if: ${{ steps.validator.outputs.valid == 1 }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PRNUM: ${{ github.event.pull_request.number }} + run: | + gh pr edit $PRNUM --add-label "PR:Ready-to-Review" + gh pr edit $PRNUM --remove-label "PR:No-Issue" + + - name: PR has no valid Issue + if: ${{ steps.validator.outputs.valid == 0 }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PRNUM: ${{ github.event.pull_request.number }} + run: | + gh pr comment $PRNUM --body "PR is not linked to any issue, please make the corresponding changes in the body." + gh pr edit $PRNUM --add-label "PR:No-Issue" From 75a97caa1716a7bb40dabb1e2a3fd618d5b57077 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:41:38 +0000 Subject: [PATCH 6/9] docs(contributor): contrib-readme-action has updated readme --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe7233b..7c6f6ef 100644 --- a/README.md +++ b/README.md @@ -202,21 +202,28 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Srinjoy Pati + + + accodes21 +
+ Aarya Chopkar +
+ akashJainAJ11
Akash Jain
- + + donheshanthaka
Heshanthaka
- - + sarthakroy2002 @@ -251,15 +258,22 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Null
- + + yashbrid03
Yash Nilesh Brid
- - + + + + mclmza +
+ Michele Mazza +
+ mer747 From 7e6db1a0098917f7f8d84a29dec4f3195955e0be Mon Sep 17 00:00:00 2001 From: Advaita Saha Date: Wed, 5 Oct 2022 04:14:10 +0530 Subject: [PATCH 7/9] Update checker.yml --- .github/workflows/checker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checker.yml b/.github/workflows/checker.yml index f7974b6..b78dcce 100644 --- a/.github/workflows/checker.yml +++ b/.github/workflows/checker.yml @@ -25,6 +25,7 @@ jobs: PRNUM: ${{ github.event.pull_request.number }} run: | gh pr edit $PRNUM --add-label "PR:Ready-to-Review" + gh pr edit $PRNUM --add-label "hacktoberfest-accepted" gh pr edit $PRNUM --remove-label "PR:No-Issue" - name: PR has no valid Issue From a3ee5241566d1f011e1b9edc158a4ad489f6ffb8 Mon Sep 17 00:00:00 2001 From: lordvader501 <60027612+lordvader501@users.noreply.github.com> Date: Wed, 5 Oct 2022 10:40:16 +0530 Subject: [PATCH 8/9] code to resize images --- scripts/Image_resizer/readme.md | 21 +++++++++++++++++++++ scripts/Image_resizer/resize.py | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 scripts/Image_resizer/readme.md create mode 100644 scripts/Image_resizer/resize.py diff --git a/scripts/Image_resizer/readme.md b/scripts/Image_resizer/readme.md new file mode 100644 index 0000000..b9d6920 --- /dev/null +++ b/scripts/Image_resizer/readme.md @@ -0,0 +1,21 @@ +# IMAGE RESIZER +### Resize image to partiular dimensions. + +This python code takes image that needs to be resised and it uses Pillow module to resize the image by given dimensions entered by user and saves the resized image. + +#### Requirements: +* Install Pillow module. +* run `pip install pillow` + +### Usage +* Clone the repo +* open the `Image-resizer` folder +* copy the image that you want to resize to this folder +* open cmd in `image-resizer` folder +##### for windows +* run `python resize.py` +##### for linux +* run `python3 resize.py` +* after that type the name of the image file in images folder (ex: img.jpg, pic.png...) +* enter the dimensions in the format(eg 1024x720 , 600x300...) +* now your resized image is saved in folder. diff --git a/scripts/Image_resizer/resize.py b/scripts/Image_resizer/resize.py new file mode 100644 index 0000000..16b38a4 --- /dev/null +++ b/scripts/Image_resizer/resize.py @@ -0,0 +1,11 @@ +from PIL import Image as img +import os + +file_name = input("Enter anpe of file: ") +name , ext = file_name.split('.') +pic = img.open((os.path.join(os.path.dirname(os.path.abspath(__file__)),file_name))) + +ht, wt= input("Enter dimenstions(eg: 1024x720): ").split('x') +dim = int(ht), int(wt) +img_resize = pic.resize(dim) +img_resize.save((os.path.join(os.path.dirname(os.path.abspath(__file__)),f'{name}_resized.{ext}'))) \ No newline at end of file From 30c4e3790fe6982f9ee6c3e07c7c1e532b418d4e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 5 Oct 2022 05:34:51 +0000 Subject: [PATCH 9/9] docs(contributor): contrib-readme-action has updated readme --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7c6f6ef..4c794a2 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻 Aswin Shailajan + + + lordvader501 +
+ Null +
+ noobyysauraj @@ -208,15 +215,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Aarya Chopkar
- + + akashJainAJ11
Akash Jain
- - + donheshanthaka @@ -251,13 +258,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
Null
- - - - lordvader501 -
- Null -