Skip to content

Instantly share code, notes, and snippets.

View mattdesl's full-sized avatar
👋

Matt DesLauriers mattdesl

👋
View GitHub Profile
import {
IrohNode,
PublicKey,
NodeAddr,
Query,
SortBy,
SortDirection,
pathToKey,
AuthorId,
keyToPath,
@mattdesl
mattdesl / 02.js
Created January 2, 2024 17:11
MIT license, messy genuary2024 code... "no palettes"
import canvasSketch from "canvas-sketch";
import { degToRad, linspace, radToDeg } from "canvas-sketch-util/math";
import { Lch, contrastRatio } from "../util/color";
import polyBool from "poly-bool";
import * as random from "canvas-sketch-util/random";
import { angleLerp } from "../util/angle";
export const settings = {
suffix: random.getSeed(),
animate: true,
@mattdesl
mattdesl / README.md
Created November 13, 2023 17:29
hachure notes

Notes on hachure

Some notes on archiving and accessing the media and metadata around digital editions of hachure. These tokens were released through verse but can be retrieved through decentralized storage systems.

See Token Data for a listing of media & data associated with each edition.

Saving High-Res PNG and SVG

In the browser, with the artwork in focus, you can hit the keystroke Cmd + S or Ctrl + S. This will auto-download two files: a 2048x2048px PNG, and an SVG of the paths that could be used for pen plotting. It's recommended to use Chrome for downloading; some browsers might only let one download through.

/**
* Conserve aspect ratio of the original region. Useful when shrinking/enlarging
* images to fit into a certain area.
*
* @param {Number} srcWidth width of source image
* @param {Number} srcHeight height of source image
* @param {Number} maxWidth maximum available width
* @param {Number} maxHeight maximum available height
* @return {Object} { width, height }
*/
@mattdesl
mattdesl / model.py
Created November 2, 2023 20:29
fork of latent consistency model with a couple small perf tweaks
import os
import torch
import time
from diffusers import DiffusionPipeline, AutoencoderTiny
from collections import namedtuple
PredictionResult = namedtuple('PredictionResult', [
'latents',
'step',
'steps',
@mattdesl
mattdesl / verify.circom
Last active August 15, 2023 22:30
verify list of indices are a valid permutation in circom zk circuit
pragma circom 2.1.5;
include "circomlib/circuits/comparators.circom";
/*
Verifies a permutation is valid and includes all indices once and only once.
Examples:
[ 0 1 2 3 ] == OK
[ 1 2 0 3 ] == OK
[ 0 2 0 3 ] == NOT OK
function fractalNoise(x, y, frequency, octaves, persistence = 0.5, lacunarity = 2) {
let total = 0;
let amplitude = 1;
let maxValue = 0; // Used for normalizing result to 0.0 - 1.0
for (let i = 0; i < octaves; i++) {
total += noise2D(x * frequency, y * frequency) * amplitude;
maxValue += amplitude;
amplitude *= persistence;
frequency *= lacunarity;
@mattdesl
mattdesl / prng.js
Created August 2, 2023 12:00
MIT Licensed — seedable PRNG using xorshift 128 bit + djb2 hash function
const djb2 = (() => {
// http://www.cse.yorku.ca/~oz/hash.html
const _uint32 = new Uint32Array(1);
return function djb2(str) {
_uint32[0] = 5381;
for (let i = 0; i < str.length; i++) {
const c = str.charCodeAt(i);
const h = _uint32[0];
_uint32[0] = (h << 5) + h + c; /* hash * 33 + c */
}
@mattdesl
mattdesl / README.md
Last active August 9, 2023 03:44
draw HTML5 canvas with voice commands and GPT-3.5

Voice Coding with iOS Shortcuts + Node.js

Instructions:

  1. Copy and paste the server.js into a new folder called genart or whatever
  2. Run npm init -y to generate a package.json
  3. Install the dependencies:
npm install body-parser openai express canvas dotenv
@mattdesl
mattdesl / iframe.html
Created June 24, 2023 14:53
test iframe gesture
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="”viewport”"
content="”width"
="device-width,"
initial-scale="1.0,"
maximum-scale="1.0,"