Skip to content

Instantly share code, notes, and snippets.

@lijameshao
lijameshao / hackathon_how_to.md
Created September 22, 2018 12:28 — forked from sergmetelin/hackathon_how_to.md
Hackathon Getting Started guide

Important Note before you start

As the EOSIO V1.3 was released this week we strongly do not recommend to use it for the hackathon. Please use EOSIO V1.2.5 to build your applications. To setup your EOSIO Developer Portal for correct version for the event, please click the following link: https://developers.eos.io/eosio-nodeos/v1.2.0/docs/?hackathon It will setup a special cookie in your browser making some modifications to the Developer Portal to make it suitable to work with EOSIO V1.2.5. If you done everything right, you will see an "#eoshackathon" label under the Developer Portal logo: logo.png

About EOSIO

The EOS.IO software introduces a new blockchain architecture designed to enable vertical and horizontal scaling of decentralized applications. This is achieved by creating an operating system-like construct upon which applications can be built. The software prov

@lijameshao
lijameshao / medium-web-dev-subscribe-wss.js
Last active September 30, 2020 05:43
open coinbase websocket and send subscription
let streamer = new WebSocket('wss://ws-feed.pro.coinbase.com');
streamer.onopen = () => {
let subRequest = {
'type': 'subscribe',
'product_ids': [ 'BTC-USD' ],
'channels': [
'heartbeat',
{
'name': 'ticker',
@lijameshao
lijameshao / medium-web-dev-parse-wss-push-to-buf.js
Last active September 30, 2020 05:43
Parse Coinbase websocket messages
streamer.onmessage = (message) => {
let data = JSON.parse(message.data);
if (data['type'] === 'heartbeat') {
let time = data.time;
console.log('Heartbeat: ' + time);
};
const canvasDiv = document.querySelector('#canvas-div');
let canvas = document.createElement("canvas");
canvasDiv.appendChild(canvas);
let ctx = canvas.getContext('2d');
@lijameshao
lijameshao / medium-web-dev-create-chart-with-streaming-plugin.js
Created September 30, 2020 05:49
Create chart with streaming plugin
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
@lijameshao
lijameshao / medium-web-dev-streaming-chart.html
Created September 30, 2020 05:52
HTML for streaming chart
<!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>
{
"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"
},
@lijameshao
lijameshao / rds_db_proxy.yml
Last active January 12, 2022 19:34
CloudFormation example to create a RDS proxy
RDSDBProxyRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- "rds.amazonaws.com"
@lijameshao
lijameshao / rds_proxy_endpoint.yml
Created January 12, 2022 19:38
CloudFormation for rds proxy endpoint
RDSDBProxyEndpoint:
Type: AWS::RDS::DBProxyEndpoint
DependsOn:
- RDSDBProxy
Properties:
DBProxyEndpointName: ReadEndpoint
DBProxyName: !Ref RDSDBProxy
TargetRole: READ_ONLY
VpcSecurityGroupIds:
- !Ref YourDBClusterSecurityGroup
@lijameshao
lijameshao / sqlalchemy_session_routing.py
Last active December 8, 2023 13:26
Route SQLAlchemy session to based on SQL query
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