A list of code examples used in class and any board work or other artifacts I create during class. This page generally will be added to shortly before or shortly after the class (or sometime both).
Demo files matching the sections in our Python page; also available as a zip file
17-args.py
18-annotation.py
19-class.py
20-nothis.py
21-comprehensions.py
22-generators.py
23-closure.py
24-async.py
25-decorators.py
– I added this late so it’s not yet in the .zip fileAlso an example of a race condition in Python: racecondition
Demo files matching the sections in our Python page; also available as a zip file
mp5startercode.c
creates a socket listener and detached threads.
In class I added this code to client_thread
:
while(1) {
char buffer[4096+1];
ssize_t got = read(fd, buffer, 4096);
[got] = '\0';
buffer("Buffer: %s (%ld)\n", buffer, got);
printf(fd, "Thank you for your message!\n", strlen("Thank you for your message!\n"));
write}
In class I also had trouble running telnet
in the docker image. Here’s the steps to use it:
either (once) add telnet
to the line that currently says make
in your Dockerfile
and then select Rebuild container
in the remote menu in VS Code
or (each time you start docker) run apt update; apt install telnet
from the command line.
From the docker command line, run telnet localhost 1234
, replacing 1234
with the port you want to use.
stack-memory.c
demonstrates both valid and invalid use of stack memory and the sizeof
operator.global-memory.c
demonstrates both valid and invalid use of global memory and const
.mem-undefined.c
a variety of mostly-undefined-behavior memory operations.vmtest.c
which demonstrates virtual memory working.cachetest.c
which demonstrates the memory cache working.memory-inspector.c
, for viewing bytes stored in anything.char twoOTheBits(char c) { return (c>>5)&3; }