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 / install_openssh_v9.3.sh
Last active May 2, 2024 00:30
How to compile install Openssh-server v9.3
# install dependencies needed to build new openssh
sudo apt-get build-dep openssh openssh-server
# downloaad openssh-server v9.3
wget -c https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p2.tar.gz
tar -xzf openssh-9.3p2.tar.gz
cd openssh-9.3p2/
# compile
./configure --with-md5-passwords --with-pam --with-selinux
@lorne-luo
lorne-luo / java_keystore.sh
Created December 19, 2022 06:02
update java keystore
$JAVA_HOME/bin/keytool -importkeystore -srckeystore /<our_ca_certs>.jks -srcstorepass <pass> -destkeystore $JAVA_HOME/lib/security/cacerts -deststorepass changeit
$JAVA_HOME/lib/security/cacerts
openssl s_client -connect bpaustralia.lei.com:443 -CApath /etc/ssl/certs
sudo cp /etc/nginx/certs/lob2023cer.crt /usr/local/share/ca-certificates
sudo update-ca-certificates --fresh
@lorne-luo
lorne-luo / cleanup.sh
Last active November 2, 2022 06:05
linux cleanup
# To delete downloaded packages
sudo apt-get clean
# To remove all stored archives in your cache for packages
sudo apt-get autoclean
# To remove unnecessary packages
sudo apt-get autoremove
# check kernel version can remove
@lorne-luo
lorne-luo / new_user.sh
Last active December 14, 2023 03:37
setup new user on linux
sudo useradd -m lorneluo --shell /bin/bash
sudo mkdir -p /home/lorneluo/.ssh
sudo touch /home/lorneluo/.ssh/authorized_keys
sudo vi /home/lorneluo/.ssh/authorized_keys
# past ssh key into /home/lorneluo/.ssh/authorized_keys
sudo echo '' >> /home/lorneluo/.ssh/authorized_keys
sudo chmod 644 /home/lorneluo/.ssh
sudo chmod 600 /home/lorneluo/.ssh/authorized_keys
@lorne-luo
lorne-luo / airflow_install.sh
Last active November 25, 2020 08:37
Airflow installation
# https://airflow.apache.org/docs/stable/installation.html
sudo apt-get update
sudo apt-get install -y build-essential mysql-server libmysqlclient-dev libblas-dev libatlas-base-dev
sudo apt-get install -y --no-install-recommends \
freetds-bin \
krb5-user \
ldap-utils \
libffi6 \
libsasl2-2 \
@lorne-luo
lorne-luo / template.yaml
Created October 15, 2020 01:34
SQS Queue as Lambda Trigger in AWS CloudFormation
AWSTemplateFormatVersion : 2010-09-09
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
@lorne-luo
lorne-luo / template_method.py
Created October 7, 2020 23:01
Python template method real case
class BitmexAPI:
# Contructor etc...
def place_order(self, order: Order):
def place_order_api_call():
size_sign = 1 if order.order_side == OrderSide.BUY else -1
result = self.__bitmex_client.Order.Order_new(symbol='XBTUSD',
orderQty=size_sign * order.size,
@lorne-luo
lorne-luo / lambda_pyodbc_layer.sh
Created July 21, 2020 07:14
build pyodbc lambda layer
docker run -it --rm --entrypoint bash -e ODBCINI=/opt/odbc.ini -e ODBCSYSINI=/opt/ -v "$PWD":/opt lambci/lambda:build-python3.8
# install unixODBC
curl ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.7.tar.gz -O
tar xzvf unixODBC-2.3.7.tar.gz
cd unixODBC-2.3.7
./configure --sysconfdir=/opt --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --prefix=/opt
make
make install
cd ..
@lorne-luo
lorne-luo / built-in-funct.md
Created February 27, 2020 23:31
Python Built-in Functions

Built-in Functions

abs()

delattr()

hash()

@lorne-luo
lorne-luo / mouse.py
Created February 11, 2020 22:07
Mouse control on Windows
# controlar o mouse no Windows.
# https://stackoverflow.com/questions/4263608/ctypes-mouse-events
# see http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx for details
import ctypes
import time # opcional
def pos(x, y):
ctypes.windll.user32.SetCursorPos(x, y)