Skip to content

Instantly share code, notes, and snippets.

View lorne-luo's full-sized avatar

Lorne Luo lorne-luo

  • Melbourne, Australia
View GitHub Profile
@lorne-luo
lorne-luo / new_database.sql
Last active March 5, 2020 02:12
Postgres initial
create database thor2;
create user thor2 with encrypted password 'thor2';
grant all privileges on database thor2 to thor2;
@lorne-luo
lorne-luo / bash.sh
Last active December 3, 2019 18:15
machine learning inference with AWS Lambda and Layers
pipenv lock -r > requirements.txt
zip -r MyMLfunction_layer1.zip python
aws s3 cp MyMLfunction_layer1.zip s3://mybucket/layers/
# layer 1
aws lambda publish-layer-version --layer-name MyMLfunction_layer1 --content S3Bucket=mybucket,S3Key=layers/MyMLfunction_layer1.zip --compatible-runtimes python3.6
# layer 2
@lorne-luo
lorne-luo / pre-commit.sh
Created July 4, 2019 00:22
Git commit hook for python formatter black
#!/bin/sh
# see black https://github.com/python/black
set -e
if which black >/dev/null; then
REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.py$") || true)
@lorne-luo
lorne-luo / test.py
Created September 1, 2019 22:49
programmatically run unit test
suite = unittest.TestLoader().loadTestsFromTestCase(TestMultiplyBy5Operator)
unittest.TextTestRunner(verbosity=2).run(suite)
@lorne-luo
lorne-luo / django_email_sending.py
Last active October 2, 2019 02:54
reuse connection to send multiple emails in django
from django.core import mail
connection = mail.get_connection()
connection.open()
email1 = mail.EmailMessage(
'That’s your subject',
'That’s your message body',
'[email protected]',
@lorne-luo
lorne-luo / orchestration.md
Last active October 9, 2019 22:37
My Marvel Heroes Orchestration

App re-orchestration for QSForex

Hulk

Abstract layer for Forex Broker integration (already support FXCM and OANDA)

  1. Broker and account
  2. Instrument and constants
  3. Real-time price streaming
  4. History price data
  5. Order & trade execution
  6. Fix protocol trader
@lorne-luo
lorne-luo / quickfix_build.sh
Last active October 4, 2019 06:53
build quickfix
https://stackoverflow.com/questions/56176229/quickfix-how-to-use-ssl-in-python
Yes, quickfix as of the time of writing does not support SSL out of the box. You will need to create a SSL tunnel from your machine manually to the host which requires SSL connectivity. You can do this via 'stunnel'. Posting some configuration below which can hopefully explain how it can be setup.
STUNNEL CONFIG
log = append
output = <path where logs will be written>
[client]
@lorne-luo
lorne-luo / app-orchestration-plan.md
Last active October 6, 2019 22:51
Lorne's Avengers

1. Orchestration for Algorithmic FX trading system

Hulk

Abstract layer for Forex Broker integration (already support FXCM and OANDA)

  1. Broker and account
  2. Instrument and constants
  3. Real-time price streaming
  4. History price data
  5. Order & trade execution
  6. Fix protocol trader (phase 2)
@lorne-luo
lorne-luo / Centos7_firewall.sh
Created October 11, 2019 10:25
Centos7 firewall
# open port
firewall-cmd --zone=public --add-port=55555/tcp --permanent
firewall-cmd --reload
# remove port
$ firewall-cmd --zone=public --remove-port=10050/tcp
$ firewall-cmd --runtime-to-permanent
$ firewall-cmd --reload
@lorne-luo
lorne-luo / s3_presigned.py
Created October 16, 2019 04:21
AWS s3 presigned python
from datetime import datetime
import boto3
import logging
from botocore.exceptions import ClientError
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.utils import timezone