Skip to content

Instantly share code, notes, and snippets.

View yshalsager's full-sized avatar

Youssif Shaaban Alsager yshalsager

View GitHub Profile
@yshalsager
yshalsager / binaamanhaji.js
Last active February 26, 2023 15:01
Binaa Manhaji Download Questions as CSV
// ==UserScript==
// @name Binaa Manhaji Download Questions as CSV
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds a download button to binaamanhaji quiz pages to get all questions as CSV file, so they can be imported to Anki.
// @author yshalsager
// @match *://*.binaamanhaji.com/usercontrol/excercise?lesson_id=*
// @match *://*.binaamanhaji.com/usercontrol/exam*
// @icon https://www.google.com/s2/favicons?sz=64&domain=binaamanhaji.com
// @grant none
#!/bin/bash
# Scrapes mp3 files links from audio.islamweb.com links into csv data: url, filename
function islamweb_get_mp3() {
URL=$1
PAGES="${2:-1}"
for page in $(seq 1 $PAGES); do
case $URL in
*pageno=*)
URL=$(echo $URL | sed "s|pageno=[0-9]\+|pageno=$page|g");;
*)
@yshalsager
yshalsager / srt2txt.sh
Created December 10, 2021 08:48
A bash function to convert srt subtitle files to text files
# sed -r -e 's/\r$//;/^[0-9]+$/{N;/\n[0-9]/d;}' -> remove lines with timestamps
# sed -e '/^$/d' -> remove empty lines
# perl -p -e 's|(.*[^\.]$)\n|\1 |g' -> remove new line between paragragh lines.
# ${1%.*} -> input filename without extension
function srt2txt() {
cat $1 | sed -r -e 's/\r$//;/^[0-9]+$/{N;/\n[0-9]/d;}' | sed -e '/^$/d' | perl -p -e 's|(.*[^\.]$)\n|\1 |g' > "${1%.*}".txt
}
@yshalsager
yshalsager / 7a9ad_scraper.py
Created July 6, 2021 16:23
Scraps quran pictures links from 7a9ad website into text file.
#!/usr/bin/env python3
from urllib.parse import urlparse
from requests import get
from bs4 import BeautifulSoup
from requests.api import head
def get_url_hostname(url):
parsed_uri = urlparse(url)
return f'{parsed_uri.scheme}://{parsed_uri.netloc}'
#!/usr/bin/env python3
from humanize import naturalsize
from requests import get
org = ""
org_size = []
repo_count = 0
response = get(f"https://api.github.com/orgs/{org}/repos")
@yshalsager
yshalsager / scraper.py
Created May 15, 2020 22:43
princeofwales speeches scraper
from requests import get
from bs4 import BeautifulSoup
site = "https://www.princeofwales.gov.uk"
url = f"{site}/biographies/hrh-prince-wales/speeches?title=&mrfs=All&date_from=&date_to=&page="
for page in range(0, 77): # hardcoded page number
print(page)
speeches = BeautifulSoup(get(f"{url}{page}").content, "html.parser").select("div.views-row > div:nth-child(1) > h2:nth-child(1) > a:nth-child(1)")
@yshalsager
yshalsager / scraper.py
Created May 15, 2020 22:41
Webscraper that gets Quran Ayah translation from http://corpus.quran.com/translation.jsp
#!/usr/bin/env python3
from requests import get
from bs4 import BeautifulSoup
chapter = input("Enter Sura number\n")
url = f"http://corpus.quran.com/translation.jsp?chapter={chapter}"
page = BeautifulSoup(get(f'{url}&verse=1').content, "html.parser")
verses = int(page.select_one("#verseList > option:last-of-type")['value'])
#!/usr/bin/env python3.7
"""
A script that calcuate sum of github organization's repositories stargazers
"""
from requests import get
ORG = "XiaomiFirmwareUpdater"
START_PAGE = 1
END_PAGE = 2
### Keybase proof
I hereby claim:
* I am yshalsager on github.
* I am yshalsager (https://keybase.io/yshalsager) on keybase.
* I have a public key ASBzAw86UrjzbEdWDjWwRPQI7yeao0X4oU-S11iVhWhrlAo
To claim this, I am signing this object:
Verifying my Blockstack ID is secured with the address 12TKkXSM5XoGRNuqt21c9CvFMfQwRXFD9b https://explorer.blockstack.org/address/12TKkXSM5XoGRNuqt21c9CvFMfQwRXFD9b