—-
Status:
Tags: [[<%tp.date.now("YYYY-[M]MM")%>]]
Links: [[Weekly Reviews]]
___
# <% tp.file.title %>
[[<%tp.date.now("YYYY-[W]ww", -9)%>]] <== This Week ==> [[<%tp.date.now("YYYY-[W]ww", 2)%>]]
## Days
### SUN
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
resources: | |
Resources: | |
APIGatewayFront: | |
Type: AWS::CloudFront::Distribution | |
Properties: | |
DistributionConfig: | |
Enabled: true | |
IPV6Enabled: true | |
HttpVersion: http2 | |
Comment: CDN in front of API Gateway |
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
// frontend lib module which is injected into the codegen'd hooks | |
import { getAuthToken } from './auth' | |
export const API_URL = process.env.REACT_APP_API_URL! | |
/** | |
* Custom fetcher used by codegen'd hooks to first load auth token, then make the fetch request. | |
*/ | |
export const fetcher = <TData, TVariables>(query: string, variables?: TVariables) => { | |
return async (): Promise<TData> => { |
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
# original script credit: https://github.com/holman/dotfiles | |
autoload colors && colors | |
if (( $+commands[git] )) | |
then | |
git="$commands[git]" | |
else | |
git="/usr/bin/git" | |
fi |
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
// /stacks/cicd-pipelines.ts | |
// CDK app which creates a stack using a set of service definitions | |
import 'source-map-support/register'; | |
import { App } from '@aws-cdk/cdk'; | |
import { ServiceCicdPipelines } from '../lib/cicd/pipelines'; | |
import { deploymentTargetAccounts } from './config'; | |
import services from './services'; | |
const app = new App({ |
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 | |
CLOUDFRONT_DOMAIN="mydomain.com" # change this | |
# Get Distribution ID (requires node.js to be installed) | |
DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[].{Id: Id, DomainName: DomainName, OriginDomainName: Origins.Items[0].DomainName }[?contains(OriginDomainName, '$CLOUDFRONT_DOMAIN')] | [0]" | node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).Id") | |
# Invalidate cache | |
echo "Invalidating CloudFront distribution $DISTRIBUTION_ID ..." | |
aws cloudfront create-invalidation --distribution-id=$DISTRIBUTION_ID --paths '/*' |
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
// Calculates the compound growth of an investment over number of periods. | |
// Assumes fixed regular contributions and average growth rate. | |
function compoundGrowth(startingBalance = 0, periodContribution = 100, periodGrowthRate=0, nPeriods = 1, currencyLabel = '£') { | |
const totalContribution = startingBalance + periodContribution * nPeriods; | |
const finalBalance = [...Array(nPeriods)].reduce((runningBalance) => { | |
return runningBalance + (runningBalance * periodGrowthRate) + periodContribution; | |
}, startingBalance); | |
const absoluteGrowth = finalBalance - totalContribution; | |
const relativeGrowth = absoluteGrowth / totalContribution; | |
console.log(`${currencyLabel}${finalBalance.toFixed(2)} will be returned after ${nPeriods} periods with ${currencyLabel}${periodContribution.toFixed(2)} contributed each period and an average period growth rate of ${periodGrowthRate * 100}% and initial lump sum of ${currencyLabel}${startingBalance}. |
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
function rethrowTest() { | |
Promise.resolve(true).then(function() { | |
return new Promise(function(resolve, reject) { | |
reject(new Error('BOOM!')); | |
}).catch(function(err) { | |
console.error('First catch: ' + err); | |
throw err; | |
}); | |
}).then(function() { | |
console.log('I should not be printed'); |