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 ssm = new AWS.SSM({ region: 'eu-central-1' }); | |
const SOURCE_COOKIE_NAME = 'myapp-origin'; | |
const LATEST_ORIGIN_GIT_HASH = 'myapp_latest-origin-git-hash'; | |
exports.handler = async event => { | |
console.group('[INFO] lambda@edge Origin 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
'use strict'; | |
const SOURCE_HEADER_NAME = 'x-myapp-origin'; | |
exports.handler = async event => { | |
console.group('[INFO] lambda@edge Origin Request') | |
const request = event.Records[0].cf.request; | |
if (request.headers[SOURCE_HEADER_NAME]) { | |
const headerValue = request.headers[SOURCE_HEADER_NAME][0].value; |
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 ssm = new AWS.SSM({ region: 'eu-central-1' }); | |
const SOURCE_COOKIE_NAME = 'myapp-origin'; | |
const LATEST_ORIGIN_GIT_HASH = 'myapp_latest-origin-git-hash'; | |
exports.handler = async (event, context, callback) => { | |
console.group('[INFO] lambda@edge Viewer Request') |
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 { Injectable } from '@angular/core' | |
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router' | |
import { Observable } from 'rxjs' | |
import { distance } from 'fastest-levenshtein' | |
import { paths } from '../paths' | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class Redirect404Guard implements CanActivate { |
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 { distance } = require('fastest-levenshtein') | |
// Approach B - Using distance which gives us more control in conjunction with a MAX_DISTANCE value | |
const routes = { | |
paymentMethods: 'paymentmethods', | |
accountData: 'account-data', | |
profile: 'profile', | |
privacySettings: 'privacy-settings', | |
} |
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 { closest, distance } = require('fastest-levenshtein') | |
// Approach A - Using closest | |
const routes = { | |
paymentMethods: 'paymentmethods', | |
accountData: 'account-data', | |
privacy: 'privacy', | |
privacySettings: 'privacy-settings', | |
} |
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
# Un-gzip them | |
gzip -d -r -S .pbf * | |
# Rename them (this also renames all non-pbf files) | |
find . -type f -exec mv '{}' '{}'.pbf \; | |
# As i said, it renames all files so we have to remove the suffix once more | |
mv metadata.json{.pbf,} |
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
cd data/ | |
sudo apt-get install -y python | |
git clone https://github.com/mapbox/mbutil.git | |
./mbutil/mb-util --image_format=pbf tiles.mbtiles tiles | |
cd ../tiles/ |
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
# Update all package lists and update ubuntu | |
sudo apt-get -y update | |
sudo apt-get -y dist-upgrade | |
# Add the docker repository to make it available via apt-get install and update the package lists again | |
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io |
NewerOlder