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 options = { | |
| method: 'POST', | |
| url: 'https://my.url.com/endpoint', | |
| body: { | |
| username: 'my_username' | |
| password: 'my_password' | |
| ... | |
| } |
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 mergeSort(arr) { | |
| //base case | |
| if (arr.length < 2) return arr; | |
| var halfLength = Math.ceil(arr.length / 2); | |
| var leftSide = arr.splice(0, halfLength); | |
| var rightSide = arr; // just to keep mental model simple | |
| return _stitch(mergeSort(leftSide), mergeSort(rightSide)); | |
| } |
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 fibonacci(n) { | |
| if (n <= 2) { // base case | |
| return 1; | |
| } | |
| else { | |
| return fibonacci(n - 1) + fibonacci(n - 2); | |
| } | |
| } | |
| fibonacci(8) // 21 |
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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| classNames: ['ember-component'] | |
| }); |
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
| import Ember from 'ember'; | |
| // @see http://emberjs.jsbin.com/beboga/edit?js,output | |
| export default function dynamicAlias(target, keyKey) { | |
| var prefix = target ? `${target}.` : ''; | |
| var dynamicAliasKey = `${prefix}${keyKey}_alias`; | |
| return Ember.computed(function() { | |
| var key = `${prefix}${this.get(keyKey)}`; | |
| Ember.defineProperty(this, dynamicAliasKey, Ember.computed.alias(key)); |
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 promise = new Promise(function(resolve, reject) { | |
| // do a thing, possibly async, then… | |
| if (/* everything turned out fine */) { | |
| resolve("Stuff worked!"); | |
| } | |
| else { | |
| reject(Error("It broke")); | |
| } | |
| }); |
NewerOlder


