Skip to content

Instantly share code, notes, and snippets.

View bigtimebuddy's full-sized avatar

Matt Karl bigtimebuddy

View GitHub Profile
@bigtimebuddy
bigtimebuddy / useTheme.ts
Last active January 3, 2024 15:58
Figma Theme Observer
import { useEffect, useState } from "react";
const getInitialTheme = (): Theme =>
document.documentElement.className.includes("dark") ? "dark" : "light";
type Theme = "dark" | "light";
function useTheme(): Theme {
const [theme, setTheme] = useState<Theme>(getInitialTheme);
useEffect(() => {
const observer = new MutationObserver(function ([event]) {
@bigtimebuddy
bigtimebuddy / sine-wave.html
Created October 19, 2023 16:19
Draw a sine-wave
<!DOCTYPE html>
<html>
<body style="background: #eee;">
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #d3d3d3;background: #fff;image-rendering: pixelated;">
</canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
@bigtimebuddy
bigtimebuddy / Ticker.ts
Last active September 28, 2023 17:17
Simple shared ticker for wrapping a single requestAnimationFrame
interface Tickerable {
render(time: number): void;
}
/**
* Create a shared, static frame ticker. Using many requestAnimationFrame
* callbacks can be a performance killer, so this wraps multiple targets
* with a single requestAnimationFrame call.
*/
class Ticker {
@bigtimebuddy
bigtimebuddy / ae-render-comp.jsx
Created June 20, 2023 15:36
After Effects Render Current Composition
// Create a new project object
var myProject = app.project;
// Get the current composition
var myComp = myProject.activeItem;
// Create a new render queue item
var myRenderItem = myProject.renderQueue.items.add(myComp);
// Set the output module to lossless
@bigtimebuddy
bigtimebuddy / ae-get-shape-source-rect.jsx
Last active June 13, 2023 16:37
After Effects Shape Layer Bounds
/**
* sourceRectAtTime isn't useful for shape layers, we need to compute based on the vectors.
* @param {ShapeLayer} layer - Shape layer
* @param {number} time
*/
function getShapeBounds(layer, time) {
var layerPosition = layer.position.valueAtTime(time, false);
var layerAnchor = layer.anchorPoint.valueAtTime(time, false);
var leftLayerOffset = layerPosition[0] - layerAnchor[0];
var topLayerOffset = layerPosition[1] - layerAnchor[1];
@bigtimebuddy
bigtimebuddy / ae-describe-object.jsx
Created June 13, 2023 13:15
After Effect Property Describe
/**
* Layers in AE ExtendScript are notoriously hard to understand
* the heirarchy of properties. I use this utility to output the properties/groups
* @param {*} obj - can be a Layer or object
* @param {number} [indent=0] - starting indent
*/
function describeObject(obj, indent) {
indent = indent || 0;
var indentString = "";
for (var i = 0; i < indent; i++) {

Proposal for v8

Each high-level display object package (sprite, mesh, etc) has common code as well as renderer-specific adapters. This can be achieved with exports in the package.json.

// install
import '@pixi/sprite/gl';
import '@pixi/sprite/gpu';
@bigtimebuddy
bigtimebuddy / downloadFile.ts
Last active July 14, 2021 16:59
Very simple, no-dependencies file download
import * as fs from 'fs';
import * as https from 'https';
/**
* Very simple remote download file.
* @param url - URL file to download
* @param filePath - Output file location
*/
function downloadFile(url: string, filePath: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
@bigtimebuddy
bigtimebuddy / regular-status.md
Last active May 19, 2021 16:47
regular-status

Regular status means upon entering a point of service (restaurant, coffee shop) your exact order can be anticipated without any verbal or physical prompting.

My friend Dave Schlafman is the professional at regular status. He has more regular status in the metro Boston-area than anyone I know--probably dozens of restaurants and coffee shops. I've known this about him since we were at college together. I believe I have distilled down what exactly are the qualities that make regular status possible using Dave as a test case.

  1. You need to be memorable to the staff who probably sees hundreds of people each day. Options include being: very friendly, neurotic, funny, eccentric. A consistent visual cue, like wearing the same jacket or hat, certainly would help to make you recognizable.
  2. You need to be original with your order.  Maybe even get something that no one else would order. For instance, at Starbucks Dave's order goes something like this: "Soy chai latte, five pumps of chai, no water, extra ext
[ "@pixi/constants",
"@pixi/math",
"@pixi/polyfill",
"@pixi/runner",
"@pixi/settings",
"@pixi/unsafe-eval",
"@pixi/ticker",
"@pixi/utils",
"@pixi/display",
"@pixi/core",