A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
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 firstThatCompleteSuccessfullyES6 = (options) => { | |
| // return the first promise that resolve | |
| const oneSuccess = (promises) => Promise.all(promises.map(p => { | |
| // If a request fails, count that as a resolution so it will keep | |
| // waiting for other possible successes. If a request succeeds, | |
| // treat it as a rejection so Promise.all immediately bails out. | |
| return p.then( | |
| (val) => { return Promise.reject(val); }, | |
| (err) => { return Promise.resolve(err); } |
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 mock globally in all your tests, add to setupTestFrameworkScriptFile in config: | |
| // https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string | |
| jest.mock('moment', () => { | |
| const moment = require.requireActual('moment-timezone'); | |
| moment.tz.setDefault('America/Los_Angeles'); // Whatever timezone you want | |
| return moment; | |
| }); |
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
| /* Based on http://www.html5rocks.com/en/tutorials/pagevisibility/intro/ */ | |
| class PageVisibilityService { | |
| constructor(store) { | |
| this.store = store; | |
| this.prop = this.getHiddenProp(); | |
| this.register(); | |
| } | |
| getHiddenProp(){ |
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
| var path = require('path'), | |
| fs = require('fs'); | |
| //this node modules will be require from cordova-lib in main function | |
| var shell; | |
| module.exports = function(context) { | |
| //global module to be share globally in this module | |
| shell = context.requireCordovaModule('shelljs'); |
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
| #!/bin/bash | |
| ### Setup a wifi Access Point on Ubuntu 12.04 (or its derivatives). | |
| ### make sure that this script is executed from root | |
| if [ $(whoami) != 'root' ] | |
| then | |
| echo " | |
| This script should be executed as root or with sudo: | |
| sudo $0 | |
| " |
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 encrypt(text){ | |
| var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq') | |
| var crypted = cipher.update(text,'utf8','hex') | |
| crypted += cipher.final('hex'); | |
| return crypted; | |
| } | |
| function decrypt(text){ | |
| var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq') | |
| var dec = decipher.update(text,'hex','utf8') |
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
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |