This commit is contained in:
lda committed 2025-12-18 22:47:45 +07:00
1 parent 4a2974098f
commit d4fc121506
10 files changed
+23 -13

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
def next_number(n: int, base: int):
dih = n # DIH
bih = 1 # track position of first not largest
cih = 0 # number until not largest
fih = -1 # digit cumulate
while dih:
if fih > (gih := dih % base):
fih = gih
break
fih = gih
cih = cih + gih * bih
bih *= base
dih //= base
print(bih, cih, dih, fih, gih, base)
assert n == (cih + dih * bih)
assert dih % base == fih
assert n == cih + dih * bih
dih //= base
print(fih * bih + cih)
gih = 1 # track position of first larger
hih = cih
ret = 0 # realest
while hih:
if fih < (jih := hih % base):
ret += jih * gih
ret = ret * base + fih
fih = base + 1
else:
ret = ret * base + jih
hih //= base
gih *= base
print(gih, ret, hih, fih, jih)
print(dih)
return ret + dih * base * bih
+60
View File
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
</head>
<body>
<textarea
name="what"
id="wow"
rows="20"
cols="100"
style="min-width: 20%; min-height: 20dvh"
></textarea>
<button type="button" id="cuh">cuh</button>
<div id="qrcode"></div>
<script>
/** @type { HTMLTextAreaElement } */
const wow = document.getElementById("wow");
/** @type { HTMLDivElement } */
const qrcode = document.getElementById("qrcode");
const cuh = () => {
for (const i of wow.value.split(/\r?\n/)) {
const l = i.split("|", 1)[0].trim();
const d = document.createElement("div");
const h = document.createElement("a");
h.href = l;
h.textContent = l;
console.log(l);
const a = document.createElement("div");
try {
new QRCode(a, {
text: l,
correctLevel: QRCode.CorrectLevel.L,
});
} catch (e) {
console.error(e);
}
d.appendChild(h);
d.appendChild(a);
qrcode.appendChild(d);
}
};
window.addEventListener("load", (_) => {
wow.value = decodeURI(
new URLSearchParams(window.location.search).get("data") ??
""
);
document.getElementById("cuh").addEventListener("click", cuh);
wow.addEventListener("input", (_) => {
const f = new URL(window.location.href);
f.searchParams.set("data", wow.value);
history.replaceState(null, "", f.href);
});
});
</script>
</body>
</html>
+27
View File
@@ -0,0 +1,27 @@
import io
from sys import stdin
import qrcode
def link_extract_from_onetab(line):
"link | title"
link = line.split("|", 1)[0].strip()
return link
def qrcodify(link):
q = qrcode.QRCode()
q.add_data(link)
a = io.StringIO()
q.print_ascii(a)
return a.getvalue()
def fuck(line):
link = link_extract_from_onetab(line)
print(link)
print(qrcodify(link))
if __name__ == "__main__":
list(map(fuck, stdin.readlines()))
+45
View File
@@ -0,0 +1,45 @@
"why outdated"
from collections import deque
import flask
def link_extract_from_onetab(line):
"link | title"
link = line.split("|", 1)[0].strip()
return link
a = flask.Flask(__name__)
queue: deque[str] = deque()
@a.route("/q")
def no():
"if i click the link then it proceed. if i reload it doesnt."
current_link = queue[0] if queue else None
return flask.render_template("reader.html", current_link=current_link)
@a.route("/r")
def redir():
"reload == proceed"
if queue:
q = queue.popleft()
return flask.redirect(q)
return flask.render_template("reader.html", current_link=None)
@a.route("/queuein", methods=["GET", "POST"])
def cuh():
if flask.request.method == "POST":
for line in flask.request.form.get("l", "").splitlines():
queue.append(link_extract_from_onetab(line))
return flask.redirect("/queuein", 303)
return flask.render_template("queue.html", queue_items=list(queue))
if __name__ == "__main__":
a.run("0.0.0.0", 2222)
# flask --app .\uhhhh.py run -h "0.0.0.0" -p 2222