Skip to content

Instantly share code, notes, and snippets.

View ahmedbr's full-sized avatar
💻
Coding the FUTURE!

Ahmed Breem ahmedbr

💻
Coding the FUTURE!
View GitHub Profile
@ahmedbr
ahmedbr / leet.py
Last active August 25, 2023 17:42
LeetCode Exercises
def running_sum_arr_rec(arr, size):
"""
Running Sum of 1D Array - Recursively
"""
if size == 1:
print(arr[0], end=" ")
return arr[0]
res = running_sum_arr_rec(arr, size - 1) + arr[size - 1]
print(res, end=" ")
return res
@ahmedbr
ahmedbr / pdf2audio.py
Last active July 30, 2022 07:50
Convert a textual PDF file to an audio book using Pyhon
import PyPDF3
import pyttsx3
import pdfplumber
import os
pdf_file_path = r"path_to_pdf_file.pdf"
root, ext = os.path.splitext(pdf_file_path)
output_audio_file = root + ".mp3"
# get num of pages
@ahmedbr
ahmedbr / timeConverter.js
Created October 5, 2020 07:03
Convert a Unix timestamp to time in JavaScript
function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
@ahmedbr
ahmedbr / simple_speech_recognition.py
Last active June 5, 2020 07:34
Simple script to conduct a search in YouTube by voice using SpeechRecognition package in python
import speech_recognition as sr
import webbrowser
r1 = sr.Recognizer()
r2 = sr.Recognizer()
with sr.Microphone() as source:
print('Dictate some thing to search in YouTube..')
url = 'https://www.youtube.com/results?search_query='
The list of POS tags is as follows, with examples of what each POS stands for:
CC coordinating conjunction
CD cardinal digit
DT determiner
EX existential there (like: “there is” … think of it like “there exists”)
FW foreign word
IN preposition/subordinating conjunction
JJ adjective ‘big’
JJR adjective, comparative ‘bigger’
contractions = {
"ain't": "am not / are not / is not / has not / have not",
"aren't": "are not / am not",
"can't": "cannot",
"can't've": "cannot have",
"'cause": "because",
"could've": "could have",
"couldn't": "could not",
"couldn't've": "could not have",
"didn't": "did not",
@ahmedbr
ahmedbr / install_and_validate.txt
Created December 12, 2019 09:08
Using GPU with PyTorch
1- Install PyTorch from the below link. Make sure you select the right CUDA version installed on your device:
https://pytorch.org/
2- After a successful installation. Feel free to test the following commands in your Command Line:
C:\Users\AhmedBr>python
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.current_device()
0
@ahmedbr
ahmedbr / MainActivity.java
Created June 17, 2019 10:03
Android - Toolbar with SearchView
public class MainActivity extends AppCompatActivity {
ArrayAdapter arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
int x = 10;
int y = 5;
Console.WriteLine("Before swapping: x = " + x + ", y = " + y);
x = x + y;
y = x - y;
x = x - y;
Console.WriteLine("After swapping: x = " + x + ", y = " + y);
@ahmedbr
ahmedbr / Android - Check and Ask for Permission
Last active June 2, 2019 23:40
Checking whether WRITE_EXTERNAL_STORAGE permission is granted or not in run-time app.
// make sure that your Manifest file has the following line of code:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
// then in you Java code file:
private static final int REQUEST_STORAGE_PERMISSION = 1;
public void requestPermission() {
// if the permission is NOT granted.
if (ContextCompat.checkSelfPermission(this,