Skip to content

Instantly share code, notes, and snippets.

@mariusdkm
Last active May 11, 2022 21:00
Show Gist options
  • Save mariusdkm/f8ebb20619e03f23cf7c6da8dfbae589 to your computer and use it in GitHub Desktop.
Save mariusdkm/f8ebb20619e03f23cf7c6da8dfbae589 to your computer and use it in GitHub Desktop.
# Add additional compiler flags here
CFLAGS=-O2 -Wall -Wextra -Wpedantic -g -std=c11 -DWITHMAIN
# execute all code wrapped inside of #ifdef WITHMAIN/#endif using the flag -DWITHMAIN
NAME := brainfuck
EXERCISE := B2_brainfuck
USERNAME := ge69usr
PASSWORD := MyPass
.PHONY: all run upload login clean
$(NAME): $(NAME).c
$(CC) $(CFLAGS) -o $@ $^
all: $(NAME) run
run:
./$(NAME) "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."
upload:
$(if $(wildcard ./login_cookie.txt),,$(error Please login first!(with make login)))
$(eval ENCODED = $(shell python3 -c 'import urllib.parse; print("content="+urllib.parse.quote_plus(open("$(NAME).c", "r").read()))'))
@echo "\033[0;31mUploading submission:\033[0m"
curl -d "$(ENCODED)" -b login_cookie.txt -X POST https://gra.caps.in.tum.de/homework/$(EXERCISE)/submit
@echo "\n"
login:
@echo "\033[0;31mLogin in:\033[0m"
curl -d 'username=$(USERNAME)&password=$(PASSWORD)' -c login_cookie.txt -X POST https://gra.caps.in.tum.de/login
@echo "\n"
clean:
rm -f $(NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment