Skip to content

Instantly share code, notes, and snippets.

View yshalsager's full-sized avatar

Youssif Shaaban Alsager yshalsager

View GitHub Profile
@yshalsager
yshalsager / calc_weight.py
Created April 4, 2024 03:53
Steps to create an Arabic dictionary for AOSP keyboard from shamela.ws
import sys
from pathlib import Path
import re
# Check if a file name is provided
if len(sys.argv) < 2:
print("Usage: python calc_weight.py <filename>")
sys.exit(1)
filename = Path(sys.argv[1])
@yshalsager
yshalsager / AnySoftKeyboard_to_HeliBoard.md
Last active March 31, 2024 21:31
Migrating AnySoftKeyboard user words history to HeliBoard

Migrating AnySoftKeyboard user words history to HeliBoard

  • Get a copy from AnySoftKeyboard user words (in app settings there's an option to open its location)
  • You need Python and Java JRE.
  • Run this python code, you can adjust file path to your xml correct one.
from xml.etree import ElementTree as etree
from pathlib import Path

<<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

@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
# 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 / 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()
@yshalsager
yshalsager / islamweb_audio_copy_links.js
Created June 4, 2023 14:26
Islamweb extract audio with names
@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
}