Skip to content

Instantly share code, notes, and snippets.

View baptistebriel's full-sized avatar

Baptiste Briel baptistebriel

View GitHub Profile
@baptistebriel
baptistebriel / uvRotate.glsl
Created August 23, 2023 16:38 — forked from raphaelameaume/uvRotate.glsl
Rotate uv in fragment shader
vec2 uvRotate (vec2 baseUv, float angle, vec2 center) {
vec2 uv = baseUv;
uv -= center;
mat2 m = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));
uv = m * uv;
uv += center;
return uv;
@baptistebriel
baptistebriel / hello-apple.md
Created October 23, 2020 17:12 — forked from Linrstudio/hello-apple.md
solutions for window.innerWidth / innerHeight issue in iOS9

iOS9 returns double the value for window.innerWidth & window.innerHeight
The versions that are concerned are: 9.0.0, 9.0.1, 9.0.2

A few people got mad on twitter:

window.innerWidth in iOS 9 Safari returns double the number it did in iOS 8? Is this real life? tell me no — @rachsmithtweets
iOS9 Safari has the most insane bug where window.innerWidth / innerHeight is *sometimes* twice as large as it should be. ughhhh. !? — @mattdesl

iOS9 innerWidth/innerHeight is having a lot of fun these days — @ayamflow

@baptistebriel
baptistebriel / gist:d4117bd65e4dd917b42a80e3f4afe5c6
Created October 6, 2018 10:41
Going beyond 60FPS by disabling VSync on Google Chrome
// https://medium.com/@hellomondaycom/how-we-built-the-google-cloud-infrastructure-webgl-experience-dec3ce7cd209
open -a "Google Chrome" --args --disable-gpu-vsync
@baptistebriel
baptistebriel / frag
Created September 26, 2018 17:06 — forked from Samsy/frag
triangle
uniform sampler2D tex;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tex, vUv );
}
@baptistebriel
baptistebriel / index.js
Created December 14, 2017 23:19 — forked from lancejpollard/index.js
webgl basics
var vs = document.getElementById('vs').textContent;
var fs = document.getElementById('fs').textContent;
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('experimental-webgl', {
alpha: false,
antialias: true,
premultipliedAlpha: false,
stencil: true
});
@baptistebriel
baptistebriel / gist:29e761fbc7cc5923cf6b99444a2935c4
Created August 9, 2017 17:44
compress mp4 video using ffmpeg
// http://ericholsinger.com/install-ffmpeg-on-a-mac
ffmpeg -i input.mp4 -vcodec h264 -acodec mp3 output.mp4
// source: https://plus.google.com/+AddyOsmani/posts/TanDFKEN9Kn
var _log = console.log;
console.log = function() {
_log.call(console, '%c' + [].slice.call(arguments).join(' '), 'color:transparent;text-shadow:0 0 2px rgba(0,0,0,.5);');
};

The issue:

..mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

(from a new defunct https://developers.google.com/mobile/articles/fast_buttons article)

touch-action CSS property can be used to disable this behaviour.

touch-action: manipulation The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.

@baptistebriel
baptistebriel / orientation.js
Last active August 29, 2015 14:14
screen.orientation
if (screen.lockOrientation) {
screen.lockOrientation('portrait-primary');
}
else if (screen.mozLockOrientation) {
screen.mozLockOrientation('portrait-primary');
}
else if (screen.orientation && screen.orientation.lock) {
screen.orientation.lock('portrait-primary');
}
@baptistebriel
baptistebriel / modules.md
Last active September 18, 2021 09:18 — forked from mattdesl/modules.md