Skip to content

Instantly share code, notes, and snippets.

import { globSync, existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { execSync } from "node:child_process";
// List of bad actors, from https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack
const pkgs = {
"02-echo": "0.0.7",
"@accordproject/concerto-analysis": "3.24.1",
"@accordproject/concerto-linter": "3.24.1",
function getDescription() {
return `
<p>
Use the sx/sy sliders to adjust the x/y scale of our unit circle,
and use the shx/shy sliders to adjust the x/y shear components. The
code will generate three points on the circle (aqually spaced
angularly), transform those using the slider parameters, then
construct a covariance matrix, calculate the eigenvalues and
eigenvectors, and use those to determine what the ellipse looks
like that we get when we transform the entire circle according
@Pomax
Pomax / download.md
Last active June 10, 2025 06:15
A script for automatically downloading all your Glitch projects, and their associated CDN assets
@Pomax
Pomax / rgbhanalysis.js
Last active November 18, 2024 07:53
Sort a collection of images based on their dominant hue, and show the rgb+h analysis in a nice little image alongside.
(function bookmarklet(window) {
var document = window.document;
var body = document.body;
/**
* Sort a collection of images based on their dominant hue,
* and show the rgb+h analysis in a nice little image alongside.
*
* for instance, use this bookmarklet on
@Pomax
Pomax / browse.js
Created March 10, 2015 02:56
Save as "browse.js", run with "node browse", instant image folder browser. Because I'm lazy
/**
* First things first: I am *lazy*. I will write a tool to do the thing I want to
* do so I don't have to do it a second time, ever. Or until a new programming
* language comes around. Generally the latter, but enough about that:
*
* This is a Node.js utility for taking the dir you are in right now, firing up
* an express server, and giving you image browsing on localhost:8080 with simple
* left/right controls once you're actually viewing images, and "up" control to
* go up a directory.
*
#include "Adafruit_seesaw.h"
#include <seesaw_neopixel.h>
#include <Joystick.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SS_SWITCH 24 // this is the pin on the encoder that connects to the momentary switch
#define SEESAW_BASE_ADDR 0x36 // I2C address, starts with 0x36
#define SCREEN_WIDTH 128 // OLED display width, in pixels
const { abs, log } = Math;
const log10 = (v) => log(v) / log(10);
const XMLNS = "http://www.w3.org/2000/svg";
const element = (tag, attributes = []) => {
const e = document.createElementNS(XMLNS, tag);
Object.entries(attributes).forEach(([key, value]) => set(e, key, value));
return e;
};
const set = (e, key, value) => e.setAttribute(key, value);
/**
* This is a function for use with JSON.stringify(input, sortedObjectKeys, number)
* that ensures that object keys are sorted in alphanumerical order.
*/
export function sortedObjectKeys(_, data) {
// Ignore primitives.
if (data === null) return null;
if (typeof data !== "object") return data;
// Also ignore iterables, which are type "object" but should not be sorted.
@Pomax
Pomax / tangents.pde
Last active June 11, 2021 18:43
This sketch illustrates the inner and outer tangents between two circles
int dim;
ArrayList<Circle> circles;
boolean moving = false;
/**
* simple (x,y) point class
*/
class Point {
float x, y;
@Pomax
Pomax / moo.md
Created November 15, 2015 14:32
programming some geometry in Type2 Charstrings

Writing Type2 sin(x) and cos(x) functions

If we want to make a font in which the glyphs are turned some random amount, we'll need to make sure we have a rotate function available. Normally, this is something you do with a rotation matrix, but that rotation matrix depends on trigonometric functions, and Type2 charstring instructions don't come with a trig. library, so ... we need to write our own!

In fact, let's use Bhaskara I's method of "sort of kind of" approximating a sine wave -or rather half of one- by using a relatively simple expression:

                 4x(π-x)
sin(x) = 4 * ----------------
              5π^2 - 4x(π-x)