Skip to content

Instantly share code, notes, and snippets.

View huntercaron's full-sized avatar
♻️

Hunter Caron huntercaron

♻️
View GitHub Profile
@mattdesl
mattdesl / random.wgsl
Last active July 2, 2024 14:30
high quality deterministic PRNG in WebGPU & WGSL (xorshift128) - MIT licensed
// each pixel is assigned 4 random u32 values per frame
@group(0) @binding(1)
var<storage, read> rnd_state: array<u32>;
// the current state within this pixel
var<private> local_rnd_state:vec4u;
fn random_u32(state:ptr<private,vec4u>) -> u32 {
var st:vec4u = *state;
/* Algorithm "xor128" from p. 5 of Marsaglia, "Xorshift RNGs" */
@sindresorhus
sindresorhus / esm-package.md
Last active July 30, 2024 15:29
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.
@akella
akella / setup.md
Last active July 10, 2024 14:46
My Setup
@edwinlee
edwinlee / Code.gs
Last active February 21, 2024 10:43
Sync a Google Sheets spreadsheet to a Firebase Realtime database
/**
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
function getEnvironment() {
var environment = {
spreadsheetID: "<REPLACE WITH YOUR SPREADSHEET ID>",
firebaseUrl: "<REPLACE WITH YOUR REALTIME DB URL>"
};
@koenbok
koenbok / store.ts
Last active November 10, 2023 00:17
import * as React from "react";
/**
A hook to simply use state between components
Warning: this only works with function components (like any hook)
Usage:
// You can put this in an central file and import it too
const useStore = createStore({ count: 0 })
// Only export the things that are actually needed, cut out everything else
export { WebGLRenderer } from 'three/src/renderers/WebGLRenderer.js'
export { ShaderLib } from 'three/src/renderers/shaders/ShaderLib.js'
export { UniformsLib } from 'three/src/renderers/shaders/UniformsLib.js'
export { UniformsUtils } from 'three/src/renderers/shaders/UniformsUtils.js'
export { ShaderChunk } from 'three/src/renderers/shaders/ShaderChunk.js'
export { Scene } from 'three/src/scenes/Scene.js'
export { Mesh } from 'three/src/objects/Mesh.js'
export { LineSegments } from 'three/src/objects/LineSegments.js'
@RaheelYawar
RaheelYawar / bloom.fragment.glsl
Created June 22, 2018 08:36
Three.js (GLSL) basic bloom shader
// THREEjs build-in uniforms and attributes (Fragment)
// uniform mat4 viewMatrix - camera.matrixWorldInverse
// uniform vec3 cameraPosition - camera position in world space
varying vec2 vUv;
uniform sampler2D albedo;
void main() {
@sebmarkbage
sebmarkbage / The Rules.md
Last active June 30, 2024 01:30
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@brendandawes
brendandawes / Processing Starting Template
Last active March 28, 2018 14:56
This is the boiler plate template I have setup each time I start a new Processing project. It includes my Dawesome Toolkit library as well as basic stuff for saving .png and .pdf files and exporting frames that you can compile into video. If you're a Vim user you can set this up to automatically be populated when you create a blank .pde file - t…
import dawesometoolkit.*;
import processing.pdf.*;
final String PROJECT = "project-x";
final int BACKGROUND_COLOR = #000000;
final int SECONDS_TO_CAPTURE = 60;
final int VIDEO_FRAME_RATE = 60;
int videoFramesCaptured = 0;
boolean recordVideo = false;
@Zammy
Zammy / DrawRect.frag
Last active April 12, 2024 10:52
Rectangle drawing function GLSL
//all params in normalized units
vec3 drawRect(in vec2 st,
in vec2 center,
in float width,
in float height,
in float thickness,
in vec3 fillColor,
in vec3 strokeColor)
{
vec3 color = vec3(0);