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
export const handler = async (event) => { | |
// TODO implement | |
//#Source https://bit.ly/2neWfJ2 | |
const hz = (fn, iterations = 100) => { | |
const before = performance.now(); | |
for (let i = 0; i < iterations; i++) fn(); | |
return (1000 * iterations) / (performance.now() - before); | |
}; | |
// 10,000 element array | |
const numbers = Array(10000) |
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
export const handler = async (event) => { | |
// TODO implement | |
//#Source https://bit.ly/2neWfJ2 | |
const hz = (fn, iterations = 100) => { | |
const before = performance.now(); | |
for (let i = 0; i < iterations; i++) fn(); | |
return (1000 * iterations) / (performance.now() - before); | |
}; | |
// 10,000 element array | |
const numbers = Array(10000) |
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
// https://gist.github.com/SamWSoftware/b4375a7dcbbd57fc1931b798afc09423 | |
import { promisify } from 'util'; | |
import * as Axios from 'axios'; | |
import * as jsonwebtoken from 'jsonwebtoken'; | |
const jwkToPem = require('jwk-to-pem'); | |
export interface ClaimVerifyRequest { | |
readonly token: string; | |
} |
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 testForOfAsync = async () => { | |
const start = Date.now(); | |
const getFruits = [ | |
new Promise((resolve) => {setTimeout(() => resolve('apple'), 10000)}), | |
new Promise((resolve) => {setTimeout(() => resolve('banana'), 100)}), | |
new Promise((resolve) => {setTimeout(() => resolve('orange'), 100)}) | |
] | |
for await (const fruit of getFruits) { | |
console.log(fruit, Date.now() - start) |
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
let config = { | |
minimumScore: 50, | |
}; | |
exports.handler = async (event) => { | |
const { score, mode } = event; | |
let minimumScore = config.minimumScore | |
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
let cachedData = {}; | |
exports.handler = async (event) => { | |
if (cachedData && cachedData.expiresOn > Date.now() ) { | |
const response = { | |
statusCode: 200, | |
body: `The weather is ${cachedData.weather} and it is ${cachedData.temperature} decrees Celcius`, | |
}; | |
return response; |
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": [ | |
{ | |
"Action": [ | |
"s3:GetObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::{YOUR_S3_BUCKET}/public/*" | |
], |
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 json | |
def lambda_handler(event, context): | |
if event['httpMethod'] == "GET": | |
return getItem(event) | |
if event['httpMethod'] == "POST": | |
return createCart(event) | |
def getItem(event): |
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
functions: { | |
UserLogin: { | |
handler: `src/handler.main`, | |
environment: { | |
USERS_TABLE: { Ref: 'UsersTable' }, | |
}, | |
iamRoleStatements: [ | |
{ | |
Effect: 'Allow', |
NewerOlder