Pages - Menu

標籤

AWS (1) bash (1) Boost (2) C (2) CMake (2) Concurrency_Programming (3) CPP (37) Database (2) DNS (1) Docker (4) Docker-Compose (1) ELK (1) emacs (4) gcp (1) gdrive (1) git (1) gitbash (2) gitlab (1) kvm (4) Linux (5) MT4 (4) MT5 (4) Multicast (2) MySQL (2) Nijatrader8 (1) OpenCV (1) Python (4) QT5 (1) R (1) rdp (3) screenshot (1) ssh (3) Tabnine (1) TCP (1) TensorFlow (1) Tools (12) Ubuntu_1904 (11) Ubuntu_20_04 (5) UDP (1) VS2010 (1) VS2015 (1) VS2019 (1) WebServer (1) Win10 (1) winmerge (1) WSL (1) xrdp (1)

搜尋此網誌

2021年12月25日星期六

Multiple Git User

This example is using gitbash on Windows.

Config file locations:

  • C:\Users\<name>\.gitconfig
  • C:\Users\<name>\path_to_github_project\.git\config

# Set up global user
$ git config --global user.name "Your_Name_001"
$ git config --global user.email "Your_Email_001"

# Set up local user and ssh key
$ cd /path_to_your_project
$ git config user.name "Your_Name_002"
$ git config user.email "Your_Email_002"
$ git config --local --add core.sshCommand 'ssh -i ~/.ssh/Your_SSH_Private_Key_002'

Done

2021年12月6日星期一

Install spacemacs on windows

Steps for spacemacs installation

  1. Download and install emacs on windows
    1. https://www.gnu.org/software/emacs/download.html
  2. Install the spacemacs config to appdata
    1.  %USERPROFILE%\appdata\roaming\.emacs.d
    2. https://www.spacemacs.org/#
  git clone https://github.com/syl20bnr/spacemacs C:\%USERPROFILE%\appdata\roaming\.emacs.d  

Steps for gtags and cscope

  1. Get the binaries from web or
    1. from one drive
  2. Put those binaries to a folder in the windows environment path
  3. Use it with the scrip: 
    1. https://github.com/SulfredLee/DailyProblem/blob/master/devTools/prepareSpacemacsTags.bat

2021年12月5日星期日

Cheat sheet compilation

 Bash


