const posts = [
{ title: 'Post One', body: 'This is post one' },
{ title: 'Post Two', body: 'This is post two' }
]
const getPosts = () => {
setTimeout(() => {
let output = ''- The function after
await someFunc()need to return a promise. Otherwise it will not await and exit from the function. The function below will simply exit and won't wait till the background process is finished. Since async functions are waiting for Promises. The keyword await makes JavaScript wait until that promise settles and returns its result.
const hello4 = () => setTimeout(() => console.log('Hello from Hello4'), 5000)
const asycFunc = async() => {
await hello4()
return
}
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
| // This lambda function will not timeout during a 3sec, since all 3 background processes happening at the same time | |
| const hello1 = () => { | |
| return new Promise(resolve => { | |
| setTimeout(() => resolve(console.log('Hello from Hello1')), 2000) | |
| }) | |
| } | |
| const hello2 = () => { | |
| return new Promise(resolve => { |
$ aws cognito-idp admin-create-user --user-pool-id eu-west-1_Ez3lS4Q8O --username [email protected] --user-attributes file://cognito-create-user.json[
{
"Name": "name",
"Value": "Dimitri"
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
| let isVarAssigned = false | |
| // if isVarAssigned is true, assign the value else assign 'There is no variable assigned' String | |
| const x = isVarAssigned || 'There is no variable assigned' | |
| console.log(x) | |
| // if isVarAssigned is true go and assign the value 'Yes the variable is assigned' if false assign false | |
| const y = isVarAssigned && 'Yes there is a variable assiged' |
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
| sam local invoke SaveContact -e ../../_mocks/lambda-payload-save-contact.json --template ../../../../template.yaml | |
| sam local invoke SaveCompany -e ../../_mocks/lambda-payload-save-company.json --template ../../../../template.yaml | |
| sam local invoke SaveDeal -e ../../_mocks/lambda-payload-save-deal.json --template ../../../../template.yaml | |
| sam local invoke SaveActivity -e ../../_mocks/lambda-payload-save-activity.json --template ../../../../template.yaml | |
| //stdin | |
| echo '{"message": "Hey, are you there?" }' | sam local invoke "Ratings" |
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 | |
| ## README | |
| # To run this script | |
| # => run `sudo bash cloud9-bootstrap.sh` | |
| # Install node 8.10 | |
| nvm install 8.10 | |
| # Set node 8.10 as default | |
| nvm alias default 8.10 |
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
| aws dynamodb batch-write-item --request-items file://Destinations.json |
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
| aws dynamodb create-table --table-name AppSync-Destinations --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 |
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
| 'use strict' | |
| const AWS = require('aws-sdk') | |
| const gm = require('gm').subClass({ imageMagick: true}) | |
| const util = require('util') | |
| const path = require('path') | |
| const parse = require('./parse') | |
| const s3 = new AWS.S3() | |
| // constants | |
| const WEB_WIDTH_MAX = 150 |
NewerOlder