Skip to content

Commit

Permalink
Updated many scripts and organised few
Browse files Browse the repository at this point in the history
  • Loading branch information
jassics committed Jul 20, 2024
1 parent 8f07bac commit 6ddd767
Show file tree
Hide file tree
Showing 103 changed files with 72,185 additions and 378 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Real world examples are the examples which you would see around you in regular b
- Similarly check pip version `pip --version`. It should point to Python3.x
- If you get module name not found error, try to install that named module as `pip install module-name`
- If you are getting any other error mail me. I would add those steps here.
- for tkinter to work in MacOs, you need to run `brew install python-tk`
- If speech recognition is not working, try `pip3 install SpeechRecognition` and `pip3 install pyaudio`
- distutils module stopped working in python3.12

## Contact(s)/ Contributor(s)
1. Sanjeev Jaiswal
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 1 addition & 11 deletions basic-concepts/11-class.py → basic_concepts/11-class.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def __init__(self):
self.display = "1080p"
self.battery = "60 WHr"
self.storage = "256 GB SSD"


def setSpecifications(self,specs:dict):
try:
Expand All @@ -35,9 +34,6 @@ def getSpecifications(self):
print(f"Battery: {self.battery}")
print(f"Storage: {self.storage}")




"""
Single-level Inheritance
(Child Class)
Expand All @@ -48,7 +44,7 @@ def __init__(self,specs:dict):
#Set the passed specs
super().setSpecifications(specs)

# Gaming laptoip features (extra)
# Gaming laptop features (extra)
self.refresh_rate = "144 Hz"
self.response_time = "2ms"

Expand All @@ -57,11 +53,6 @@ def getGamingSpecs(self):
print(f"Refresh Rate: {self.refresh_rate}")
print(f"Response Time: {self.response_time}")






if __name__ == "__main__":

gaming_specs = {
Expand All @@ -74,6 +65,5 @@ def getGamingSpecs(self):
}

# "model": "ASUS TUF Gaming A15",

gl = GamingLaptop(specs=gaming_specs)
gl.getGamingSpecs()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions check-all-is-well.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import socket
import os
import requests
import nmap3 # pip install python3-nmap

"""
First Python Program
Just to see if we can run python3 successfully
and modules are installed or not ;)
"""

name = "Sanjeev"
print("Hello "+name+"\n")
print("O.S. is: " + os.name)

hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
public_ip = requests.get('https://checkip.amazonaws.com').text.strip()
print("Your Computer Name is:" + hostname)
print("Your Computer Local IP Address is:" + local_ip)
print("Your Computer Public IP Address is:" + public_ip)
print("\nChecking if nmap works:\nStarting nmap scan now...\n")

# make nmap object
nmap = nmap3.Nmap()

#nmap version
nmap_version = nmap.nmap_version()
print (f"Nmap version: {nmap_version}")

# scanning practical-devsecops.com
url = 'aliencoders.org'
""""
print("Starting nmap scan for url: " + url)
results = nmap.nmap_version_detection(url)
print(f"Here is the result for {url}: {results}")
"""
top_ports = nmap.scan_top_ports(url, args="-sV")
print(f"These are the top ports: {top_ports}")
15 changes: 15 additions & 0 deletions cryptography/crypto_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from cryptography.fernet import Fernet

key = Fernet.generate_key()
cipher_suite = Fernet(key)
message = "This is a secret message for a secret group. Not for crackers, but may be for Cryptanalyst!.".encode()

cipher_text = cipher_suite.encrypt(message)
print('Cipher Text is: ' + str(cipher_text))

plain_text = cipher_suite.decrypt(cipher_text)
print('Here is the plain text:' + str(plain_text))

print('\nChecking if decrypted text is same as our message or not')

if plain_text == message: print("Yes both are same\n")
1 change: 0 additions & 1 deletion docs/_config.yml

This file was deleted.

38 changes: 0 additions & 38 deletions docs/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion exercises/city_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime

# asking the user for api key
api_key = input("Please Enter Your API: ")
api_key = input("Please Enter Your API Key (get it from openweathermap.org): ")

#asking the user for city name
city_name = input("Please Enter Your City Name: ")
Expand Down
15 changes: 0 additions & 15 deletions exercises/get_time_from_utc.py

This file was deleted.

Binary file added python_for_web_security_v1.pdf
Binary file not shown.
55 changes: 0 additions & 55 deletions real-world-examples/alexa_rank.py

This file was deleted.

20 changes: 0 additions & 20 deletions real-world-examples/generate_password.py

This file was deleted.

Binary file removed real-world-examples/text2speech/page25.mp3
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# this regex would also work as it with positive lookbehind (?:[^/][\d\w\.-]+)$(?<=\.\w{3,4})
# file name with extension
matched_file = re.search("(?=[\w\d-]+\.\w{3,4}$).+", file_url) # regex with positive lookahead
matched_file = re.search("(?=[\\w\\d-]+\\.\\w{3,4}$).+", file_url) # regex with positive lookahead
if matched_file is not None:
file_name_with_extension = matched_file.group(0)
else:
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions real_world_examples/generate_password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import string
import secrets

def get_alphabet():
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation

# Alphabet is the combination of letters, digits and special characters
alphabet = letters + digits + special_chars
return alphabet

# Password constraints
# define password length, must be more than 8 chars
# at least 1 upper case, 1 lower case, 1 digit and 1 special character
password_len = int(input("Give password length(8 or more): "))
if password_len <8:
exit("Length must be at least 8 characters")
password = ''

for i in range(password_len):
password += ''.join(secrets.choice(get_alphabet()))

print(f"Password is: {password}")

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
# Save the links in a file
# just get the domain name and create a file by domain name with -links.txt
domain_name = url.split('//')[1]
print(f"domain name: {domain_name}")
file_name = domain_name + '-links.txt'

with open(file_name, 'w+') as file_to_write:
for link in all_links:
href_link = link.get('href')
if re.search("facebook|fb|instagram|linkedin|twitter|google|telegram|whatsapp|pinterest|goo\.gl|baidu", href_link) is None:
if re.search("facebook|fb|instagram|linkedin|twitter|google|telegram|whatsapp|pinterest|goo\\.gl|baidu", href_link) is None:
file_to_write.write(href_link + "\n")
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6ddd767

Please sign in to comment.