Skip to content

Instantly share code, notes, and snippets.

(╯°□°)╯︵ ┻━┻

David Larlet davidbgk

(╯°□°)╯︵ ┻━┻
View GitHub Profile
View es6-feature-detection.js
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
} catch(e) {
alert('Your browser does not support ES6!')
davidbgk /
Created Jan 14, 2017 — forked from anonymous/ template
#!/usr/bin/env python
# coding=utf-8
python distribute file
from __future__ import (absolute_import, division, print_function,
unicode_literals, with_statement)
View sw-precache-config.js
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), {
cacheId: `know-it-all`,
filename: `service-worker.js`,
stripPrefix: `public/`,
staticFileGlobs: [
`public/app.*.js`, // don't include the polyfills version
dontCacheBustUrlsMatching: [
/\.(js|json)$/, // I'm cache busting js and json files myself
View gist:bc358a9e89bfbf3bf4f79cd5f6d5bbc8
window.Promise || document.write('<script src=""><\/script>');
window.fetch || document.write('<script src=""><\/script>');
davidbgk / promise-all.js
Created Sep 8, 2016 — forked from naholyr/promise-all.js
Run promise-based async API in series or concurrency
View promise-all.js
// ( T1 => Promise<T2> ) => Array<T1> => Promise<Array<T2>>
export const concurrent = foo => vals =>
export const series = foo => vals =>
vals.reduce((p, val) => p.then(rs => foo(val).then(r => rs.concat([val]))), Promise.resolve([]))
// Usage: promiseOfValues.then(promiseAll.concurrent(functionReturningAPromiseFromAValue))
davidbgk /
Created Aug 9, 2016 — forked from Rich-Harris/
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.

davidbgk /
Created Jun 18, 2016 — forked from almet/
Use named pipes to stream answers between processes without buffering (thanks to stdbuf -o0)
import os
import shlex
import subprocess
def spawn(cmd):
with open("toto", "w") as f:
process = subprocess.Popen(shlex.split(cmd), stdout=f)
davidbgk / README
Created May 9, 2016 — forked from thedod/README
Woof (one-time file exchange) + helper scripts
Woof is an amazingly simple and effective file exchange tool:
This distribution doesn't include simon Budig's original woof
(that started breaking for me), but Edward Samson's fork:
Desktop helper scripts:
filewoof and folderwoof "open with" actions for nautilus etc.
and woofget that runs "woof -U" in a terminal window in /tmp
(e.g. for a launcher button)
View remember.js
"use strict";
function remember(...args){
const [key, value] = args;
if(args.length === 1){ // recall
return new Promise(resolve => {
setTimeout(() => {
const val = localStorage.getItem(key);
View redux-light-example.js
const store = createStore((state = { counter: 0 }, action) => {
switch(action.type) {
return { counter: state.counter + 1 }
return { counter: state.counter - 1 }
return state