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
Object.defineProperty(window, 'data', {set: function () {console.trace()}, get: function () {return 1}}); |
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
$$('span.value:last-of-type') | |
.map(node => node.textContent.trim()) | |
.filter(txt => txt.indexOf('EUR') === 0) | |
.map(txt => txt.split('EUR')[1].trim().replace(',','.')) | |
.reduce((a,b) => a + +b, 0) |
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
const listDirectivesApp = () => { | |
const listDirectives = name => { | |
return angular | |
.module(name) | |
._invokeQueue | |
.filter(item => 'directive' === item[1]) | |
.map(item => item[2][0]); | |
}; | |
return angular |
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
/** | |
* From @link {https://gist.github.com/zenparsing/5dffde82d9acef19e43c} | |
* Usage: | |
* output = dedent`Monique mange: | |
* - une pomme | |
* - une poire | |
* Voilou` | |
* | |
* Output: | |
* 'Monique mange: |
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
function mockUserAgent(ua) { | |
'use strict'; | |
var copyNav = navigator; | |
navigator = {}; | |
navigator.__proto__ = copyNav; | |
navigator.__defineGetter__('userAgent', function() { | |
return ua; | |
}); | |
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
var PSEUDO = 'bob' | |
var service = angular.element(document.body).injector().get('Username') | |
service.register(PSEUDO, function(data) { | |
location.href = '/'; | |
}, function(data) { | |
console.log(data) | |
}); |
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
const dispatcherApp = dispatcher('App'); | |
const eventChange = dispatcherApp | |
.on('change', data => { | |
console.log('App.change', data); | |
}) | |
const eventTest = dispatcherApp | |
.on('test', data => { | |
console.log('App.test', data); |
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
/** | |
* Format an input from a given mask, key per key | |
* - XXXX-XXX-XXX-XXX => 1111-222-333-444 | |
* - XXXX XXXX XXXX => 1111 2222 3333 | |
* - XX/XX => 11/22 | |
* @param {String} mask | |
* @return {Function} | |
*/ | |
const maskInput = (mask = '') => { |
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
/** | |
* @param String content Html | |
* @param String state State url -> $state.$current.url | |
*/ | |
const bindAnchor = (content, state) => { | |
return content | |
.replace(/href="#\w+"/g, match => { | |
const url = match.split('#'); | |
return `${url[0]}#${state}#${url[1]}`; | |
}); |
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
/** | |
* Detect the type of network | |
* @link http://caniuse.com/#feat=resource-timing | |
*/ | |
function getNetwork() { | |
// Default case if the network detection api is not available | |
if (!window.performance || !window.performance.getEntriesByName) { | |
return '4G'; | |
} |