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
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
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
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
ec2_role = stack.add_resource( | |
Role( | |
'WebappInstanceRole', | |
AssumeRolePolicyDocument=Policy( | |
Statement=[Statement( | |
Effect=Allow, | |
Principal=Principal('Service', ['ec2.amazonaws.com']), | |
Action=[AssumeRole] | |
)] | |
), |
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
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
internet_gateway = stack.add_resource( | |
InternetGateway('InternetGateway') | |
) | |
route_table = stack.add_resource(RouteTable( | |
'RouteTable', | |
VpcId=Ref(vpc) | |
)) | |
stack.add_resource(Route( |
NewerOlder