advent-of-code-2023

Frank's Advent of Code written in Rust and executed client-side in WASM

https://github.com/frankhereford/advent-of-code-2023

Science Score: 31.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.2%) to scientific vocabulary

Keywords

advent-of-code advent-of-code-2023 ffmpeg javascript nextjs redis rust t3 typescript wasm
Last synced: 6 months ago · JSON representation ·

Repository

Frank's Advent of Code written in Rust and executed client-side in WASM

Basic Info
  • Host: GitHub
  • Owner: frankhereford
  • License: unlicense
  • Language: Rust
  • Default Branch: main
  • Homepage: https://that.photo
  • Size: 13.1 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 8
  • Releases: 7
Topics
advent-of-code advent-of-code-2023 ffmpeg javascript nextjs redis rust t3 typescript wasm
Created over 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

📸 Website: https://that.photo

Photograph credit

The photograph featured in this website belongs to Zoe Leonard. It is the inspiration for this work, and it is used without permission. Zoe Leonard's photography is remarkable, and I am grateful for her work questioning traditional views on gender and sexuality. I recommend anyone who reads this to investigate her art further.

Technology

This website consists of two, almost seperate, projects. They were written about a month apart. These systems include: * A backend system used to provide the polaroid photograph with video on the televisions * To see this portion of the project more clearly, you can click the red close button on the terminal to hide it. * A nextJS app utilizing WASM compiled from Rust to compute the 2023 Advent of Code solutions

Photograph

Intent

The intent of this art is to imagine what might have caused the photographer to stop and take this photo. The motivation is provided by "turning the televisions on" and finding a way to fill them with reasonable, possible video streams that are believable. Why is she taking that photograph? This is my imagining an answer to that question.

Mechanism

The photograph proceedes through the following steps on page load: * A call to OpenAI's API is made to select a notable news event in a given year, randomly chosen between 1970 and now. The program picks the year, and GPT 4 picks the news event. This interval is chosen to provide a reasonably good chance of having news coverage of the event being available on YouTube. * With a topic chosen, a search is made on Google's YouTube API to find semi-randomly chosen videos from the top results on that topic. * With two videos chosen, each is downloaded to the server in 360p resolution. * With mp4 files of the videos, each is run through a complex chain of ffmpeg filtergraphs to simulate being displayed on a CRT. * As the processed video is produced, it is saved to disk as a TLS stream, allowing it to be used while the transcoding process continues. * The web application polls for availability of enough of the TLS stream, and then begins to display it. * When both video streams are playing topical videos through the above mechanism, the topic is displayed on the polaroid. * While the TLS streams are being prepared, the televisions will alternate between brief flashes of videos depicting static and randomly, previously downloaded video, simulating a channel changing effect. * The queing system used to pass events from one stage to the next is based on redis. * Horizontal scalability is provided by standing the stack up in Kubernetes and using an archtecture based around redis queueing. * An individual page load requires two cores of the processor to work for about two minutes, almost entirely dedicated to the ffmpeg processing. The cost of running this website at any level of scale would be brutal in the cloud. The current implementation is running on a real, metal i7-10700 and can support two to three simultatinious visitors with transcoded video faster than the playback speed. * When you use this website, a computer in my living room spins up its fans. 🖥️💨

Terminal

Intent

Pretty simply, the intent is to learn how to program in Rust. Beyond that, it's to execute Advent of Code solutions at near native, binary speed in the context of a client's browser on the client's hardware.

Mechanism

  • I found this book, Rust 🦀 and WebAssembly 🕸, which inspired me to learn about compiling rust into web assembly.
  • Inside the rust directory, there is a rust project which they are used to compile web-assembly (WASM).
    • These binary objects are able to be executed by the browser at near native binary speed, comperable to a locally compiled software's execution rate.
    • These binary WASM objects are symlinked into a nextjs app where it is run via the <Rust /> component.
  • The rust WASM code is run in a web-worker to avoid blocking the main JS event loop. They communicate with the main components through web-worker-like pub/sub methods. This architecture frees us up from needing to write async code, and we can plow ahead functionally without impact on the UI/UX, keeping the polaroid mechanisms working as intended. This is adventagous when you're trying to just crank out an AOC solution.
  • The rust routines are provided a mechanism to print "status updates", similar conceptually to console.log() statements, as it proceedes through the solution to the program.
  • These updates are collected and displayed in the <Terminal /> component borrowed from last year's AOC website.
  • The result is that the client's web browser provides the compute for the solution, and does it through execution of "binary" files compiled from rust at compile time, not execution time.
  • Recompilation of the rust source into WASM modules interacts with the NextJS development cycle as you'd expect. When you recompile, the module is re-run, outputting its status updates to the terminal.

Deployment

This is wreckless, "ride or die" deployment. Production and development environments are the same thing. If you see something break, just wait a second, I'm probably fixing it.

Owner

  • Name: Frank Hereford
  • Login: frankhereford
  • Kind: user
  • Location: Austin, TX
  • Company: Austin Transportation Department / Data & Technology Services

Citation (citations/README.md)

# Citations for Day 1

## Part 1

