Skip to content

Instantly share code, notes, and snippets.

View naso's full-sized avatar

Fábio Azevedo naso

View GitHub Profile
import * as React from 'react'
import { SpringValue, easings, useSpring } from 'react-spring'
/**
* Hook that animates height when args.animationKey changes
*
* Ex:
* const animatedBlock = useAnimatedHeight({
* animationKey: key,
* })
//MIT License
//Copyright (c) 2021 Felix Westin
//Source: https://github.com/Fewes/MinimalAtmosphere
//Ported to GLSL by Marcin Ignac
#ifndef ATMOSPHERE_INCLUDED
#define ATMOSPHERE_INCLUDED
// -------------------------------------
@donmccurdy
donmccurdy / JAVASCRIPT_LIBRARY_TOOLS.md
Last active April 16, 2021 05:36
A minimal set of tools for creating a JavaScript or TypeScript library.

These are the build tools I prefer to use when starting a new JavaScript or TypeScript library. Most libraries I write run both in the browser and in node.js. Each project needs to be lightweight, and to minimize maintenance. And I need build chains for those libraries to pretty much "just work". That last part has become more important over time, as I've maintained more libraries and generally had less time to deal with dependencies and build system issues. For web applications, as opposed to libraries consumed in other projects, these choices may or may not make sense. These are opinionated choices, and will probably change over time.

Almost always:

  • microbundle: Zero-config Rollup bundler, with optional TypeScript support
  • tape: Test runner
  • tap-spec: Clean test output

Occasionally:

@andreyryabtsev
andreyryabtsev / backmatting.ipynb
Last active June 5, 2024 04:56
BackMatting.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@developit
developit / *constant-locals-loader.md
Last active February 4, 2022 17:15
Inline Webpack CSS Modules classNames, reducing bundle size. https://npm.im/constant-locals-loader

constant-locals-loader for Webpack

This loader optimizes the output of mini-css-extract-plugin and/or css-loader, entirely removing the potentially large CSS classname mappings normally inlined into your bundle when using CSS Modules.

Run npm install constant-locals-loader, then make these changes in your Webpack config:

module.exports = {
 module: {

python websockets + browser

Two approaches:

The sync approach is faster and less complex. ¯_(ツ)_/¯

Please comment if you have ideas about how to make the asyncio cleaner/faster.

@Danetag
Danetag / critical.js
Last active March 5, 2021 21:18
Using critical.js with cluster for maxi perf
const cluster = require('cluster');
const fs = require('fs');
const path = require('path');
const critical = require('critical');
const minify = require('html-minifier').minify;
/*** Step 01 - define pages */
// Manifest is created with Webpack on build
const manifest = JSON.parse(fs.readFileSync('./static/bundles/manifest.json', 'utf8'));

texture loading

A utility for loading texture in ThreeJS. Will upload to GPU as soon as the texture is loaded, ensuring that it won't cause jank later in your application.

Example:

const loadTexture = require('./loadTexture');

// Returns a THREE.Texture object
@vincentriemer
vincentriemer / ResizeObservable.js
Created December 4, 2017 20:15
React Component prototype that provides element query functionality via ResizeObserver
// @flow
import * as React from "react";
import ResizeObserver from "resize-observer-polyfill";
import invariant from "invariant";
type Entry = {
+contentRect: {
+width: number,
+height: number
@cdata
cdata / three-clone-gltf.js
Created November 8, 2017 23:26
A quick hack to clone a Three.js GLTF scene without re-loading or re-parsing the source.
const cloneGltf = (gltf) => {
const clone = {
animations: gltf.animations,
scene: gltf.scene.clone(true)
};
const skinnedMeshes = {};
gltf.scene.traverse(node => {
if (node.isSkinnedMesh) {