kylehovey / rick-canvas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rick Canvas

This automates placing a RickRoll QR code on the Aggie Canvas using their REST API. I made this on a lunch break using ChatGPT and by hacking together the plumbing, so the code is Not Great™. That being said, if you'd like to see how this was done, the pipeline was:

flowchart LR
    A(Get Rickroll PNG) --> B(Crop out padding)
    B --> C(Convert to JSON with PIL)
    C --> D(Post to API using JS script)

Result:

result_opt

ChatGPT wrote the Python PIL script to convert the image to JSON, I modified it to sample centers of squares instead of checking any pixel (it was getting the borders of regions and incorrectly converting), then once again used GPT to generate the code to properly call the API. The API shape was deduced from network information in Firefox inspector.

I finished by writing a basic 2D for loop to make the calls, added some retry logic, and made sure that each request only happens every 2.5s so that it doesn't spam the server (requests have a 2 second cooldown anyways).

Why?

It's fun :3

Also, whoever did this first won a $10 donation to their open source project of choice. I chose the Learning Equality project, who prioritizes offline-first content management systems for educational courses. If you haven't, check out their Kolibri software and the available courses you can download for it.

About


Languages

Language:JavaScript 52.9%Language:Python 47.1%