Skip to content

Instantly share code, notes, and snippets.

View Destaq's full-sized avatar
🔨
probably building~

Simon Ilincev Destaq

🔨
probably building~
View GitHub Profile
@Destaq
Destaq / .env
Created January 31, 2023 11:01
Graphically analyzes the most commonly learned language combinations on r/languagelearning based on user flairs
{
"username": "Reddit username",
"client_id": "Register a developer script on Reddit",
"client_secret": "See the above",
"password": "Your Reddit password"
}
@Destaq
Destaq / cultivation_visualization.py
Created October 4, 2022 18:54
Generate an SVG representation of a xianxia or xuanhuan cultivator's progress throughout a story by analyzing their book file
import random
import re
WEBNOVEL_SUBPATH = "《凡人修仙传》.txt"
WEBNOVEL_ENGLISH = "A Record of a Mortal's Journey to Immortality"
LEVELS = ["炼气", "筑基", "结丹", "元婴", "化神", "炼虚", "合体", "大乘"]
LEVELS_ENG = ["Qi Condensation", "Foundation Establishment", "Core Formation", "Nascent Soul", "Deity Transformation",
"Spatial Tempering", "Body Integration", "Grand Ascension"]
#####
@Destaq
Destaq / app.py
Created July 20, 2022 16:35
Nuxt 2 + Flask — full, working custom refresh scheme using cookies from flask-jwt-extended
@app.after_request
def refresh_expiring_jwts(response):
"""
Here we are supporting the implicit cookie refresh mechanism.
If a not-yet-expired access cookie (token) is sent with a request, it will be replaced
with one that is newly created, also for two weeks.
(Note that this will not work just by opening the app, the user also needs to do some actions).
"""
@Destaq
Destaq / graph_comprehension.py
Last active October 15, 2021 22:18
Graphs your total comprehension of a Chinese text file based on known vocabulary, number of words learnt per step, and other rules.
# generates a graph of the percentage known words of a text at every step
import argparse
from LAC import LAC
from plotly.subplots import make_subplots
import plotly.graph_objects as go
from collections import Counter
parser = argparse.ArgumentParser(
"Display a graph of your comprehension every *x* of a Chinese text file."
)
@Destaq
Destaq / generate_dushu369.py
Last active April 30, 2021 19:59
Create a ready-to-read/analyze dushu369.com .txt file from the TOC link
import requests
from bs4 import BeautifulSoup
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
session = requests.Session()
retry = Retry(connect=3, backoff_factor=0.5)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)
@Destaq
Destaq / comprehension.py
Last active April 30, 2021 17:50
Calculates Chinese text comprehension - UPDATE: now with repo & further functions
import re, jieba, argparse
from collections import Counter
from re import compile as _Re
parser = argparse.ArgumentParser(
description="Calculates percentage comprehension of a text file based on known words."
)
parser.add_argument(
"-k",
"--known",