Skip to content

Instantly share code, notes, and snippets.

@ayamflow
ayamflow / Git team workflow - merge + rebase
Last active August 29, 2015 14:10
Git team workflow - merge + rebase
Git team workflow - merging and rebasing
0. git checkout [branch]
1. git push origin [branch]
2. git checkout master
3. git pull --rebase
4. git checkout [branch]
5. git rebase master
(6.) git mergetool / git rebase --continue
/*
** Copyright (c) 2012, Romain Dura romain@shazbits.com
**
** Permission to use, copy, modify, and/or distribute this software for any
** purpose with or without fee is hereby granted, provided that the above
** copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
@ayamflow
ayamflow / gist:9a57dddeabbcf529164b
Last active August 29, 2015 14:17
Parallax equation

Because I never remember (work with easing too)

Canvas

var y = data.y - scrollY * data.speed;

// Container height
var targetY = size.height; // window height
@ayamflow
ayamflow / gist:bebf234062c16e0b6937
Created April 16, 2015 09:17
Cross-browser landscape/orientation in CSS
landscape() {
@media screen and (min-aspect-ratio: 13/9) { block; }
}
portrait() {
@media screen and (max-aspect-ratio: 13/9) { block; }
}
// http://blog.abouthalf.com/development/orientation-media-query-challenges-in-android-browsers/
@ayamflow
ayamflow / gist:ab9595ce3cee6bfb6d78
Last active August 29, 2015 14:22
THREEJS objConvert CLI

python objConvert.py -i -o -s flat

@ayamflow
ayamflow / gist:55003a14ae10ec32a56f
Last active October 14, 2015 18:20
3D / WebGL memo

Because I keep forgetting that stuff...

Diffuse

light that will be reflected on different surfaces

Specular

"mirror-like" reflection of light

occlusion / culling

objects outside of viewport should not be rendered

@ayamflow
ayamflow / gist:038026febd0b3db64fae
Created November 19, 2015 19:33
FPS control with RAF
// http://stackoverflow.com/questions/19764018/controlling-fps-with-requestanimationframe
fpsInterval = 1000 / fps; // 24 for instance
then = Date.now();
update();
function update() {
requestAnimationFrame(update);
now = Date.now();
@ayamflow
ayamflow / .md
Created January 22, 2016 19:36
Mobile video - custom cover play
  1. pointer-events: none on cover and play button (might need some nested pointer-events to get the click through the UI to the video)

  2. on iOS, use cuevideoById instead of loadVideoById

  3. ???

  4. Profit !

@ayamflow
ayamflow / .js
Created January 23, 2016 20:26
Canvas resize (including retina)
var ratio = window.devicePixelRatio || 1;
var canvas = this.canvas;
canvas.width = ratio * size.width;
canvas.height = ratio * size.height;
canvas.style.width = size.width + 'px';
canvas.style.height = size.height + 'px';
@ayamflow
ayamflow / .js
Created January 23, 2016 20:27
Canvas fit letter height
'use strict';
/*
This function will resize a letter until it fits the specified height
options:
- height: the height to fit
- precision: how much pixels +/-
- size: the start font size
- increment: the step of each iteration