Skip to content

Instantly share code, notes, and snippets.

View souporserious's full-sized avatar

Travis Arnold souporserious

View GitHub Profile
@whoisryosuke
whoisryosuke / Box.tsx
Created May 27, 2022 00:24
Shader / GLSL / OpenGL - Inner border fragment shader. Resembles a "prototype" box for "grid"-like level debugging in game development.
import * as THREE from 'three'
import { useFrame, extend } from '@react-three/fiber'
import { useRef, useState } from 'react'
import useStore from '@/helpers/store'
import { shaderMaterial } from '@react-three/drei'
import { Mesh } from "three"
import vertex from './glsl/shader.vert'
import fragment from './glsl/shader.frag'
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
@zaripych
zaripych / typeFootprint.ts
Last active May 14, 2025 11:22
ts-morph type footprint
import {
Project,
Type,
Symbol,
SymbolFlags,
Signature,
Node,
TypeFormatFlags,
} from 'ts-morph';
  • Common setup for engineers with
    • laptop with encrypted hard drive
    • automatic updates (possibly forced, disabling delay)
    • password manager
    • 2FA everywhere
    • dedicated browser for development without extensions except for the ones approved by devsec ops
    • VPN to access internal properties
    • work (dedicate) GitHub account
    • rotate passwords and tokens / keys
  • remote dev machines on premise that can be kept secure and up to date by IT - might reduce chances to compromise engineer machine (accessible only via vpn)
import React, { useRef, useState, useLayoutEffect, useCallback } from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
@steveruizok
steveruizok / cacheflowelike.ts
Created June 27, 2021 21:05
A beautiful shape for tldraw.
// Run this code on tldraw.com
// By @steveruizok
// Based on an awesome image by @cacheflowe: https://twitter.com/cacheflowe/status/1408902719130288130
new NumberControl({
label: 'radius',
value: 200,
min: 50,
max: 500,
})
@notwaldorf
notwaldorf / README.md
Last active January 4, 2025 16:51
A very minimal p5.js polyfill for when you want to write basic p5.js code but not import the whole kitchen sink.

Minimal p5 polyfill

This is a very minimal bit of polyfill code for when you want to use some basic p5.js code you wrote, but not pay the performance cost associated with importing the whole kitchen sink.

It basically implements some of the sintactic sugar I use the most from p5.js but using the Canvas api, so that I have the p5 api but without all the magic I'm probably not using in this particular sketch.

@sindresorhus
sindresorhus / esm-package.md
Last active June 7, 2025 05:45
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@crabmusket
crabmusket / README.md
Last active December 11, 2024 21:59
Headless rendering with THREE.js

Headless THREE

Created with

Make sure you install headless-gl's dependencies, then run with XVFB like so:

@tannerlinsley
tannerlinsley / createCrudHooks.js
Created November 29, 2020 06:39
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>