Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.
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
Resources: | |
AccountsRestApi: | |
Type: "AWS::ApiGateway::RestApi" | |
Properties: | |
Name: "AccountsRestApi" | |
FailOnWarnings: "true" | |
AccountsResource: | |
Type: "AWS::ApiGateway::Resource" | |
Properties: | |
ParentId: |
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
'use strict'; | |
const aws = require('aws-sdk'); | |
const s3 = new aws.S3({ apiVersion: '2006-03-01' }); | |
exports.handler = (event, context, callback) => { | |
const key = decodeURIComponent(event.Records[0].s3.object.key); | |
const meta = key.split('/'); |
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 wait = time => new Promise( | |
res => setTimeout(() => res(), time) | |
); | |
wait(200) | |
// onFulfilled() can return a new promise, `x` | |
.then(() => new Promise(res => res('foo'))) | |
// the next promise will assume the state of `x` | |
.then(a => a) | |
// Above we returned the unwrapped value of `x` |
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
# AWS Version 4 signing example | |
# | |
# Example: | |
# Authorization: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7 | |
# Formulae: | |
# CanonicalRequest = | |
# HTTPRequestMethod + '\n' + | |
# CanonicalURI + '\n' + | |
# CanonicalQueryString + '\n' + |
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
" Add this to your vimrc to get a minimalist autocomplete pop | |
" Or use as a plugin : https://github.com/maxboisvert/vim-simple-complete | |
" Minimalist-TabComplete-Plugin | |
inoremap <expr> <Tab> TabComplete() | |
fun! TabComplete() | |
if getline('.')[col('.') - 2] =~ '\K' || pumvisible() | |
return "\<C-P>" | |
else |
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
#!/bin/bash | |
yum install -y aws-cli | |
cd /home/ec2-user/ | |
aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1 | |
yum -y install codedeploy-agent.noarch.rpm |
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
""" | |
Results: | |
multiple_update: 33 ms | |
copy_and_update: 27 ms | |
dict_constructor: 29 ms | |
kwargs_hack: 33 ms | |
dict_comprehension: 33 ms | |
concatenate_items: 81 ms | |
union_items: 81 ms |