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
/* | |
Pass in two WGS84 points as arrays in x y order to calcuate the | |
meter distance between them. | |
distance([longitude1, latitude1], [longitude2, latitude2]) | |
The distance is calculated with the help of the harvesin formula | |
*/ | |
var distance = function(coords1, coords2) { |
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
function curry(f) { | |
return function curried(...args) { | |
if (args.length >= f.length) { | |
return f.apply(this, args); | |
} else { | |
return function (...args2) { | |
return curried.apply(this, args.concat(args2)); | |
}; | |
} | |
}; |
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
function compose(f, g) { | |
return function (A) { | |
return g(f(A)); | |
} | |
} |
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 appEvents = pubSub(); | |
const appState = state("", appEvents); | |
const input = document.querySelector('.app input'); | |
const paragraph = document.querySelector('.app p'); | |
input.addEventListener('input', (evt) => { | |
appState.setValue(evt.srcElement.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
const appEvents = pubSub(); | |
const appState = state(0, appEvents); | |
function timer() { | |
appState.setValue(appState.getValue() + 1); | |
setTimeout(timer, 1000); | |
} | |
setTimeout(timer, 1000); | |
function updateTimerView(val) { |
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
function pubSub() { | |
const listeners = []; | |
return { | |
dispatch: (event) => listeners.forEach((l) => l(event)), | |
subscribe: (fun) => listeners.push(fun) | |
} | |
} |
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
db_Subnet_group = stack.add_resource(DBSubnetGroup( | |
'DbSubnetGroup', | |
DBSubnetGroupDescription='Subnet group for an internal DB', | |
SubnetIds=[Ref(db_subnet1), Ref(db_subnet2)] | |
)) | |
db_instance = stack.add_resource(DBInstance( | |
'DbInstance', | |
AllocatedStorage=10, | |
DBInstanceClass='db.t2.micro', |
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
app_security_group = stack.add_resource( | |
SecurityGroup( | |
'AppInstanceSecurityGroup', | |
GroupName='AppInstanceSecurityGroup', | |
GroupDescription='Security group for the application instance', | |
SecurityGroupIngress=[{ | |
'FromPort': '8080', | |
'ToPort': '8080', | |
'IpProtocol': 'tcp', | |
'CidrIp': '0.0.0.0/0' |
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
domain_certificate = stack.add_resource( | |
Certificate( | |
'ApiCertificate', | |
DomainName=f'{subdomain}.{domain}' | |
) | |
) | |
elb = stack.add_resource(LoadBalancer( | |
'ELB', | |
LoadBalancerName='ELB', |
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
ec2_role = stack.add_resource( | |
Role( | |
'WebappInstanceRole', | |
AssumeRolePolicyDocument=Policy( | |
Statement=[Statement( | |
Effect=Allow, | |
Principal=Principal('Service', ['ec2.amazonaws.com']), | |
Action=[AssumeRole] | |
)] | |
), |
NewerOlder