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 / snippet.py
Last active January 16, 2020 04:07
Python snippet
# Occurrence Counter in List
num_lst = [1, 1, 2, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3]
cnt = Counter(num_lst)
print(dict(cnt))
# first 2 most occurrence
print(dict(cnt.most_common(2)))
str_lst = ['blue', 'red', 'green', 'blue', 'red', 'red', 'green']
print(dict(Counter(str_lst)))
@lorne-luo
lorne-luo / tools.txt
Created December 2, 2019 00:25
Online tools
https://requestbin.com/
RequestBin gives you an instant HTTP endpoint that will collect all the requests sent so that you can interpret them easily to check and validate data.
https://cloudcraft.co/
Cloudcraft helps you design and budget your cloud. It has a very cool drag and drop interface to create 3D diagrams, by connecting different cloud infrastructure services (currently only for AWS).
@lorne-luo
lorne-luo / kite.py
Last active June 4, 2021 07:46
Kite Tutorial
# -*- coding: utf-8 -*-
# SHIFT+CMD+A -> Kite: Tutorial
# CMD+P to show function parameter
# Welcome to...
#
# `hmy+. ://:
# .mMMMMMNho:` NMMm
# :NMMMMMMMMMMMds/.` NMMm :ss:
@lorne-luo
lorne-luo / meta.py
Created December 1, 2019 22:43
Python meta example
import time
import types
from functools import wraps
from abc import ABCMeta
def timeit(f):
@wraps(f)
def wrapper(*args, **kwargs):
start = time.time()
resp = f(*args, **kwargs)
@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
@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 / 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 / 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 / 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 / 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]',