Skip to content

Instantly share code, notes, and snippets.

View asadamatic's full-sized avatar
🎯
Focusing

ASAD HAMEED asadamatic

🎯
Focusing
  • Islamabad, Pakistan
  • 14:21 (UTC +05:00)
View GitHub Profile
@asadamatic
asadamatic / main.dart
Created March 22, 2024 04:53
UI to Flutter Code Using ChatGpt Plus.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@asadamatic
asadamatic / extendedFileSearch.py
Created April 16, 2020 12:26
Searching for a file in a directory with sub directories and returning file paths using python.
import os, os.path
def extendedFileSearch(requiredFile):
filePaths = []
for file in os.listdir():
@asadamatic
asadamatic / fileSearch.py
Created April 16, 2020 12:24
Finding a file in current working directory using python.
import os
def searchFile(requiredFile):
if requiredFile in os.listdir():
return True
else:
@asadamatic
asadamatic / audioRecording.py
Created April 14, 2020 11:12
Python script to record audio using 'sounddevice' module.
import sounddevice as sound
from scipy.io.wavfile import write
duration = 5
sampleRate = 4100
sound.default.samplerate = sampleRate
sound.default.channels = 2
@asadamatic
asadamatic / SpamFilter.py
Created March 31, 2020 12:27
This is a spam messages filter is based on naive Bayes Classifier.
spamMessage = {'million': 156, 'dollars': 29, 'adclick': 51, 'conferences': 2}
hamMessage = {'million': 98, 'dollars': 119, 'adclick': 1, 'conferences': 12}
spamWordCount = 95791
hamWordCount = 306438
probabilitySpam = 0.00
probabilityHam = 0.00
def likelihood(word):
@asadamatic
asadamatic / readCompletePdf.py
Created March 19, 2020 11:49
Python program to extract all the text from a pdf file and saving it as a text file. I have used PyPDF2 library for this module.
from PyPDF2 import PdfFileReader
fileName = '' #Enter the name of pdf file here
with open(fileName + '.pdf', 'rb') as pdf:
pdfReader = PdfFileReader(pdf)
totalPages = pdfReader.numPages
@asadamatic
asadamatic / readSinglePdfPage.py
Created March 19, 2020 11:18
Python program to extract data from a specific page of a pdf file. I have used PyPDF2 library for this module.
from PyPDF2 import PdfFileReader
with open('Sommerville-Software-Engineering-10ed.pdf', 'rb') as pdf:
pdfReader = PdfFileReader(pdf)
page = pdfReader.getPage(0)
pageText = page.extractText()
@asadamatic
asadamatic / textFileToAudio.py
Created March 19, 2020 11:01
A python program that reads text from a file and converts it to audio, saves it and plays it using default audio player.
from gtts import gTTS
import os
with open('message.txt') as file:
message = file.read()
output = gTTS(text = message, lang = 'hi', slow = False)
output.save('messageFromFile.mp3')
@asadamatic
asadamatic / sayHello.py
Created March 19, 2020 10:48
A python program that converts a text message to audio, saves it and plays it using default audio player.
from gtts import gTTS
import os
message = 'Hello Asad!'
output = gTTS(text = message, lang= 'en', slow = False)
output.save('sayHello.mp3')
os.system('start sayHello.mp3')
@asadamatic
asadamatic / downloadImages.py
Created March 5, 2020 05:09
Code to download multiple images using requests library in python.
import requests
import time
imageUrls = ['https://images.unsplash.com/photo-1558981396-5fcf84bdf14d',
'https://images.unsplash.com/photo-1583314059352-663691cfa23f',
'https://images.unsplash.com/photo-1583314238585-21664bba94ab',
'https://images.unsplash.com/photo-1583317094917-8aac805fed5a' ,
'https://images.unsplash.com/photo-1583307266943-e0055bb40037' ]