Skip to content

Instantly share code, notes, and snippets.

$("html, body").animate({ scrollTop: 0 }, {
duration: 250,
complete: function() {
var elem = document.documentElement;
// setting a padding top on document element will force repaint, but not show any visual effect
elem.style.paddingTop = '1px';
setTimeout(function() {
elem.style.paddingTop = '0';
}, 0);
}
@HektorW
HektorW / gist:10368274
Created April 10, 2014 10:58
lifx util
var lifx = require('lifx');
var lx = lifx.init();
lx.on('bulb', function(bulb) {
queueLights([
[255, 255, 255],
[255, 0, 0],
[0, 255, 0],
[0, 0, 255],
[255, 255, 0],
@HektorW
HektorW / Sleep sort
Last active September 26, 2018 06:57
function sleepSort(res, arr) {
arr.forEach(function(val) {
setTimeout(function() {
res.push(val);
}, val * 5);
})
}
var res = [];
sleepSort(res, [4, 6, 2, 9, 3, 5, 1]);
@HektorW
HektorW / Snow.js
Last active January 1, 2016 05:19
Snow
var Snow = (function() {
var requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback) {
return setTimeout(function() {
callback(performance.now());
}, 16);
};
@HektorW
HektorW / main,js
Created November 5, 2013 11:40
Fixed and workging
//GLOBALS
var triangleVertexPositionBuffer;
var squareVertexPositionBuffer;
var mvMatrix = mat4.create();
var pMatrix = mat4.create();
var gl;
var shaderProgram;