Skip to content

Instantly share code, notes, and snippets.

Gaël Métais gmetais

Block or report user

Report or block gmetais

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Rich-Harris /
Last active Nov 12, 2019
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

View core.js
export function $(value) {
if(value == null) {
return []
if(typeof value === "string") {
return [...document.querySelectorAll(value)]
if(typeof value.nodeType === "number") {
return Array.of(value)
gmetais / gzip-conf.txt
Last active Jul 15, 2019
This is a list of Content-Type / mime-type for a server Gzip compression configuration
View gzip-conf.txt
jpvincent / optimizedFor.js
Last active Jul 8, 2016
never blocking loop mechanism, using setTimeout 0 trick and time control to break the loop and let the browser breath
View optimizedFor.js
* NEVER BLOCKING LOOP : implementation of the infamous setTimeout 0 hack, with time checking in order to guarantee fluidity without sacrificing execution speed.
* var array = ["a way too big array that is heavy to process"]
* optimizeFor({
* nbIterations: array.length,
* each:function( index ) {
* doSomethingUsefulWith( array[ index ] );
* },
sergejmueller /
Last active Sep 5, 2019
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
View SmoothScroll.js
Please duplicate this radar for a Safari fix!
This will clean up a 50-line workaround.
rdar://22376037 (
(Now available as a standalone repo.)
thomseddon / gist:3511330
Last active Oct 9, 2019
AngularJS byte format filter
View gist:3511330
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
psebborn / countCSSRules.js
Last active Jan 18, 2019
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
View countCSSRules.js
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
for (var i = 0; i < document.styleSheets.length; i++) {
function countSheet(sheet) {
You can’t perform that action at this time.