This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: | |
// importScript('./path/to/script.js').then((allExports) => { .... })); | |
function importScript(path) { | |
let entry = window.importScript.__db[path]; | |
if (entry === undefined) { | |
const escape = path.replace(`'`, `\\'`); | |
const script = Object.assign(document.createElement('script'), { | |
type: 'module', | |
textContent: `import * as x from '${escape}'; importScript.__db['${escape}'].resolve(x);`, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_registry = {}; | |
importPolyfill = path => { | |
if(!(path in _registry)) { | |
const entry = _registry[path] = {}; | |
entry.promise = new Promise(resolve => entry.resolve = resolve); | |
document.head.appendChild(Object.assign( | |
document.createElement('script'), | |
{ | |
type: 'module', | |
innerText: `import * as X from '${path}'; _registry['${path}'].resolve(X);`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function uses the Page Visibility API to puase/restart the timeout such that | |
* the time you specify equates to "visibility time". | |
* Note: There is no clearTimeout capability - though it would not be hard to extend this to | |
* provide cancel-ability | |
* | |
* Usage: | |
* setVisiTimeout(function, ms, arg1, arg2, ... ); | |
* | |
* LICENSE: Unlicense <http://unlicense.org/> / CC0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon | |
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later, | |
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads. | |
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive | |
// calls internally. | |
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly | |
// you can starve the UI and be unresponsive to the user. | |
// This is an even FASTER version of https://gist.github.com/bluejava/9b9542d1da2a164d0456 that gives up | |
// passing context and arguments, in exchange for a 25x speed increase. (Use anon function to pass context/args) | |
var soon = (function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon | |
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later, | |
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads. | |
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive | |
// calls internally. | |
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly | |
// you can starve the UI and be unresponsive to the user. | |
// Note: For an even faster version, see https://gist.github.com/bluejava/b3eb39911da03a740727 | |
var soon = (function() { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'm a Vim user, this makes navigation easier | |
setw -g mode-keys vi # I especially like being able to search with /,? when in copy-mode | |
unbind-key j | |
bind-key j select-pane -D # Similar to 'C-w j' to navigate windows in Vim | |
unbind-key k | |
bind-key k select-pane -U | |
unbind-key h | |
bind-key h select-pane -L | |
unbind-key l | |
bind-key l select-pane -R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |