Skip to content

Instantly share code, notes, and snippets.


Matt DesLauriers mattdesl

View GitHub Profile

"the cloud"

I wish we had real cloud computers. I want to be able to write some code and deploy it to the ether, without having to maintain it. If other people find the program useful, they can tap in and run my code without me having to manage the application's uptime, bandwidth, and costs. The less control I have over it, the better. In fact, I'd love if the mere act of uploading the program also relinquishes it from my control, placing the burden on the users who will operate and use it. And, importantly, I'd like this system to be a web primitive—something that lives in a shared and open spec, like the way that HTTPS and HTML works, rather than relying on a single private company to manage everything (*cough* Amazon).

Midjourney: old computers flying in the sky

vending machines in the sky

One analogy I can think of might be a network of floating vending machines. You s

mattdesl / grid.js
Created May 7, 2023 09:12
grid tiles sketch code
View grid.js
export function pluginGrid(fn) {
return (props) => {
const { context, width, height, data = {} } = props;
const { background = "white" } = data;
const cells = gridTiles(width, height, data).map((tile) => {;
context.translate(tile.x, tile.y);
const cellProps = {

WebGPU in Deno and the browser (with canvas-sketch)

This is a canvas-sketch demo that can render an image with WebGPU in both the browser and deno.


This requires deno 1.8 or higher (tested on 1.31.3) and a recent version of node/npm to install canvas-sketch-cli. If you want to run the browser version, you'll need a browser with WebGPU support, which is most likely going to be Chrome Canary with WebGPU enabled.


graphics toolkit wishlist

Specifically for 2D graphics and art. Not ideally suited for real-time purposes.

Hardware acceleration is not strictly necessary but would be ideal for faster iteration & feedback loops.

Main features:

  • Works on the Web (either pure JS or compiles to WASM)
  • Works outside of the Web (either Nodejs or native)
mattdesl / LHTSS.m
Last active March 17, 2023 13:01
try running here, will give errors:
View LHTSS.m
% data taken from Excel sheet described in:
T = [
0.0000646936115727633 0.000219415369171578 0.00112060228414359 0.00376670730427686 0.0118808497572766 0.0232870228938867 0.0345602796797156 0.0372247180152918 0.0324191842208867 0.0212337349018611 0.0104912522835777 0.00329591973705558 0.000507047802540891 0.000948697853868474 0.00627387448845597 0.0168650445840847 0.0286903641895679 0.0426758762490725 0.0562561504260008 0.0694721289967602 0.0830552220141023 0.0861282432155783 0.0904683927868683 0.0850059839999687 0.0709084366392777 0.0506301536932269 0.0354748461653679 0.0214687454102844 0.0125167687669176 0.00680475126078526 0.00346465215790157 0.00149764708248624 0.000769719667700118 0.000407378212832335 0.000169014616182123 0.0000952268887534793;
0.00000184433541764457 0.0000062054782702308 0.0000310103776744139 0.000104750996050908 0.000353649345357243 0.000951495123526191 0.00228232006613489 0.00420743392201395 0.00668896510747318 0.0098886425131619
# Generating Reflectance Curves from sRGB Triplets
# Original Matlab code & article:
# Note: This file was transpiled from Matlab by GPT-4 with
# some additional human help by @mattdesl to fix bugs. There
# may still be crucial errors—notably, it cannot solve due to "Singular matrix" error.
View mixbox-without-mixbox.js
// Using mixbox latent vectors without
// actually pulling mixbox dependency into the code
// Useful in two ways:
// 1. To bring file size down (e.g. on-chain art)
// 2. (Legal gray area) To potentially create something that is not restricted by mixbox license. Not clear yet whether this would circumvent the need for a license.
// EDIT: After discussion with them, this would indeed invalidate their license and be considered infringement. Code exists for educational purpose only.
// note this file includes some licensed code (evalPolynomial) from mixbox's source
// so I have not put a license on this

training a neural net to learn mixbox's latent space (encoding RGB to latent vector). the rest can be mixed and decoded without a neural net.


note this source code has no license associated with it and should be used for personal use only, as Mixbox has a commercial license and it isn't entirely clear whether this type of usage would infringe on it or not.

mattdesl / qoa-decoder.js
Last active February 6, 2023 21:33
The "Quite OK Audio" (QOA) Decoder for JavaScript [unstable / experimental / work-in-progress]
View qoa-decoder.js
* A decoder for The "Quite OK Audio" (QOA) format, a lossy audio compression
* that achieves relatively decent compression with fast decoding and not much complexity.
* Note that this has only been tested on QOA files generated by a specific commit (e8386f4)
* of QOA, see below:
* If you try to decode audio files that were encoded on a different version of QOA you might
* end up with jarring noise. This needs a companion encoder written in JS to be a little more stable.