# Get space usage
du -chs ./* | sort -rh
du -kh --max-depth=1 | sort -rh

# find files
find [path] -name "lost+found" -prune -o -name "abc*.log.gz" -print0

 Cpp


# cpp debugs
## cpp heap memory checking
sudo cat /proc/18594/maps |grep heap # cat the process memory

55da5171a000-55da5178a000 rw-p 00000000 00:00 0 [heap]
55da5178a000-55db1c7c3000 rw-p 00000000 00:00 0 [heap]

55db1c7c3000-55da5178a000= 3,406,008,320 around 3G mem.

## Then dump the heap memory to a file(example from UAT):
dd if=/proc/29619/mem bs=1 skip=$((0x55db1c7c3000)) count=$((0x55db1c7c3000-0x55da5178a000)) status=none | strings > /tmp/heap_log.txt

 Docker Compose


# up and run in background
docker-compose up -d

# stop --- will keep the data
docker-compose stop

# shutdown --- will remove the data
docker-compose down -v

# check service environment variables
docker-compose run web env

# check config --- this can print the real value of the variable
docker-compose config

2021年11月26日星期五

Packaging Python Project

Reference

https://packaging.python.org/tutorials/packaging-projects/

https://dzone.com/articles/executable-package-pip-install 

https://setuptools.pypa.io/en/latest/userguide/declarative_config.html

Cheat sheet



# Install all needed packages
python -m pip install --upgrade pip setuptools wheel
python -m pip install tqdm
python -m pip install --upgrade twine
python -m pip install --upgrade build

# Prepare the package structure and all needed files

# Build the package
python -m build

# Upload to test
python -m twine upload --repository testpypi dist/*
# Upload to prod
python -m twine upload --repository pypi dist/*

# Install the package by specific the repo
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-pkg-YOUR-USERNAME-HERE

2021年9月5日星期日

2021年3月27日星期六

C++ package manager CMake vcpkg

 How to use vcpkg with CMake

Steps

  • Create C++ project by CCreate
    • CCreate -p TradingPlatform
    • cd TradingPlatform/Projects/TradingPlatform/app
    • CCreate -a ThePlatform
  • Install vcpkg
    • https://docs.microsoft.com/en-us/cpp/build/install-vcpkg?view=msvc-160&tabs=linux
    • git clone https://github.com/microsoft/vcpkg
    • cd ./vcpkg
    • ./bootstrap-vcpkg.sh
  • Install package
    • cd ./vcpkg
    • ./vcpkg search | grep json
    • ./vcpkg install rapidjson
Computing installation plan...
The following packages will be built and installed:
    rapidjson[core]:x64-linux -> 2020-09-14
Detecting compiler hash for triplet x64-linux...
Could not locate cached archive: /home/sulfred/.cache/vcpkg/archives/16/16e324f00567b9fbcd2f106e12e631094b31b5de.zip
Starting package 1/1: rapidjson:x64-linux
Building package rapidjson[core]:x64-linux...
-- Downloading https://github.com/Tencent/rapidjson/archive/ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz -> Tencent-rapidjson-ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz...
-- Extracting source /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/downloads/Tencent-rapidjson-ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz
-- Using source at /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/buildtrees/rapidjson/src/c72ed4364c-35829b36f2.clean
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Installing: /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/packages/rapidjson_x64-linux/share/rapidjson/copyright
-- Installing: /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/packages/rapidjson_x64-linux/share/rapidjson/usage
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: /home/sulfred/.cache/vcpkg/archives/16/16e324f00567b9fbcd2f106e12e631094b31b5de.zip
Building package rapidjson[core]:x64-linux... done
Installing package rapidjson[core]:x64-linux...
Installing package rapidjson[core]:x64-linux... done
Elapsed time for package rapidjson:x64-linux: 1.485 s

Total elapsed time: 1.76 s

The package rapidjson provides CMake integration:

    find_package(RapidJSON CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAPIDJSON_INCLUDE_DIRS})
  • Cmake setting
    • -DCMAKE_TOOLCHAIN_FILE=../Projects/vcpkg/scripts/buildsystems/vcpkg.cmake
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Debug$ cat readme.txt | grep cmake
cmake -G Ninja ../Projects -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../Install -DCMAKE_TOOLCHAIN_FILE=../Projects/vcpkg/scripts/buildsystems/vcpkg.cmake
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Debug$ cd ..
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform$ ll
total 24
drwxrwxr-x 6 sulfred sulfred 4096 Mar 27 20:05 ./
drwxrwxr-x 3 sulfred sulfred 4096 Mar 27 20:10 ../
drwxrwxr-x 4 sulfred sulfred 4096 Mar 27 20:29 Debug/
drwxrwxr-x 3 sulfred sulfred 4096 Mar 27 20:30 Install/
drwxrwxr-x 4 sulfred sulfred 4096 Mar 27 20:30 Projects/
drwxrwxr-x 2 sulfred sulfred 4096 Mar 27 20:05 Release/
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform$ ll Projects/
total 24
drwxrwxr-x  4 sulfred sulfred 4096 Mar 27 20:30 ./
drwxrwxr-x  6 sulfred sulfred 4096 Mar 27 20:05 ../
-rw-rw-r--  1 sulfred sulfred 1025 Mar 27 20:28 CMakeLists.txt
drwxrwxr-x  5 sulfred sulfred 4096 Mar 27 20:30 TradingPlatform/
-rw-rw-r--  1 sulfred sulfred  560 Mar 27 20:05 TradingPlatform.cmake
drwxrwxr-x 14 sulfred sulfred 4096 Mar 27 20:12 vcpkg/
k
    • cat ../Projects/CMakeLists.txt
      • find_package(RapidJSON CONFIG REQUIRED)
      • message(STATUS "Rapid include PATH: " ${RAPIDJSON_INCLUDE_DIRS})