(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |
#!/usr/bin/env python | |
# coding: utf-8 | |
from optparse import OptionParser | |
import sys | |
usage = """%prog infile [options] | |
Reads an ICO file and writes a CUR file. The ICO file should contain a single | |
image. If no outfile name is provided, the infile name is used to create an |
/* | |
* Vanilla JS - Touch Gestures | |
* @version 0.1 | |
* @inspired QuoJS - http://quojs.tapquo.com | |
* | |
* Supported Gestures: singleTap, doubleTap, hold, | |
* swipe, swiping, swipeLeft, swipeRight, swipeUp, swipeDown, | |
* rotate, rotating, rotateLeft, rotateRight, pinch, pinching, | |
* pinchIn, pinchOut, | |
* drag, dragLeft, dragRight, dragUp, dragDown |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/** | |
* Returns the total amount of disk space used (in MB) by localStorage for the current domain. | |
*/ | |
var getLocalStorageSize = function() { | |
var total = 0; | |
for (var x in localStorage) { | |
// Value is multiplied by 2 due to data being stored in `utf-16` format, which requires twice the space. | |
var amount = (localStorage[x].length * 2) / 1024 / 1024; | |
total += amount; | |
} |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
// Load fonts async by default | |
// Load sync from SW cache when available. | |
// | |
// Snippet assumes your Service Worker caches fonts as part of installation, so that | |
// an 'activated' Service Worker means the fonts are cached with 100% confidence. | |
if ( | |
'serviceWorker' in navigator && | |
navigator.serviceWorker.controller !== null && | |
navigator.serviceWorker.controller.state === 'activated' | |
) { |