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
// Entirely based on answer given in: https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula | |
export default function calculateDistance(position1, position2) { | |
//lon1, lat1, lon2, lat2 | |
const R = 6371; // Radius of the earth in km | |
const dLat = (position2.latitude - position1.latitude).toRad(); | |
const dLon = (position2.longitude - position1.longitude).toRad(); | |
const a = | |
Math.sin(dLat / 2) * Math.sin(dLat / 2) + | |
Math.cos(position1.latitude.toRad()) * |
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
// Based on something I found on the internet, don't remember where | |
export default function renderImagePreviews(files) { | |
for (let i = 0, f; (f = files[i]); i++) { | |
if (!f.type.match('image.*')) { | |
continue; | |
} | |
const reader = new FileReader(); |
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
import React from 'react'; | |
import { StaticRouter } from 'react-router'; | |
import { createStore, Provider } from 'unistore/full/react'; | |
import Routes from 'routes/index'; | |
import persistStore from 'unissist'; | |
import localStorageAdapter from 'unissist/integrations/localStorageAdapter'; | |
// Use let rather than const so we can send props in class constructor | |
let store = createStore({}); | |
const adapter = localStorageAdapter(); |
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
const countries = [ | |
"Afghanistan", | |
"Åland Islands", | |
"Albania", | |
"Algeria", | |
"American Samoa", | |
"Andorra", | |
"Angola", | |
"Anguilla", | |
"Antarctica", |
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
const countriesEurope = [ | |
"Åland Islands", | |
"Albania", | |
"Andorra", | |
"Armenia", | |
"Austria", | |
"Azerbaijan", | |
"Belarus", | |
"Belgium", | |
"Bosnia and Herzegovina", |
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
# From: https://letsencrypt.org/docs/certificates-for-localhost/ | |
openssl req -x509 -out localhost.crt -keyout localhost.key \ | |
-newkey rsa:2048 -nodes -sha256 \ | |
-subj '/CN=localhost' -extensions EXT -config <( \ | |
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") |
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
trigger: | |
- master | |
pool: | |
vmImage: 'ubuntu-latest' | |
variables: | |
- group: Deployment variables | |
steps: |
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
az login | |
az account set -s ${ACCOUNT_NUMBER} | |
az ad sp create-for-rbac --name ${PRINCIPAL_NAME} | |
# Example object returned from create-for-rbac | |
# { | |
# "appId": "16c2b0ae-26a6-494c-9afd-257a8eb7b9a1", | |
# "displayName": "serverless-service-principal", |
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
# Use Visual Studio Code in Google Cloud Shell | |
# As posted at: https://medium.com/google-cloud/how-to-run-visual-studio-code-in-google-cloud-shell-354d125d5748 | |
# Export version variable | |
export VERSION=`curl -s https://api.github.com/repos/cdr/code-server/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'` | |
# Download | |
wget https://github.com/cdr/code-server/releases/download/$VERSION/code-server$VERSION-linux-x64.tar.gz | |
# Unzip |
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
#https://github.com/aws/aws-cli/issues/2279#issuecomment-262616353 | |
export AWS_ACCOUNT_ID='123412341234'; | |
export ROLE='SomeAccessRole'; | |
export CLOUDFRONT_DISTRIBUTION_ID='E123123123123'; | |
export SOME_ROLE='SomeUser'; | |
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" | |
unzip awscli-bundle.zip | |
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws |