Skip to content

Instantly share code, notes, and snippets.

View ProfAvery's full-sized avatar

Kenytt Avery ProfAvery

  • California State University, Fullerton
  • Fullerton, CA
View GitHub Profile
@ProfAvery
ProfAvery / Makefile
Last active November 22, 2021 01:00
C++ variant of threads-intro/t1.c (Figure 26.6)
CXXFLAGS = -g -std=c++17 -Wall -Wextra -Wpedantic -Werror -pthread
all: t1 t1-sanitized
# Note: using implicit rule for .cpp files to create t1
t1-sanitized: t1.cpp
$(CXX) $(CXXFLAGS) -o $@ $^ -fsanitize=thread
.PHONY: clean
@ProfAvery
ProfAvery / Makefile
Last active August 31, 2021 23:23
C++ variant of cpu-api/p4.c (Figure 5.4)
CXXFLAGS = -g -std=c++17 -Wall -Wextra -Wpedantic -Werror
all: p4
# Note: using implicit rule for .cpp files to create p4
.PHONY: clean test
test: p4
./p4 && cat p4.output
@ProfAvery
ProfAvery / form.js
Created July 15, 2021 23:22
How forms are handled on the server-side
#!/usr/bin/env node
const http = require('http')
const url = require('url')
const qs = require('querystring')
function formHandler (request, response) {
response.write(`method: ${request.method}\n`)
response.write(`url: ${request.url}\n`)
@ProfAvery
ProfAvery / hash.py
Created June 25, 2021 05:25
Fun with hash tables
students = [
['foo', 'junior'],
['bar', 'senior'],
['baz', 'junior'],
['quux', 'junior'],
['guacamole', 'senior'],
['spatula', 'junior'],
['firewood', 'senior'],
]
@ProfAvery
ProfAvery / Makefile
Created January 7, 2021 05:23
State machine example in C
CFLAGS= -g -std=c11 -Wall -Wextra -Wpedantic
TARGET=dieroll
$(TARGET): $(TARGET).c
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
test: $(TARGET)
./$< 100000
clean:
@ProfAvery
ProfAvery / .gitignore
Last active February 12, 2021 22:34
In-class exercise: Resource Allocation Graph
*.o
resource-allocation
@ProfAvery
ProfAvery / .gitignore
Last active October 8, 2020 09:04
POSIX Multithreading Example
burncpu
multithread
mutex
semaphore
@ProfAvery
ProfAvery / onethread.cpp
Created September 22, 2020 23:24
C++ variant of Figure 4.11
#include <cstdlib>
#include <iostream>
#include <pthread.h>
using std::cout;
using std::cerr;
using std::endl;
// Don't forget to compile with -pthread
@ProfAvery
ProfAvery / .gitignore
Last active October 12, 2020 01:03
POSIX Shared Memory Example
*.o
send_string
receive_string
@ProfAvery
ProfAvery / forking.cpp
Created September 16, 2020 06:55
C++ variant of Figure 3.8
#include <cstdlib>
#include <iostream>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
using std::cout;
using std::cerr;
using std::endl;