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 / ButtonPanel.java
Created June 24, 2020 10:22
Sudoku Graphical User Interface
package nl.elridge.sudoku.view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.Observable;
import java.util.Observer;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
@alrafiabdullah
alrafiabdullah / pdf.py
Created September 21, 2020 22:53
Create PDF from Images (Except .png)
import img2pdf # run pip install img2pdf
img = "" # Local image file location
f = open('output.pdf', 'wb')
f.write(img2pdf.convert(img)) # Writes pdf file in the root directory
f.close()
@alrafiabdullah
alrafiabdullah / youtube.py
Created February 14, 2021 18:44
A script to download audio file from YouTube link.
from pytube import YouTube
import validators
url = input("Enter a YouTube URL: ")
if not validators.url(url):
raise ValueError("Please enter a correct URL.")
if not "youtube" in url:
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")
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
)
@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
@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 / 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 / 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);