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 / nudge.js
Last active June 16, 2023 01:26
Nudge - Web Interface for Git Push
#!/usr/bin/env node
"use strict";
var http = require("http"),
querystring = require("querystring"),
child_process = require("child_process");
function writeCSS(res) {
res.writeHead(200, {
@ProfAvery
ProfAvery / query.py
Last active April 27, 2022 20:35
Simple SQLite query utility that can print GUIDs
#!/usr/bin/env python
import cmd
import sys
import uuid
import pprint
import sqlite3
def make_dicts(cursor, row):
@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 / sum.rb
Created February 9, 2012 05:39
15 ways to sum an array in Ruby
#!/usr/bin/env ruby
require 'test/unit'
class TestSums < Test::Unit::TestCase
def setup
@a = [2, 5, 18, 27]
@sum = 0
end
@ProfAvery
ProfAvery / .gitignore
Last active February 12, 2021 22:34
In-class exercise: Resource Allocation Graph
*.o
resource-allocation
@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 October 12, 2020 01:03
POSIX Shared Memory Example
*.o
send_string
receive_string