This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
const HOST = "/path/to/url/"; | |
addEventListener("trix-attachment-add", function (event) { | |
if (event.attachment.file) { | |
event.attachment.file | |
uploadFileAttachment(event.attachment) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import morgan, { StreamOptions } from "morgan"; | |
import winston from "winston"; | |
const levels = { | |
error: 0, | |
warn: 1, | |
info: 2, | |
debug: 3, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Due to the flexible nature of Flask. This might be __init__.py | |
from .extensions import huey | |
def create_app(): | |
app = Flask(__name__) | |
# add your configurations | |
# app.config.from_object("settings.local") | |
huey.init_app(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_image_from_b64(b64_image): | |
file_name = secrets.token_hex(6) | |
file_data = b64_image.split(",")[-1].encode() | |
file_type = b64_image.split(",")[0].split(";")[0].split("/")[-1] or "png" | |
with open("{}/{}.{}".format(app.config["UPLOAD_FOLDER"], file_name, file_type), "wb") as f: | |
f.write(base64.decodebytes(file_data)) | |
return "{}.{}".format(file_name, file_type) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
contract Ballot { | |
struct Voter { | |
uint weight; | |
bool voted; | |
uint8 vote; | |
address delegate; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
) | |
type KeyValueSlice map[string]float64 | |
func main() { |
OlderNewer