This file contains hidden or 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
| ### | |
| # To create a plugin you need to include the `classy-core` module and then pass | |
| # your plugin object into the `class.plugin.controller function` | |
| ### | |
| angular.module('classy-yourPlugin', ['classy-core']).classy.plugin.controller | |
| name: 'yourPlugin' | |
| ### | |
| # Dependencies placed in the localInject array will be available on `@` (`this`) |
This file contains hidden or 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
| /* | |
| * To create a plugin you need to include the `classy-core` module and then pass | |
| * your plugin object into the `class.plugin.controller function` | |
| */ | |
| angular.module('classy-yourPlugin', ['classy-core']).classy.plugin.controller({ | |
| name: 'yourPlugin', | |
| /* | |
| * Dependencies placed in the localInject array will be available on `@` (`this`) | |
| * in the plugins init and postInit methods. |
This file contains hidden or 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
| extendsScope_module = angular.module 'classy-extends', ['classy-core'] | |
| ### | |
| Note that this does NOT get the mixin class dependencies as of now. | |
| ### | |
| extendsScope_module.classy.plugin.controller | |
| name: 'extends' | |
| localInject: ['$controller'] |
This file contains hidden or 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
| Verifying that +davej is my Bitcoin username. You can send me #bitcoin here: https://onename.io/davej |
This file contains hidden or 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
| const transitionToPromise = (el, property, value) => | |
| new Promise(resolve => { | |
| el.style[property] = value; | |
| const transitionEnded = e => { | |
| if (e.propertyName !== property) return; | |
| el.removeEventListener('transitionend', transitionEnded); | |
| resolve(); | |
| } | |
| el.addEventListener('transitionend', transitionEnded); | |
| }); |
This file contains hidden or 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
| function createSite(name, assignedOptions = {}) { | |
| const defaultOptions = { | |
| html: 'jade', | |
| styles: 'scss', | |
| scripts: 'babel', | |
| whitespace: '2 spaces', | |
| }; | |
| const options = Object.assign({}, defaultOptions, assignedOptions); | |
| /* |
This file contains hidden or 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
| // 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; | |
| callback(currentScrollY) |
This file contains hidden or 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
| Promise.race([ | |
| fetch('/foo'), | |
| new Promise((_, reject) => | |
| setTimeout(() => reject(new Error('Timeout')), 7000) | |
| ) | |
| ]); |
This file contains hidden or 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
| const isLocalhostName = window.location.hostname === 'localhost'; | |
| const isLocalhostIPv6 = window.location.hostname === '[::1]'; | |
| const isLocalhostIPv4 = window.location.hostname.match( | |
| // 127.0.0.1/8 | |
| /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ | |
| ); | |
| const isLocalhost = isLocalhostName || isLocalhostIPv6 || isLocalhostIPv4; |
This file contains hidden or 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
| # From https://discussions.apple.com/thread/8115237 | |
| from time import sleep | |
| while True: | |
| sleep(0.00002) |