Skip to content

Instantly share code, notes, and snippets.

View bendc's full-sized avatar

Benjamin De Cock bendc

View GitHub Profile
@bendc
bendc / hello-message-render.js
Created January 4, 2017 16:48
Web Components: hello-message render
document.body.innerHTML = "<hello-message>Jane</hello-message>";
@bendc
bendc / objectmap.js
Created October 26, 2016 08:00
Object mapping
const odd = { a: 1, b: 3 };
const even = Object.entries(odd).reduce((object, pair) => {
const [key, value] = pair;
object[key] = value + 1;
return object;
}, {});
console.log(even); // => { a: 2, b: 4 }
@bendc
bendc / cloneMap.js
Created October 25, 2016 08:07
Deep clone a Map containing JSON-compatible data
const clone = map =>
new Map(JSON.parse(JSON.stringify([...map])));
@bendc
bendc / easing.css
Created September 23, 2016 04:12
Easing CSS variables
:root {
--ease-in-quad: cubic-bezier(.55, .085, .68, .53);
--ease-in-cubic: cubic-bezier(.550, .055, .675, .19);
--ease-in-quart: cubic-bezier(.895, .03, .685, .22);
--ease-in-quint: cubic-bezier(.755, .05, .855, .06);
--ease-in-expo: cubic-bezier(.95, .05, .795, .035);
--ease-in-circ: cubic-bezier(.6, .04, .98, .335);
--ease-out-quad: cubic-bezier(.25, .46, .45, .94);
--ease-out-cubic: cubic-bezier(.215, .61, .355, 1);
@bendc
bendc / .vimrc
Last active October 11, 2018 18:29
Vim config
set nocompatible
set encoding=utf-8 nobomb
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
@bendc
bendc / svgo.json
Created August 30, 2016 07:05
Sketch's SVGO Compressor settings
{
"comment": "This is the settings file for the SVGO Compressor Plugin. For more info, please check <https://github.com/BohemianCoding/svgo-compressor>",
"pretty": false,
"indent": 2,
"plugins": [
{
"name": "cleanupAttrs"
},
{
"name": "cleanupEnableBackground"
@bendc
bendc / supportsES6.js
Created August 25, 2016 08:05
Test if ES6 is ~fully supported
var supportsES6 = function() {
try {
new Function("(a = 0) => a");
return true;
}
catch (err) {
return false;
}
}();
@bendc
bendc / interval.js
Created August 18, 2016 20:28
Better setInterval
const interval = (callback, delay) => {
const tick = now => {
if (now - start >= delay) {
start = now;
callback();
}
requestAnimationFrame(tick);
};
let start = performance.now();
requestAnimationFrame(tick);
@bendc
bendc / merge.js
Created July 21, 2016 14:15
Deep merge of JSON-like objects
const merge = (() => {
const duplicate = object => JSON.parse(JSON.stringify(object));
return (...objects) => Object.assign(...objects.map(duplicate));
})();
@bendc
bendc / define.js
Created July 8, 2016 09:24
Friendlier object definition
const define = (object, ...pairs) =>
(Array.isArray(pairs[0]) ? pairs : [pairs]).reduce((accumulator, pair) => {
const [ key, value ] = pair;
return Object.defineProperty(accumulator, key, { value, enumerable: true });
}, object);