Skip to content

Instantly share code, notes, and snippets.

View yshalsager's full-sized avatar

Youssif Shaaban Alsager yshalsager

View GitHub Profile
#!/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 / 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}'
@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
}
#!/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 / 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
@yshalsager
yshalsager / islamweb_audio_copy_links.js
Created June 4, 2023 14:26
Islamweb extract audio with names
@yshalsager
yshalsager / alandals_scraper.py
Last active December 6, 2023 17:00
فتاوى نور على الدرب الصوتية
from pathlib import Path
import httpx
from parsel import Selector
root_url = "http://alandals.net"
response = httpx.get(f"{root_url}/Sections.php")
selector = Selector(response.text)
sections_links = selector.css("tr a::attr(href)").getall()
# pip install httpx parsel
from pathlib import Path
from httpx import get
from parsel import Selector
books_urls = Path('books_list.txt').read_text().splitlines()
download_urls = Path('download_urls.txt')
if download_urls.exists():
download_urls.unlink()
@yshalsager
yshalsager / albabtainlibrary_extract_books_urls.js
Created January 15, 2024 14:31
albabtainlibrary extract books urls
// ==UserScript==
// @name albabtainlibrary extract books urls
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Copy books pages URL from albabtainlibrary.
// @author yshalsager
// @match *://albabtainlibrary.org/zobair_list/
// @match *://albabtainlibrary.org/zobair_list/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=albabtainlibrary.org
// @run-at document-idle

<<Valentino Gagliardi - Decoupled Django_ Understand and Build Decoupled Django Architectures for JavaScript Front-ends-Apress (2021)>>Hypermedia All the Things 2024-02-16 11:45  |  Page No.: 21 As you can see, we say users, not user, when retrieving the resource. As a convention, resources should always be plural.

2024-02-16 11:47  |  Page No.: 22 some HTTP verbs are idempotent, meaning that the result of the operation is always stable.

2024-02-16 11:47  |  Page No.: 22 A POST request instead will always induce a side effect, that is, create a new resource

Cacheable 2024-02-16 11:57  |  Page No.: 24 A well-designed REST API should always give the client hints about the lifetime of a GET response. To do so, the backend sets a Cache-Control header on the response with a max-age directive,

2024-02-16 11:58  |  Page No.: 25 Cache-Control: max-age=3600