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 items = [{ key: 'a', value: 1 }, { key: 'a', value: 2 }, { key: 'b', value: 3 }, { key: 'b', value: 4 }]; | |
const hashMap = items.reduce((acc, current) => { | |
if (!acc[current.key]) acc[current.key] = []; | |
acc[current.key].push(current.value); | |
return acc; | |
}, {}); | |
console.log(hashMap); // { a: [ 1, 2 ], b: [ 3, 4 ] } |
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
name: Deploy | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: |
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 { APIGatewayEvent, Context } from 'aws-lambda'; | |
import { doSomething } from './utils'; | |
export const handler = async (event: APIGatewayEvent, context: Context) => { | |
doSomething(); | |
// Do some other stuff... | |
} |
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
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"target": "ES2017", | |
"lib": ["ES2019"], | |
"rootDir": "src", | |
"outDir": "dist", | |
"declaration": false, | |
"sourceMap": false, | |
"inlineSources": false, |
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 { NodeTracerProvider } = require("@opentelemetry/node"); | |
const provider = new NodeTracerProvider({ | |
plugins: { | |
"aws-sdk": { | |
enabled: true, | |
path: "opentelemetry-plugin-aws-sdk", | |
} | |
} | |
}); |
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
// Make sure to set the right EBS_REGION | |
autoScalingGroup.addUserData('docker plugin install rexray/ebs REXRAY_PREEMPT=true EBS_REGION=eu-west-1 --grant-all-permissions \nstop ecs \nstart ecs'); |
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
//Class | |
class InputWithFocus extends React.Component { | |
constructor() { | |
super(); | |
this.inputRef = null; | |
} | |
render() { | |
return <div> | |
<input ref={inputRef => { this.inputRef = inputRef }} /> | |
<button onClick={() => this.inputRef.focus()}> |
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
//Class | |
componentWillReceiveProps(nextProps) { | |
if (nextProps.count !== this.props.count) { | |
console.log('count changed', nextProps.count); | |
} | |
} | |
//Hooks | |
//Printing 1st iteration: | |
useEffect(() => { |
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 { Ec2TaskDefinition, Scope, ContainerDefinition } from '@aws-cdk/aws-ecs'; | |
// Create TaskDefinition | |
const taskDefinition = new Ec2TaskDefinition(...); | |
// Add EBS volume, this will also create the volume | |
// Look here to understand all the options: | |
// https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html | |
const VOLUME_NAME = 'my-ebs-volume'; | |
taskDefinition.addVolume({ |
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 { Policy, PolicyStatement } from '@aws-cdk/aws-iam'; | |
// Give our EC2 instance the needed permissions to manage EBS | |
const ec2PolicyEbs = new Policy(stack, 'ec2-policy-create-ebs', { | |
policyName: 'REXRay-EBS', | |
statements: [ | |
PolicyStatement.fromJson({ | |
Effect: 'Allow', | |
Action: [ | |
'ec2:AttachVolume', |
NewerOlder