Skip to content

Instantly share code, notes, and snippets.

View naso's full-sized avatar

Fábio Azevedo naso

View GitHub Profile
@cybercase
cybercase / product.js
Last active February 10, 2023 10:59
Python-like itertools.product function in javascript
function product() {
var args = Array.prototype.slice.call(arguments); // makes array from arguments
return args.reduce(function tl (accumulator, value) {
var tmp = [];
accumulator.forEach(function (a0) {
value.forEach(function (a1) {
tmp.push(a0.concat(a1));
});
});
return tmp;
@max-mapper
max-mapper / readme.md
Last active March 16, 2023 15:18
Video stabilization using VidStab and FFMPEG (Mac OS X)

Video stabilization using VidStab and FFMPEG

Examples here use the default settings, see the VidStab readme on GitHub for more advanced instructions.

Here's an example video I made

Install ffmpeg with the vidstab plugin from homebrew

brew install ffmpeg --with-libvidstab
@naso
naso / Reveal.glsl
Last active July 8, 2016 14:15 — forked from glslioadmin/TEMPLATE.glsl
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D to, from;
uniform float progress;
uniform vec2 resolution;
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
vec4 a = texture2D(from, p); //vec4(0.0, 0.0, 0.0, 0.0);
@Rich-Harris
Rich-Harris / service-workers.md
Last active June 26, 2024 12:04
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@addyosmani
addyosmani / route-based-chunking.md
Last active December 28, 2021 06:18
Route-based chunking

Route-based chunking

Many of us building single-page apps today use JavaScript module bundling tools that trend towards a monolithic "bundle.js" file including the full app and vendor code for multiple routes. This means if a user lands on any arbitrary route they need to wait for a large bundle of JS to be fetched, parsed and executed before the application is fully rendered and interactive.

screen shot 2016-09-28 at 4 45 52 pm

This is a little backwards, especially when apps are used under real-world network (3G) and device

@mattdesl
mattdesl / glsl-background.glsl
Created April 26, 2017 18:02
Like CSS background-size: contain but in GLSL
vec2 backgroundUV (vec2 uv, vec2 resolution, vec2 texResolution) {
float tAspect = texResolution.x / texResolution.y;
float pAspect = resolution.x / resolution.y;
float pwidth = resolution.x;
float pheight = resolution.y;
float width = 0.0;
float height = 0.0;
if (tAspect > pAspect) {
height = pheight;
@niw
niw / fetch_nike_puls_all_activities.bash
Last active June 10, 2024 11:43
A simple NikePlus API description to fetch past run metrics
#!/usr/bin/env bash
# fetch_nike_puls_all_activities.bash
# A simple bash script to fetch all activities and metrics from NikePlus.
# See `nike_plus_api.md` for the API details.
readonly bearer_token="$1"
if [[ -z "$bearer_token" ]]; then
echo "Usage: $0 bearer_token"
exit
@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) {
@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

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