Skip to content

Instantly share code, notes, and snippets.

View alrafiabdullah's full-sized avatar
🏠
Working from home

Abdullah Al Rafi alrafiabdullah

🏠
Working from home
View GitHub Profile
@alrafiabdullah
alrafiabdullah / ses_email.py
Created October 3, 2022 08:11
Sending email using AWS SES and python.
import boto3
from botocore.exceptions import ClientError
def send_email_using_ses(email, name, subject, body):
"""Send an email using Amazon SES.
:param email: The recipient's email address.
:param subject: The subject of the email.
:param body: The body of the email.
@alrafiabdullah
alrafiabdullah / rename_file_name.py
Created March 19, 2022 19:55
Renames file names with specific instructions.
import os
FILE_LOC = "FILE_LOCATION"
# read all the file name from FILE_LOC
def read_file_name():
file_name = []
for file in os.listdir(FILE_LOC):
file_name.append(file)
@alrafiabdullah
alrafiabdullah / review.php
Last active November 28, 2021 13:52
Review page of CSE482 using PHP. Many useful code snippets are here.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Review</title>
<link rel="shortcut icon" href="assets/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
@alrafiabdullah
alrafiabdullah / readability.c
Created May 29, 2021 21:04
Readability checker written with C, according to Scholastic standards.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int letterCounter(char paragraph[], int);
int wordCounter(char paragraph[], int);
int sentenceCounter(char paragraph[], int);
@alrafiabdullah
alrafiabdullah / scrabble.c
Created May 29, 2021 19:28
A scrabble game made with C.
#include <ctype.h>
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Points assigned to each letter of the alphabet
int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
int compute_score(string word);
@alrafiabdullah
alrafiabdullah / credit.c
Created May 28, 2021 20:38
A script written with C to check the validity of a credit card number by using Luhn's Algorithm.
/*
Most cards use an algorithm invented by Hans Peter Luhn of IBM. According to Luhn’s algorithm, you can determine if a credit card number is (syntactically) valid as follows:
1. Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products’ digits together.
2. Add the sum to the sum of the digits that weren’t multiplied by 2.
3. If the total’s last digit is 0 (or, put more formally, if the total modulo 10 is congruent to 0), the number is valid!
*/
#include <stdio.h>
@alrafiabdullah
alrafiabdullah / main.py
Created April 12, 2021 10:13
A command line YouTube video downloader using pytube library.
# pip install git+https://github.com/nficano/pytube@5d2c1a4e756cd8bac373867bf673155e691f1e04
from pytube import YouTube
import time
start_time = time.time()
previous = 0
for mkv in mkv_list:
name, ext = os.path.splitext(mkv)
if ext != ".mkv":
raise Exception("Please add MKV files only!")
output_name = name + ".mp4"
try:
subprocess.run(
["ffmpeg", "-i", f"assets/{mkv}", "-codec", "copy", f"result/{output_name}"], check=True
)
import os
import subprocess
if not os.path.exists("assets"):
raise Exception("Please create and put all your vidoes in assets folder!")
mkv_list = os.listdir("assets")
if not os.path.exists("result"):
os.mkdir("result")
import os
import subprocess
if not os.path.exists("assets"):
raise Exception("Please create and put all your vidoes in assets folder!")
mkv_list = os.listdir("assets")
if not os.path.exists("result"):
os.mkdir("result")