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 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")); | |
} | |
}); |
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
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 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 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 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 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 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
Cypress.Commands.add('login', (overrides = {}) => { | |
Cypress.log({ | |
name: 'loginViaAuth0', | |
}); | |
const options = { | |
method: 'POST', | |
url: Cypress.env('auth_url'), | |
body: { | |
grant_type: 'password', |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "PublicReadGetObject", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::bucket-name-here/*" | |
} |
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 myObject = { | |
a: 1, | |
b: 2, | |
c: 3 | |
}; | |
const { a, ...noA } = myObject; | |
console.log(noA); // => { b: 2, c: 3 } |
OlderNewer