From 6178771a550bc4bb0cdced6179475f95c4bd77f3 Mon Sep 17 00:00:00 2001 From: Elouin Date: Wed, 31 Jul 2024 16:17:49 +0200 Subject: [PATCH] init --- .gitignore | 1 + README.md | 14 +++++ requirements.txt | 1 + threadednames.py | 129 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 requirements.txt create mode 100644 threadednames.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7275bb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f61935 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Slides for Tech Talks 25 + +First run the python script: +``` +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt +python3 threadednames.py +``` + +Then get the PID of the script and do: +``` +top -p -H -d 0.5 +``` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4d62081 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyprctl==0.1.3 diff --git a/threadednames.py b/threadednames.py new file mode 100644 index 0000000..baaad4d --- /dev/null +++ b/threadednames.py @@ -0,0 +1,129 @@ +import threading +import time +import os +import signal + +import pyprctl + + +slides = [] +current_slide = 0 + +slides.append(("static", """Herzlich +Willkommen, +zur 26. Auflage +der Tech Talks +des Kassel Code +Meetups in der +Caricatura Bar""")) + +slides.append(("static", """ +Die Agenda fuer +Heute: + +19:15 - 19:30 +Begruessung + +19:30 - 20:00 +Talk No 1 +Goodbye +Hydration – +Resumable Pages +mit Qwik +Entdecke die +Macht der +Webcomponents +- Sven + +20:00 - 20:30 +Talk No 2 +Capture The Flag +- Marlon + +20:30 - 21:00 +Talk No 3 +Reverse +Engineering +old +Datastructures +From System +Programming +To The Web +and back! +- Enno + +21:00 - 21:30 +Pizza + +21:30 - 22:00 +Whats Next +""")) + +slides.append(("walking", """ ______ ____ _ __ ___ + /_ __/___ _/ / /__ / | / /___ < / + / / / __ `/ / //_/ / |/ / __ \ / / + / / / /_/ / / ,< / /| / /_/ / / / +/_/ \__,_/_/_/|_| /_/ |_/\____(_) /_/ """)) + +slides.append(("walking", """ ______ ____ _ __ ___ + /_ __/___ _/ / /__ / | / /___ |__ | + / / / __ `/ / //_/ / |/ / __ \ __/ / + / / / /_/ / / ,< / /| / /_/ / / __/ +/_/ \__,_/_/_/|_| /_/ |_/\____(_) /____/ """)) + +slides.append(("walking", """ ______ ____ _ __ _____ + /_ __/___ _/ / /__ / | / /___ |__ / + / / / __ `/ / //_/ / |/ / __ \ /_ < + / / / /_/ / / ,< / /| / /_/ / ___/ / +/_/ \__,_/_/_/|_| /_/ |_/\____(_) /____/ """)) + +slides.append(("walking", """ ____ ______________ ___ ______ + / __ \/ _/__ /__ / / | / / / / + / /_/ // / / / / / / /| | / / / / + / ____// / / /__/ /__/ ___ |/_/_/_/ +/_/ /___/ /____/____/_/ |_(_|_|_) """)) + + +def create_named_thread(name: str, slide: int) -> None: + pyprctl.set_name(name) + while current_slide == slide: + time.sleep(1) + + +def create_walking_thread(name: str, slide: int) -> None: + nth = 0 + while current_slide == slide: + pyprctl.set_name(name[nth % len(name):nth + 15]) + nth = nth + 1 + time.sleep(0.5) + + +def render_slide() -> None: + if slides[current_slide][0] == "static": + for line in slides[current_slide][1].split('\n'): + threading.Thread(target=create_named_thread, args=(line, current_slide)).start() + if slides[current_slide][0] == "walking": + for line in slides[current_slide][1].split('\n'): + threading.Thread(target=create_walking_thread, args=(line, current_slide)).start() + + +if __name__ == "__main__": + render_slide() + print(f"run: 'top -p {os.getpid()} -H -d 0.5' to view the presentation") + while True: + print(slides[current_slide][1]) + nav = input("j -> Next, k -> previous, q -> quit : ") + + if nav =='j': + current_slide += 1 + if nav == 'k': + current_slide -= 1 + if nav == 'q': + os.kill(os.getpid(), signal.SIGTERM) + + if current_slide < 0: + current_slide = 0 + if current_slide > len(slides) - 1: + current_slide = len(slides) - 1 + render_slide() +