* [Seeking Solutions for Embedding and Processing File Contents in WebAssembly with Rust](https://chat.openai.com/share/a8d52d67-ea79-46bc-814e-4ad47fd40a71)
* [Exploring Regular Expressions in Rust: Converting Chars to Strings and Regex Pattern Matching](https://chat.openai.com/share/e1eb6303-a6bc-4d88-a486-fcfd0fad3152)
* [Seeking Rust Programming Guidance for String Manipulation, Regex Usage, and Integer Type Casting](https://chat.openai.com/share/b0d19338-ee6d-4983-ad1a-9a18bbd502e2)
* [Exploring Rust Programming: String Manipulation, Arrays, and Summation Techniques](https://chat.openai.com/share/119f6bcc-2637-4743-b661-a3b3782b3f10)

## Part 2

* [Exploring Rust: String Operations and Understanding the Borrow Checker](https://chat.openai.com/share/54b26bc0-ddfc-46ab-9976-1a51a7a0cac3)

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 563
  • Total Committers: 3
  • Avg Commits per committer: 187.667
  • Development Distribution Score (DDS): 0.398
Past Year
  • Commits: 563
  • Committers: 3
  • Avg Commits per committer: 187.667
  • Development Distribution Score (DDS): 0.398
Top Committers
Name Email Commits
Frank Hereford f****k@f****m 339
Frank Hereford f****d 148
Frank Hereford g****b@f****m 76
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 24
  • Total pull requests: 82
  • Average time to close issues: 13 days
  • Average time to close pull requests: about 11 hours
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.04
  • Merged pull requests: 72
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • frankhereford (12)
Pull Request Authors
  • frankhereford (41)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

rust/Cargo.lock cargo
  • android-tzdata 0.1.1
  • android_system_properties 0.1.5
  • autocfg 1.1.0
  • bumpalo 3.14.0
  • cc 1.0.83
  • cfg-if 1.0.0
  • chrono 0.4.31
  • console_error_panic_hook 0.1.7
  • core-foundation-sys 0.8.4
  • iana-time-zone 0.1.58
  • iana-time-zone-haiku 0.1.2
  • js-sys 0.3.65
  • libc 0.2.150
  • log 0.4.20
  • num-traits 0.2.17
  • once_cell 1.18.0
  • proc-macro2 1.0.70
  • quote 1.0.33
  • scoped-tls 1.0.1
  • syn 2.0.39
  • unicode-ident 1.0.12
  • wasm-bindgen 0.2.88
  • wasm-bindgen-backend 0.2.88
  • wasm-bindgen-futures 0.4.38
  • wasm-bindgen-macro 0.2.88
  • wasm-bindgen-macro-support 0.2.88
  • wasm-bindgen-shared 0.2.88
  • wasm-bindgen-test 0.3.38
  • wasm-bindgen-test-macro 0.3.38
  • web-sys 0.3.65
  • windows-core 0.51.1
  • windows-targets 0.48.5
  • windows_aarch64_gnullvm 0.48.5
  • windows_aarch64_msvc 0.48.5
  • windows_i686_gnu 0.48.5
  • windows_i686_msvc 0.48.5
  • windows_x86_64_gnu 0.48.5
  • windows_x86_64_gnullvm 0.48.5
  • windows_x86_64_msvc 0.48.5
rust/Cargo.toml cargo
  • wasm-bindgen-test 0.3.34 development
  • chrono 0.4
  • console_error_panic_hook 0.1.7
  • wasm-bindgen 0.2.84
  • web-sys 0.3
crt/Dockerfile docker
  • linuxserver/ffmpeg latest build
download/Dockerfile docker
  • ubuntu latest build
haproxy/Dockerfile docker
  • haproxy latest build
nextjs/Dockerfile docker
  • node current-bookworm build
nextjs/package-lock.json npm
  • 517 dependencies
nextjs/package.json npm
  • @types/eslint ^8.44.2 development
  • @types/lodash ^4.14.202 development
  • @types/node ^18.16.0 development
  • @types/react ^18.2.20 development
  • @types/react-dom ^18.2.7 development
  • @typescript-eslint/eslint-plugin ^6.3.0 development
  • @typescript-eslint/parser ^6.3.0 development
  • autoprefixer ^10.4.14 development
  • eslint ^8.47.0 development
  • eslint-config-next ^13.5.4 development
  • postcss ^8.4.27 development
  • prettier ^3.0.0 development
  • prettier-plugin-tailwindcss ^0.5.1 development
  • tailwindcss ^3.3.3 development
  • typescript ^5.1.6 development
  • @t3-oss/env-nextjs ^0.7.0
  • @tanstack/react-query ^4.32.6
  • @trpc/client ^10.37.1
  • @trpc/next ^10.37.1
  • @trpc/react-query ^10.37.1
  • @trpc/server ^10.37.1
  • @types/pg-promise ^5.4.3
  • @types/uuid ^9.0.6
  • @wasm-tool/wasm-pack-plugin ^1.7.0
  • axios ^1.5.1
  • googleapis ^128.0.0
  • hls.js ^1.4.12
  • lodash ^4.17.21
  • next ^13.5.4
  • openai ^4.12.1
  • pg-promise ^11.5.4
  • react 18.2.0
  • react-dom 18.2.0
  • react-hook-videojs ^3.0.2
  • redis ^4.6.10
  • superjson ^1.13.1
  • usehooks-ts ^2.9.1
  • uuid ^9.0.1
  • webpack ^5.89.0
  • youtube-search-api ^1.2.1
  • zod ^3.22.4