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
#!/usr/bin/python3 | |
# Copyright (C) 2020 Stefan Vargyas | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
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
# Option 2 | |
def get_session_alternative(read_only=False): | |
if read_only: | |
SessionLocal = sessionmaker(bind=engine_ro) | |
else: | |
SessionLocal = sessionmaker(bind=engine) | |
session = SessionLocal() | |
try: | |
yield session | |
finally: |
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 sqlalchemy | |
from sqlalchemy.sql import Select, Update, Delete, Insert | |
from sqlalchemy.orm import Session, sessionmaker | |
from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base | |
Base: DeclarativeMeta = declarative_base() | |
# Hack to get around engines need type DeclarativeBase or MappedClass or Table but we are targeting the same Base | |
# and we want to route on a query level | |
ReadBase = Base |
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
RDSDBProxyEndpoint: | |
Type: AWS::RDS::DBProxyEndpoint | |
DependsOn: | |
- RDSDBProxy | |
Properties: | |
DBProxyEndpointName: ReadEndpoint | |
DBProxyName: !Ref RDSDBProxy | |
TargetRole: READ_ONLY | |
VpcSecurityGroupIds: | |
- !Ref YourDBClusterSecurityGroup |
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
RDSDBProxyRole: | |
Type: "AWS::IAM::Role" | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- "rds.amazonaws.com" |
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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "AWS CloudFormation Template to create a static S3 website with CloudFront distribution.", | |
"Parameters" : { | |
"S3BucketName" : { | |
"Type" : "String", | |
"Description" : "The name of your S3 bucket" | |
}, |
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
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<meta charset="utf-8"> | |
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moment@2.27.0/min/moment.min.js"></script> | |
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3"></script> | |
<script type="text/javascript" src="chartjs-plugin-streaming-min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pusher/4.1.0/pusher.js"></script> | |
<script defer type="text/javascript" src="coinbase-minimal.js"></script> | |
</head> |
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
let chart = new Chart(ctx, { | |
type: 'line', | |
data: { | |
datasets: [{ | |
data: [], | |
label: 'Bid', | |
borderColor: 'rgb(0, 255, 0)', | |
backgroundColor: 'rgba(0, 255, 0, 0.5)', | |
fill: false, | |
lineTension: 0 |
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 canvasDiv = document.querySelector('#canvas-div'); | |
let canvas = document.createElement("canvas"); | |
canvasDiv.appendChild(canvas); | |
let ctx = canvas.getContext('2d'); |
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
streamer.onmessage = (message) => { | |
let data = JSON.parse(message.data); | |
if (data['type'] === 'heartbeat') { | |
let time = data.time; | |
console.log('Heartbeat: ' + time); | |
}; |
NewerOlder