- Install jsgrep
- Convert your source code using
node spatch-cli.js es5-to-es3.spatch source.js // yields the converted source
- Prepare the implementation of ES5 by implemeting the missing polyfills in es5.js
- Concat es5.js and the converted code
- Wrap the result of the previous steps in a closure and export your object
var approx = function(a, b, eps) { | |
// http://en.wikipedia.org/wiki/Machine_epsilon | |
eps = eps || 5e-16; | |
return |a - b| < eps; | |
} | |
approx(0.1 * 0.2, 0.02) // true |
// modified John Resig's http://ejohn.org/projects/flexible-javascript-events/ | |
var div = document.createElement('div'); | |
var addEvent, removeEvent; | |
if ( div.addEventListener ) { | |
addEvent = function( elem, type, fn ) { | |
elem.addEventListener( type, fn, false ); | |
}; |
requirements: requirements.txt.out | |
requirements.txt.out: requirements.txt | |
pip install -r requirements.txt | tee requirements.txt.out |
Function.prototype.runOnBackgroundThread = function (aCallback) { | |
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"}); | |
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob)); | |
_worker.onmessage = aCallback; | |
_worker.postMessage(); | |
} | |
var _test = function () { | |
postMessage((1+1).toString()); | |
} |
// NOTE: only escapes a " if it's not already escaped | |
function escapeDoubleQuotes(str) { | |
return str.replace(/\\([\s\S])|(")/g,"\\$1$2"); // thanks @slevithan! | |
} | |
escapeDoubleQuotes(`ab`); // ab => ab (nothing escaped) | |
escapeDoubleQuotes(`a"b`); // a"b => a\"b | |
escapeDoubleQuotes(`a\\"b`); // a\"b => a\"b (nothing escaped) | |
escapeDoubleQuotes(`a\\\\"b`); // a\\"b => a\\\"b | |
escapeDoubleQuotes(`a\\\\\\"b`); // a\\\"b => a\\\"b (nothing escaped) |
#Retina images Sharpness is relative. We can only observe if something is really sharp if we can see it next to something that's sharper. Lots of people are looking for solutions for the problem that images look blurry on retina displays. All solutions I've seen so far give the advice to send an image that's twice as wide and twice as high to these new screens. Before you start sending these images, be sure to understand that these files will be four times the size of the smaller version. People with a high end device and a low end connection—everybody in the train in The Netherlands—will hate you.
##Image types I'm generalizing here, but there are two types of images: (1) graphics like logos and (2) photos. Quadroupled images might be justified for the first kind, for logos, icons, things like that. You could also try to find a solution in clever SVG files—with media queries in them, why not? These kinds of ima
import os.path | |
import contextlib | |
import hashlib | |
from flask import Flask | |
from flask.helpers import safe_join | |
# Injects an "h" parameter on the URLs of static files that contains a hash of | |
# the file. This allows the use of aggressive cache settings on static files, | |
# while ensuring that content changes are reflected immediately due to the | |
# changed URLs. Hashes are cached in-memory and only checked for updates when |
# -*- coding: utf-8 -*- | |
import os | |
from flask import Flask | |
from flask_heroku import Heroku | |
from flask_sslify import SSLify | |
from raven.contrib.flask import Sentry | |
from flask.ext.celery import Celery |
import urllib | |
import settings | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
class YahooException(Exception): | |
pass |