Skip to content

Instantly share code, notes, and snippets.

View prettyirrelevant's full-sized avatar
💭
???

Isaac Adewumi prettyirrelevant

💭
???
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@prettyirrelevant
prettyirrelevant / zlib_scraper.py
Last active January 28, 2021 18:17
A script that scrapes b-ok.africa for books
import requests
from bs4 import BeautifulSoup
Z_LIB = "https://b-ok.africa"
def scrape_zlib(query):
response = []
url = f"{Z_LIB}/s/{query}"
page = requests.get(url)
@prettyirrelevant
prettyirrelevant / trix_attach.js
Created November 24, 2020 14:42
my version of trix editor attachment.js
(function () {
const HOST = "/path/to/url/";
addEventListener("trix-attachment-add", function (event) {
if (event.attachment.file) {
event.attachment.file
uploadFileAttachment(event.attachment)
}
})
@prettyirrelevant
prettyirrelevant / time_to_read.py
Created November 24, 2020 14:39
a python script that calculates the time it'll take to read a given text( i think it's buggy)
def get_time_to_read(text: str):
striped_text = strip_tags(text)
word_cleaned = re.sub(r" /[^\w ]/g", "", striped_text)
word_count = len(word_cleaned.split(" "))
reading_time = math.floor(word_count / 200)
if reading_time <= 1:
return f"{str(reading_time)} min"
else:
return f"{str(reading_time)} mins"
@prettyirrelevant
prettyirrelevant / clean_html.py
Created November 24, 2020 14:38
a python script to clean an input of html and return just text
class ParseHTML(HTMLParser):
def __init__(self):
super().__init__()
self.reset()
self.strict = False
self.convert_charrefs = True
self.text = StringIO()
def handle_data(self, d):
self.text.write(d)