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
{ | |
"Vue component": { | |
"prefix": "vue", | |
"body": [ | |
"<template>", | |
" <div></div>", | |
"</template>", | |
"", | |
"<script>", | |
"export default {", |
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
// collect a haystack | |
const countries = [ | |
'Afghanistan', | |
'Åland Islands', | |
'Albania', | |
'Algeria', | |
'American Samoa', | |
'Andorra', | |
'Angola', | |
'Anguilla', |
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 poop = ['one', 'two', 'three', 'four', 'five'] | |
// I always use `acc` and `item` by default | |
// acc is the thing being accumulated | |
// item is each item in `poop` | |
// basic idea: this will do nothing, | |
// add some console.logs in here and study the behaviour | |
// look at the example below that uses `i` and add it here with console.log | |
const ultraBasic = poop.reduce((acc, item) => { |
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 data = [ | |
{ first: 'David', last: 'Goldstein', age: 92 }, | |
{ first: 'Tom', last: 'Stamper', age: 23 }, | |
{ first: 'Sally', last: 'Brunswick', age: 76 }, | |
{ first: 'Steve', last: 'Henderson', age: 37 }, | |
{ first: 'Mark', last: 'Chopper', age: 75 }, | |
{ first: 'Lucy', last: 'Steel', age: 29 }, | |
] | |
// localeCompare is a String prototype: |
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 showTimeElapsed = (timestamp) => { | |
if (typeof timestamp !== 'number') return 'NaN' | |
const SECOND = 1000 | |
const MINUTE = SECOND * 60 | |
const HOUR = MINUTE * 60 | |
const DAY = HOUR * 24 | |
const MONTH = DAY * 30 | |
const YEAR = MONTH * 12 |
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
// First we are creating or getting some users and placing them in `users` | |
const users = [ | |
{ name: 'Bob' }, | |
{ name: 'Alice' }, | |
] | |
// Then we are creating a config object that we could pass around as needed | |
// Notice we are using shorthand `users` instead of `users: users` | |
const config = { | |
appOwner: 'INSERT_YOUR_NAME', |
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
Show hidden characters
{ | |
"env": { | |
"browser": true, | |
"es6": true, | |
"node": true | |
}, | |
"parserOptions": { | |
"parser": "babel-eslint" | |
}, | |
"extends": [ |
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 axios = require('axios') | |
const followIDs = async (next) => { | |
if (next) { | |
const nextRes = await axios({ | |
method: 'get', | |
url: next, | |
responseType: 'json' | |
}) | |
if (nextRes.data.message) { |
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
{ | |
"env": { | |
"node": true, | |
"browser": true, | |
"es6": true | |
}, | |
"parser": "babel-eslint", | |
"extends": "airbnb", | |
"parserOptions": { | |
"ecmaFeatures": { |
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
// INCLUDING AWAIT DELEGATES TO PARENT | |
const dontBubbleUp = async () => { | |
const samplerPack = async () => { | |
throw new Error('BAD') | |
} | |
try { | |
return await samplerPack() | |
} catch (e) { | |
throw new Error('handling rejection upstream in parent') | |
} |