Compare commits
4 Commits
427e0bf72a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a4b8468cba | |||
| 2cb09552c2 | |||
| 49c7132863 | |||
| 0b2a2e5cd0 |
@@ -1,12 +1,12 @@
|
||||
# DSA Tutoring microsite
|
||||
#
|
||||
# For local use, serves on port 80.
|
||||
# For local use, serves on port 8080
|
||||
# Replace :80 with your domain (e.g. dsa-tutoring.example.com) for
|
||||
# automatic HTTPS via Let's Encrypt.
|
||||
#
|
||||
# Run `python build.py` first to generate the public/ directory.
|
||||
|
||||
dsa-tutoring.bchen.dev {
|
||||
:8080 {
|
||||
root * /srv/public
|
||||
encode gzip
|
||||
file_server
|
||||
|
||||
20
build.py
20
build.py
@@ -75,6 +75,22 @@ def scan_shared() -> list[Section]:
|
||||
|
||||
assignments_dir = SHARED_DIR / "assignments"
|
||||
if assignments_dir.exists():
|
||||
subdirs = sorted(
|
||||
d for d in assignments_dir.iterdir()
|
||||
if d.is_dir() and should_include(d)
|
||||
)
|
||||
if subdirs:
|
||||
subsections = []
|
||||
for subdir in subdirs:
|
||||
zip_name = f"assignments-{subdir.name}.zip"
|
||||
create_zip(subdir, ZIPS_DIR / zip_name)
|
||||
subsections.append(SubSection(
|
||||
name=subdir.name,
|
||||
zip_url=f"zips/{zip_name}",
|
||||
files=list_files(subdir),
|
||||
))
|
||||
sections.append(Section(title="Assignments", subsections=subsections))
|
||||
else:
|
||||
zip_name = "assignments.zip"
|
||||
create_zip(assignments_dir, ZIPS_DIR / zip_name)
|
||||
sections.append(Section(
|
||||
@@ -258,6 +274,10 @@ def main() -> None:
|
||||
output.write_text(html_content, encoding="utf-8")
|
||||
print(f"Built {output}")
|
||||
|
||||
robots = PUBLIC_DIR / "robots.txt"
|
||||
robots.write_text("User-agent: *\nDisallow: /\n", encoding="utf-8")
|
||||
print(f"Built {robots}")
|
||||
|
||||
print(f"Zips in {ZIPS_DIR}:")
|
||||
for z in sorted(ZIPS_DIR.iterdir()):
|
||||
print(f" {z.name}")
|
||||
|
||||
@@ -12,10 +12,7 @@ services:
|
||||
builder:
|
||||
condition: service_completed_successfully
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "8080:8080" # test port
|
||||
- "443:443/udp"
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||
- ./public:/srv/public:ro
|
||||
|
||||
2
shared/notes-and-examples/2026.02.28/homework.py
Normal file
2
shared/notes-and-examples/2026.02.28/homework.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# Homework:
|
||||
# See youtube-playlists under Assignments
|
||||
51
shared/notes-and-examples/2026.02.28/queues.py
Normal file
51
shared/notes-and-examples/2026.02.28/queues.py
Normal file
@@ -0,0 +1,51 @@
|
||||
class Node:
|
||||
next_node: "None | Node" = None
|
||||
prev_node: "None | Node" = None
|
||||
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
class Queue:
|
||||
front: "Node | None" = None
|
||||
back: "Node | None" = None
|
||||
|
||||
def append(self, value):
|
||||
if self.back is None:
|
||||
self.front = Node(value)
|
||||
self.back = self.front
|
||||
else:
|
||||
new_node = Node(value)
|
||||
self.back.prev_node = new_node
|
||||
new_node.next_node = self.back
|
||||
self.back = new_node
|
||||
|
||||
def popleft(self):
|
||||
if self.front is not None:
|
||||
prev_front = self.front
|
||||
|
||||
prev_node_in_queue = self.front.prev_node
|
||||
self.front.next_node = None
|
||||
self.front.prev_node = None
|
||||
if prev_node_in_queue is not None:
|
||||
prev_node_in_queue.next_node = None
|
||||
|
||||
self.front = prev_node_in_queue
|
||||
|
||||
return prev_front
|
||||
else:
|
||||
return None
|
||||
|
||||
def print_queue(self):
|
||||
current_node = self.front
|
||||
while current_node is not None:
|
||||
print(current_node.value)
|
||||
current_node = current_node.prev_node
|
||||
|
||||
|
||||
queue = Queue()
|
||||
queue.append("first")
|
||||
queue.append("second")
|
||||
queue.append("third")
|
||||
queue.popleft()
|
||||
queue.popleft()
|
||||
queue.print_queue()
|
||||
Reference in New Issue
Block a user