Skip to content

Instantly share code, notes, and snippets.

Working on @ToDesktop

Dave Jeffery davej

Working on @ToDesktop
Block or report user

Report or block davej

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

Keybase proof

I hereby claim:

  • I am davej on github.
  • I am davej ( on keybase.
  • I have a public key ASCGM6pZ2DMI-QNgpHyOlpPARpMxaK5PQI2eJIkwfMxiwwo

To claim this, I am signing this object:

davej / finished-polyfill.js
Last active Aug 29, 2019 — forked from simevidas/finished-polyfill.js
Animation.prototype.finished polyfill
View finished-polyfill.js
// only polyfill .finished in browsers that already support animate()
if (document.body.animate) {
// Chrome does not seem to expose the Animation constructor globally
if (typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
if (!('finished' in Animation.prototype)) {
Object.defineProperty(Animation.prototype, 'finished', {
davej /
Created Dec 23, 2017
Prevent Mid 2014 MBP random shutdown
# From
from time import sleep
while True:
davej / isLocalhost.js
Created Apr 9, 2017
Detect if current hostname is local
View isLocalhost.js
const isLocalhostName = window.location.hostname === 'localhost';
const isLocalhostIPv6 = window.location.hostname === '[::1]';
const isLocalhostIPv4 = window.location.hostname.match(
const isLocalhost = isLocalhostName || isLocalhostIPv6 || isLocalhostIPv4;
davej / fetch-timeout.js
Last active Dec 6, 2019
Add a pseudo timeout/deadline to a request using the ES6 fetch api
View fetch-timeout.js
new Promise((_, reject) =>
setTimeout(() => reject(new Error('Timeout')), 7000)
davej / onScrollYChange.js
Last active Sep 12, 2016
Performant scroll change listener
View onScrollYChange.js
// Your scroll callback will only be called once per frame and only
// when the y-position changes. Good for doing DOM work without causing
// unnecessary reflows of the document.
function onScrollYChange(callback) {
let latestKnownScrollY = 0, ticking = false;
const scrollChanged = () => {
ticking = false;
const currentScrollY = latestKnownScrollY;
davej / optionDefaults.js
Last active Jul 25, 2016
Options object merged with defaults in ES2015+
View optionDefaults.js
function createSite(name, assignedOptions = {}) {
const defaultOptions = {
html: 'jade',
styles: 'scss',
scripts: 'babel',
whitespace: '2 spaces',
const options = Object.assign({}, defaultOptions, assignedOptions);
davej / transitionToPromise.js
Last active Dec 27, 2019
Do a CSS transition and resolve promise when complete
View transitionToPromise.js
const transitionToPromise = (el, property, value) =>
new Promise(resolve => {[property] = value;
const transitionEnded = e => {
if (e.propertyName !== property) return;
el.removeEventListener('transitionend', transitionEnded);
el.addEventListener('transitionend', transitionEnded);
View gist:c697978bf61ff4e47317
Verifying that +davej is my Bitcoin username. You can send me #bitcoin here:
View gist:49b25fa90f75c7615919
extendsScope_module = angular.module 'classy-extends', ['classy-core']
Note that this does NOT get the mixin class dependencies as of now.
name: 'extends'
localInject: ['$controller']
You can’t perform that action at this time.