Posts

Web Workers

“client side js is single threaded”

“erm actually using web-workers you can create multi threaded applications in client side js” - 🤓


Setup #

The Web Workers API lets users create dedicated worker threads in the browser to run a specified script.

To use SharedArrayBuffer (the primary way web workers can share memory) the Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy headers must be set to require-corp and same-origin.

python -m http.server is typically my go to run quickly a http server, but i couldn’t find an easy way to set headers - so i ended up using FastAPI.

...

Concurrent Programming in JavaScript

“Parallelism is about physically doing two or more things at the same time. Concurrency is about undefined, out of order, execution.” - William Kennedy

Javascript typically isn’t the first language that comes to mind when you think of concurrent & parallel programming - i’d imagine c++, go, and elixir are higher up on the list.

Despite preconceived notions (i myself didn’t think that javascript could be parallel, especially on the client) javascript is definitely concurrent - and even parallel at times.

...

Reverse Engineering Coinbase's Price Chart

What i want:

What i got


You know something is done well when you don’t even think about it. I caught myself playing with the coinbase price chart over the past few days without realizing it (not a good idea to check every day, but bull runs will do that to you).

I didn’t really have a good idea of how they did it as well (repeating linear gradient for the dots? each line is a div? how’d they change opacity based on cursor position? - and only for half of the chart?).

...

Anatomy of a GitHub Action

When I haven’t done something a long time I tend to need a quick overview to remind my brain that I know this stuff, this is exactly that for GitHub Actions.

Workflow’s are triggered when an event occurs in a repository. A workflow contains one or more jobs, each job runs inside its own runner (think vm/container/isolated process). Each job has one more more steps that can either run a shell script or an action.

...

Parsing Boolean Expressions into DNF with ANTLR

Motivation #

To determine if a student had successfully completed ANY of the numerous prerequisite combinations. The prerequisites for courses at Ontario Tech are structured like this;

To take CSCI 3055U, the expression (CSCI 1060U or CSCI 2030U) and CSCI 2110U must evaluate to true.

An easy way to do this was to check if any of the possible combinations were true, this lends itself to the idea of Disjunctive Normal Form.

...