Skip to content

Instantly share code, notes, and snippets.

:octocat:
...

Michael Gerstmann webdesignberlin

:octocat:
...
Block or report user

Report or block webdesignberlin

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
View flip.css
.element.collapsed {
height: 90px;
width: 100%;
}
.element.expanded {
top: 0;
bottom: 0;
left: 0;
width: 100%;
@webdesignberlin
webdesignberlin / awaitIdle.js
Created Dec 16, 2016 — forked from potch/awaitIdle.js
Rather rough sketch of using requestIdleCallback to break up JS execution
View awaitIdle.js
function idle(action) {
return new Promise((resolve, reject) => {
requestIdleCallback(timing => resolve(action(timing)));
});
}
async function init() {
criticalPath();
await idle(lessImportant);
await idle(nonCritical);
@webdesignberlin
webdesignberlin / sort.js
Created Nov 18, 2016 — forked from laggingreflex/sort.js
Sort github comments by reactions
View sort.js
(() => {
const q = (e, s) => e.querySelector(s);
const qA = (e, s) => e.querySelectorAll(s);
const num = e => parseInt(e.nextSibling.wholeText.trim())
const d = document.querySelector('.js-discussion.js-socket-channel');
/* uncomment one of these to sort by */
const sortBy = '+1';
// const sortBy = '-1';
// const sortBy = 'smile';
View canvasrecord.js
(function() {
let canvas = document.querySelector('canvas');
// Optional frames per second argument.
let stream = canvas.captureStream(25);
let recorder = new MediaRecorder(stream, options);
let blobs = [];
function download(blob) {
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
View object-assign-arrays.js
const original = [0,1,2,3];
const copy = Object.assign([], original, { 2: 42 }); // [0,1,42,3]
console.log(original);
// [ 0, 1, 2, 3 ]
console.log(copy);
// [ 0, 1, 42, 3 ]
View jsx-object-literal.jsx
function WhySoManyProps(props) {
const user = extractUser(props);
const fudge = calculateFudge();
const bits = computeBits();
// This is soooooo redundant.
return <SomeComponent user={user} fudge={fudge} bits={bits} />;
}
function Shorthand(props) {
View no-bind-util-object.js
const moment = require('moment');
const PERIOD = moment.duration(3, 'days');
module.exports = {
PERIOD,
isWithinPeriod(test) {
return moment().add(PERIOD).isAfter(test);
},
};
View destructuring-cli.js
#!/usr/bin/env node
// skip the first two args as they are node and this script
const [,,filepath] = process.argv;
doSomethingFSLike(filepath);
View branches-and-leaves.js
const {
topLevel: {
intermediate, // declaration of intermediate
intermediate: {
nested // declaration of nested
}
}
} = {
topLevel: {
intermediate: {
View default-default.js
function defaults({ a = 1, b = 2 } = {}) {
console.log('a', a);
console.log('b', b);
}
defaults();
// a 1
// b 2
defaults({ a: 42, b: 32 });
You can’t perform that action at this time.