From dc2af0386d0d306d0c9bda593ffac9d4444d24d3 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Mon, 8 Apr 2024 12:36:16 +0300 Subject: [PATCH 01/17] local changes DEV --- NOTES/useful commands.md | 1 + _CONFIGS/home router config.md | 30 +++++++++++ _ideas/project ideas.md | 3 ++ ai-ollama.md | 2 + dev/docker deploy.md | 11 ++++ dev/node react.md | 54 +++++++++++++++++++ git/git combine multiple commits.md | 80 +++++++++++++++++++++++++++++ linux/disk fscheck.md | 10 ++++ linux/setup aider.md | 2 +- python/population_plot.py | 39 ++++++++++++++ 10 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 NOTES/useful commands.md create mode 100644 _CONFIGS/home router config.md create mode 100644 _ideas/project ideas.md create mode 100644 ai-ollama.md create mode 100644 dev/docker deploy.md create mode 100644 dev/node react.md create mode 100644 git/git combine multiple commits.md create mode 100644 linux/disk fscheck.md create mode 100644 python/population_plot.py diff --git a/NOTES/useful commands.md b/NOTES/useful commands.md new file mode 100644 index 0000000..17c3908 --- /dev/null +++ b/NOTES/useful commands.md @@ -0,0 +1 @@ +docker init \ No newline at end of file diff --git a/_CONFIGS/home router config.md b/_CONFIGS/home router config.md new file mode 100644 index 0000000..ab9b763 --- /dev/null +++ b/_CONFIGS/home router config.md @@ -0,0 +1,30 @@ +192.168.0.1 + popov %TGBnhy6= WPA2 AES + popov5G %TGBnhy6= auto auto + popov-guest wpa-psk aes 12345678 + -TP-Archer C6 Zelenakravapasetrev@ (original PIN:35390466, MAC: D8-07-B6-17-03-AE) + https://94.156.137.3:8444 + http://94.156.137.3:1024 +WAN: 192.168.100.3 DNS 20.101.62.76/1.1.1.3 +DHCP: 92.168.0.100-249 DNS 192.168.0.10/20.101.62.76 +RESERVATIONS: +C4-65-16-9A-E4-CD +192.168.0.11 +E8-65-D4-33-06-D0 +192.168.0.4 +10-FE-ED-B7-3E-D1 +192.168.0.3 +34-64-A9-D1-84-75 +192.168.0.10 +68-5D-43-A8-07-46 +192.168.0.20 +2C-56-DC-F0-14-80 +192.168.0.9 +B4-2E-99-3A-99-CB +192.168.0.2 +60-6D-C7-5E-63-29 +192.168.0.15 +30-85-A9-23-1D-F6 +192.168.0.13 +A4-CF-12-F5-22-8D +192.168.0.18 \ No newline at end of file diff --git a/_ideas/project ideas.md b/_ideas/project ideas.md new file mode 100644 index 0000000..686b6e1 --- /dev/null +++ b/_ideas/project ideas.md @@ -0,0 +1,3 @@ +AI: + +petals private farm aider - self improving assistant jw documents vector database embedding \ No newline at end of file diff --git a/ai-ollama.md b/ai-ollama.md new file mode 100644 index 0000000..223fb75 --- /dev/null +++ b/ai-ollama.md @@ -0,0 +1,2 @@ +run llama code 7b in ollama" +ollama run codellama:7b-code \ No newline at end of file diff --git a/dev/docker deploy.md b/dev/docker deploy.md new file mode 100644 index 0000000..ed37045 --- /dev/null +++ b/dev/docker deploy.md @@ -0,0 +1,11 @@ +# Step 1: Build the Docker Image +docker build -t my-next-app . +# Step 2: Save the Docker Image +docker save my-next-app > my-next-app.tar +# Step 3: Transfer the Image to the Production Server +scp my-next-app.tar user@your-server-ip:/path/to/directory +# Step 4: Load the Image on the Production Server +ssh user@your-server-ip +docker load < my-next-app.tar +# Step 5: Run the Docker Container +docker run -d -p 80:3000 my-next-app \ No newline at end of file diff --git a/dev/node react.md b/dev/node react.md new file mode 100644 index 0000000..0c7c994 --- /dev/null +++ b/dev/node react.md @@ -0,0 +1,54 @@ +copy + +# npm remove excessive package dependencies +# 1.Use Dependency Analysis Tools +npm install -g depcheck +depcheck +# or +npm install -g npm-check +npm-check + +# 2.Bundle Size Analysis: +npm install --save-dev webpack-bundle-analyzer +# edit webpack to push BundleAnalyzerPlugin to config.plugins +# run #> ANALYZE=true npm run build + +npm uninstall yargs-parser + +yargs-parser +Unused dependencies +* @date-io/date-fns +* @mui/icons-material +* @react-pdf/renderer +* docx +* docx-templates +* docxtemplater +* excel4node +* fs +* gapi +* gapi-script +* html-to-docx +* module-alias +* node-excel-export +* nodemailer-smtp-transport +* prisma-binding +* react-cookies +* react-file-reader +* react-hook-form +* react-router-dom +* react-table +* sqlite3 +* xml-js +Unused devDependencies +* @types/react-table +* autoprefixer +* postcss +* typescript +Missing dependencies +* @fullcalendar/core: ./styles/calendar.scss +* @fullcalendar/daygrid: ./styles/calendar.scss +* @fullcalendar/timegrid: ./styles/calendar.scss +* google-auth-library: ./src/helpers/calendar.js +* open: ./src/helpers/calendar.js +* pages: ./pages/dash.tsx +* src: ./pages/cart/publishers/import.tsx \ No newline at end of file diff --git a/git/git combine multiple commits.md b/git/git combine multiple commits.md new file mode 100644 index 0000000..66cbffc --- /dev/null +++ b/git/git combine multiple commits.md @@ -0,0 +1,80 @@ + +git checkout -b review-branch + + +oldest_commit_hash=$(git log --grep="GAT-4861" --reverse --format="%H" | head -1) +git checkout -b review-branch $oldest_commit_hash^ + + +$oldestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 +git checkout -b review-branch $oldestCommitHash^ + + + +git log --grep="GAT-4861" --format="%H" | xargs -L1 git cherry-pick + +git log --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ } + +git log --grep="GAT-4861" --format="%H" | ForEach-Object { + git cherry-pick $_ --strategy-option theirs +} +git log --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { + git cherry-pick $_ --strategy-option theirs +} + +git log master --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { + git cherry-pick $_ --strategy-option theirs --no-commit + if ($LASTEXITCODE -ne 0) { + Write-Host "Conflict encountered. Skipping commit $_" + git reset --merge + } +} + + +git checkout master # Replace 'main' with your default branch name if different +git branch -D review-branch + + + + +git checkout master # Replace 'main' with your default branch name if different +git branch -D review-branch + +$oldestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 +git checkout -b review-branch $oldestCommitHash^ + +git log master --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { + git cherry-pick $_ --strategy-option theirs --no-commit + if ($LASTEXITCODE -ne 0) { + Write-Host "Conflict encountered. Skipping commit $_" + git reset --merge + } +} + + + + +git diff $(git log --grep="GAT-4861" --format="%H" | tail -n 1)^ $(git log --grep="GAT-4861" --format="%H" | head -n 1) > changes.patch + + +$firstCommit = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 +$lastCommit = git log --grep="GAT-4861" --format="%H" | Select-Object -First 1 +git diff $firstCommit^ $lastCommit > changes.patch + + + + +# Checkout to the parent of the earliest "GAT-4861" commit +$earliestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 +git checkout -b review-branch $earliestCommitHash^ + +# Apply the patch +git apply changes.patch + + + diff --git a/linux/disk fscheck.md b/linux/disk fscheck.md new file mode 100644 index 0000000..9737928 --- /dev/null +++ b/linux/disk fscheck.md @@ -0,0 +1,10 @@ +sudo umount /mnt/mmc + +sudo fsck.vfat -a /dev/sdX1 +sudo fsck.ext4 -cDfty -C 0 /dev/sdX1 +-a: Automatically repair errors. +-c: Check for bad blocks. +-D: Optimize directories when possible. +-f: Force a check, even if the filesystem appears clean. +-t: Print timing stats (optional). +-C 0: Display progress information. \ No newline at end of file diff --git a/linux/setup aider.md b/linux/setup aider.md index 44aae3b..203f39f 100644 --- a/linux/setup aider.md +++ b/linux/setup aider.md @@ -21,5 +21,5 @@ export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin/ctags export OPENAI_API_KEY=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 aider -3 --no-auto-commits -# dev-bro GPT4 +# !!!!! dev-bro GPT4 export OPENAI_API_KEY=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 \ No newline at end of file diff --git a/python/population_plot.py b/python/population_plot.py new file mode 100644 index 0000000..c101633 --- /dev/null +++ b/python/population_plot.py @@ -0,0 +1,39 @@ +import matplotlib.pyplot as plt +import numpy as np + +# Initial population at year 0 +initial_population = 1_000_000 +death_rate = 0.10 + +# Start and stop years for the graph +start_year = 4000 +stop_year = 10000 +interval = 500 # Interval for plotting data points + +# Initialize population calculations +current_population = initial_population +population_values = [initial_population] # Include initial population as the first data point +years = np.arange(0, stop_year + 1, 100) # Calculate every 100 years + +# Apply the death rate for each 100-year period +for year in years[1:]: + current_population -= death_rate * current_population + population_values.append(current_population) + +# Filter the years and population values for the graph +graph_years = np.arange(start_year, stop_year + 1, interval) +graph_population_values = [population for year, population in zip(years, population_values) if year >= start_year and year in graph_years] + +# Create the graph with labels for each data point +plt.figure(figsize=(8, 6)) +plt.plot(graph_years, graph_population_values, marker='o', linestyle='-', color='b') +plt.xlabel('Years') +plt.ylabel('Population') +plt.title(f'Population Projection from Year {start_year} to {stop_year}') + +# Adding labels to the data points +for i, txt in enumerate(graph_population_values): + plt.annotate(f"{int(txt):,}", (graph_years[i], graph_population_values[i]), textcoords="offset points", xytext=(0,10), ha='center') + +plt.grid(True) +plt.show() From 70938c3b15fc9a736d9c17bf5ea0842e450a0b61 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 9 Apr 2024 18:45:48 +0300 Subject: [PATCH 02/17] dvbern forticlient setup + vscode --- linux/setup forticlient.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/linux/setup forticlient.sh b/linux/setup forticlient.sh index 6e2b526..80fe0bb 100644 --- a/linux/setup forticlient.sh +++ b/linux/setup forticlient.sh @@ -1,6 +1,17 @@ #wget https://links.fortinet.com/forticlient/deb/vpnagent #wget https://filestore.fortinet.com/forticlient/forticlient_vpn_7.0.7.0246_amd64.deb apt update -sudo su -apt install openfortivpn -openfortivpn vpn.gateway.one:10443 -u 'Dobromir Popov' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +apt install -y openfortivpn ppp +openfortivpn vpn.gateway.one:10443 -u 'dobromir.popov@gateway.one' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 + + +#ERROR: pppd: The kernel does not support PPP, for example, the PPP kernel driver is not included or cannot be loaded. +docker run --cap-add=NET_ADMIN your_image + privileged: true + cap_add: + - NET_ADMIN + +# useradd popov +# passwd popov +# usermod -aG sudo popov +code --no-sandbox --user-data-dir /home/popov/.config/Code \ No newline at end of file From ab2cbb73e41b1f62d0f1be0c88faebe3ed7b5b93 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 10 Apr 2024 00:05:44 +0300 Subject: [PATCH 03/17] instructions to isntall mono on linux for ASP.net 4.8 apps --- linux/install mono for .net4.8 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 linux/install mono for .net4.8 diff --git a/linux/install mono for .net4.8 b/linux/install mono for .net4.8 new file mode 100644 index 0000000..238029a --- /dev/null +++ b/linux/install mono for .net4.8 @@ -0,0 +1,20 @@ +https://www.mono-project.com/download/stable/#download-lin-ubuntu + +sudo apt install ca-certificates gnupg +sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list +sudo apt update + + +sudo apt install mono-devel + + + + + +dotnet restore /workspace/repos/bitbucket.org/gatewayserver/GatewayServer.sln + +sudo apt-get update +sudo apt-get install nuget +nuget restore /workspace/repos/bitbucket.org/gatewayserver/GatewayServer.sln + From 9fbfc0890eec17c2e9e862f2340f34fd17743869 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 24 Apr 2024 11:57:31 +0300 Subject: [PATCH 04/17] more aider notes --- linux/setup aider.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/linux/setup aider.md b/linux/setup aider.md index 203f39f..61fdb23 100644 --- a/linux/setup aider.md +++ b/linux/setup aider.md @@ -2,6 +2,7 @@ in conda env: pip install aider-chat # latest python -m pip install git+https://github.com/paul-gauthier/aider.git +python -m pip install git+https://github.com/d-popov/aider.git # isntall ctags # > sudo apt update && apt install universal-ctags @@ -15,6 +16,15 @@ brew install universal-ctags /home/linuxbrew/.linuxbrew/bin/ctags export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin/ctags +# KEYS + +export GROQ_API_KEY=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 +export OPENAI_API_BASE=http://ollama.d-popov.com +export AIDER_4=false +export AIDER_35TURBO=false + + + # RUN > aider # personal @@ -22,4 +32,25 @@ export OPENAI_API_KEY=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 aider -3 --no-auto-commits # !!!!! dev-bro GPT4 -export OPENAI_API_KEY=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 \ No newline at end of file +export OPENAI_API_KEY=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 + + + +usage: aider [-h] [--openai-api-key OPENAI_API_KEY] [--anthropic-api-key ANTHROPIC_API_KEY] [--model MODEL] [--models MODEL] [--opus] [--sonnet] [--4] [--4-turbo-vision] [--35turbo] + [--voice-language VOICE_LANGUAGE] [--openai-api-base OPENAI_API_BASE] [--openai-api-type OPENAI_API_TYPE] [--openai-api-version OPENAI_API_VERSION] + [--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID] [--openai-organization-id OPENAI_ORGANIZATION_ID] [--edit-format EDIT_FORMAT] [--weak-model WEAK_MODEL] + [--show-model-warnings | --no-show-model-warnings] [--map-tokens MAP_TOKENS] [--input-history-file INPUT_HISTORY_FILE] [--chat-history-file CHAT_HISTORY_FILE] [--dark-mode] + [--light-mode] [--pretty | --no-pretty] [--stream | --no-stream] [--user-input-color USER_INPUT_COLOR] [--tool-output-color TOOL_OUTPUT_COLOR] + [--tool-error-color TOOL_ERROR_COLOR] [--assistant-output-color ASSISTANT_OUTPUT_COLOR] [--code-theme CODE_THEME] [--show-diffs] [--git | --no-git] + [--gitignore | --no-gitignore] [--aiderignore AIDERIGNORE] [--auto-commits | --no-auto-commits] [--dirty-commits | --no-dirty-commits] [--dry-run | --no-dry-run] [--commit] + [--version] [--check-update] [--skip-check-update] [--apply FILE] [--yes] [-v] [--show-repo-map] [--message COMMAND] [--message-file MESSAGE_FILE] [--encoding ENCODING] + [-c CONFIG_FILE] + [FILE ...] + +### OLLAMA || GROQ +export GROQ_API_KEY=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 +aider --models groq/ +# #################################################### # +aider --model groq/llama3-70b-8192 --no-auto-commits +# OLLAMA? +aider --openai-api-base https://ollama.d-popov.com --models openai/ \ No newline at end of file From 5019e388bf8a76d7dc4bb7ac3ab0a3f7e5dc8d84 Mon Sep 17 00:00:00 2001 From: popov Date: Tue, 18 Jun 2024 17:23:34 +0300 Subject: [PATCH 05/17] add git commit search --- git/git combine multiple commits.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git/git combine multiple commits.md b/git/git combine multiple commits.md index 66cbffc..f2e1ea5 100644 --- a/git/git combine multiple commits.md +++ b/git/git combine multiple commits.md @@ -77,4 +77,5 @@ git checkout -b review-branch $earliestCommitHash^ git apply changes.patch - +# search for 'App_Code' in commit msgs +git log --all --grep="App_Code" From 1ea2f19d1197d2f5aa600da93c8286cd8066df7f Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 12:05:04 +0300 Subject: [PATCH 06/17] generate marmaid graph --- git/generae_overview_mermaid.sh | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 git/generae_overview_mermaid.sh diff --git a/git/generae_overview_mermaid.sh b/git/generae_overview_mermaid.sh new file mode 100644 index 0000000..103f7c3 --- /dev/null +++ b/git/generae_overview_mermaid.sh @@ -0,0 +1,37 @@ +$ #!/bin/bash + +# Function to escape special characters for Mermaid +escape_for_mermaid() { + echo "$1" | sed 's/[^a-zA-Z0-9]/_/g' +} + +# Start the Mermaid diagram +echo "%%{init: { 'theme': 'base' } }%%" +echo "gitGraph" + +# Set master as the main branch +main_branch="master" + +# Start with the main branch +echo " commit id: \"Initial commit\"" + +# Keep track of declared branches +declared_branches=("$main_branch") + +# Function to find the base branch +find_base_branch() { + local branch=$1 + local base=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//') + if [[ -z "$base" ]]; then + echo "$main_branch" + else + echo "$base" + fi +} + +# Function to declare a branch if not already declared +declare_branch() { + local branch=$1 + if [[ ! " ${declared_branches[@]} " =~ " ${branch} " ]]; then + echo " branch $branch" +doneprocess_branch "$branch"--sort=committerdate --format='%(refname:short)' refs/heads/) \ No newline at end of file From 37cdca37195403d72cab7cd03a8913673f52937f Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 12:18:35 +0300 Subject: [PATCH 07/17] mermaid save to file, fix --- git/generae_overview_mermaid.sh | 37 ++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/git/generae_overview_mermaid.sh b/git/generae_overview_mermaid.sh index 103f7c3..a2cbe25 100644 --- a/git/generae_overview_mermaid.sh +++ b/git/generae_overview_mermaid.sh @@ -1,11 +1,15 @@ -$ #!/bin/bash +#!/bin/bash # Function to escape special characters for Mermaid escape_for_mermaid() { echo "$1" | sed 's/[^a-zA-Z0-9]/_/g' } +# Output file +output_file="branches_diagram.mmd" + # Start the Mermaid diagram +{ echo "%%{init: { 'theme': 'base' } }%%" echo "gitGraph" @@ -14,9 +18,12 @@ main_branch="master" # Start with the main branch echo " commit id: \"Initial commit\"" +echo " branch $main_branch" +echo " checkout $main_branch" # Keep track of declared branches -declared_branches=("$main_branch") +declare -A declared_branches +declared_branches[$main_branch]=1 # Function to find the base branch find_base_branch() { @@ -32,6 +39,26 @@ find_base_branch() { # Function to declare a branch if not already declared declare_branch() { local branch=$1 - if [[ ! " ${declared_branches[@]} " =~ " ${branch} " ]]; then - echo " branch $branch" -doneprocess_branch "$branch"--sort=committerdate --format='%(refname:short)' refs/heads/) \ No newline at end of file + if [[ -z "${declared_branches[$branch]}" ]]; then + echo " branch $(escape_for_mermaid "$branch")" + declared_branches[$branch]=1 + fi +} + +# Process each branch +for branch in $(git for-each-ref --sort=committerdate --format='%(refname:short)' refs/heads/); do + base_branch=$(find_base_branch "$branch") + + declare_branch "$branch" + + echo " checkout $(escape_for_mermaid "$branch")" + echo " commit id: \"$(git log -1 --pretty=format:%s "$branch")\"" + + if [ "$branch" != "$main_branch" ]; then + echo " checkout $(escape_for_mermaid "$base_branch")" + echo " merge $(escape_for_mermaid "$branch")" + fi +done +} > $output_file + +echo "Mermaid diagram saved to $output_file" From 7568039e165de3478eff5a8c7b5778345c71dcc3 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 13:10:33 +0300 Subject: [PATCH 08/17] new v --- git/generae_overview_mermaid.sh | 44 ++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/git/generae_overview_mermaid.sh b/git/generae_overview_mermaid.sh index a2cbe25..9d5c0c9 100644 --- a/git/generae_overview_mermaid.sh +++ b/git/generae_overview_mermaid.sh @@ -22,13 +22,23 @@ echo " branch $main_branch" echo " checkout $main_branch" # Keep track of declared branches -declare -A declared_branches -declared_branches[$main_branch]=1 +declared_branches=("$main_branch") + +# Function to check if a branch is declared +is_branch_declared() { + local branch=$1 + for declared_branch in "${declared_branches[@]}"; do + if [[ "$declared_branch" == "$branch" ]]; then + return 0 + fi + done + return 1 +} # Function to find the base branch find_base_branch() { local branch=$1 - local base=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//') + local base=$(git merge-base --fork-point "$branch" "$main_branch" || echo "$main_branch") if [[ -z "$base" ]]; then echo "$main_branch" else @@ -39,9 +49,9 @@ find_base_branch() { # Function to declare a branch if not already declared declare_branch() { local branch=$1 - if [[ -z "${declared_branches[$branch]}" ]]; then + if ! is_branch_declared "$branch"; then echo " branch $(escape_for_mermaid "$branch")" - declared_branches[$branch]=1 + declared_branches+=("$branch") fi } @@ -50,15 +60,31 @@ for branch in $(git for-each-ref --sort=committerdate --format='%(refname:short) base_branch=$(find_base_branch "$branch") declare_branch "$branch" - echo " checkout $(escape_for_mermaid "$branch")" echo " commit id: \"$(git log -1 --pretty=format:%s "$branch")\"" - if [ "$branch" != "$main_branch" ]; then - echo " checkout $(escape_for_mermaid "$base_branch")" - echo " merge $(escape_for_mermaid "$branch")" + # Check which branches are merged into this branch + merged_branches=$(git branch --merged "$branch" | grep -v "\* $branch" | grep -v "$main_branch") + if [ -n "$merged_branches" ]; then + for merged_branch in $merged_branches; do + if [ "$merged_branch" != "$branch" ]; then + declare_branch "$merged_branch" + echo " checkout $(escape_for_mermaid "$branch")" + echo " merge $(escape_for_mermaid "$merged_branch")" + fi + done fi done + +# Check for branches not yet merged into master +not_merged=$(git branch --no-merged "$main_branch") +if [ -n "$not_merged" ]; then + echo " commit id: \"Branches not yet merged into master:\"" + for branch in $not_merged; do + echo " commit id: \"$branch\"" + done +fi + } > $output_file echo "Mermaid diagram saved to $output_file" From d7672c195901452d265ffae2493717393494a31d Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 14:24:47 +0300 Subject: [PATCH 09/17] fixes. added appbeyor script and diagram (wip) --- git/generae_overview_mermaid.sh | 32 +++++++------ python/appveyor.mmd | 35 ++++++++++++++ python/deployments_graph.py | 85 +++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 15 deletions(-) create mode 100644 python/appveyor.mmd create mode 100644 python/deployments_graph.py diff --git a/git/generae_overview_mermaid.sh b/git/generae_overview_mermaid.sh index 9d5c0c9..7b88d18 100644 --- a/git/generae_overview_mermaid.sh +++ b/git/generae_overview_mermaid.sh @@ -55,25 +55,27 @@ declare_branch() { fi } +# Function to recursively process merged branches +process_merged_branches() { + local branch=$1 + local merged_branches=$(git branch --merged "$branch" | grep -v "\* $branch" | grep -v "$main_branch") + if [ -n "$merged_branches" ]; then + for merged_branch in $merged_branches; do + declare_branch "$merged_branch" + echo " checkout $(escape_for_mermaid "$branch")" + echo " merge $(escape_for_mermaid "$merged_branch")" + process_merged_branches "$merged_branch" + done + fi +} + # Process each branch for branch in $(git for-each-ref --sort=committerdate --format='%(refname:short)' refs/heads/); do base_branch=$(find_base_branch "$branch") - declare_branch "$branch" echo " checkout $(escape_for_mermaid "$branch")" echo " commit id: \"$(git log -1 --pretty=format:%s "$branch")\"" - - # Check which branches are merged into this branch - merged_branches=$(git branch --merged "$branch" | grep -v "\* $branch" | grep -v "$main_branch") - if [ -n "$merged_branches" ]; then - for merged_branch in $merged_branches; do - if [ "$merged_branch" != "$branch" ]; then - declare_branch "$merged_branch" - echo " checkout $(escape_for_mermaid "$branch")" - echo " merge $(escape_for_mermaid "$merged_branch")" - fi - done - fi + process_merged_branches "$branch" done # Check for branches not yet merged into master @@ -81,10 +83,10 @@ not_merged=$(git branch --no-merged "$main_branch") if [ -n "$not_merged" ]; then echo " commit id: \"Branches not yet merged into master:\"" for branch in $not_merged; do - echo " commit id: \"$branch\"" + echo " commit id: \"$branch\" - merged into: $(git branch --merged "$branch" | grep -v "\* $branch" | grep -v "$main_branch" | tr '\n' ' ')" done fi } > $output_file -echo "Mermaid diagram saved to $output_file" +echo "Mermaid diagram saved to $output_file" \ No newline at end of file diff --git a/python/appveyor.mmd b/python/appveyor.mmd new file mode 100644 index 0000000..84ab1a8 --- /dev/null +++ b/python/appveyor.mmd @@ -0,0 +1,35 @@ +graph TD + A[Common Configuration] --> B[master] + A[Common Configuration] --> C[stable] + A[Common Configuration] --> D[deployment] + A[Common Configuration] --> E[GAT-5073] + A[Common Configuration] --> F[GAT-5098] + + B --> B1[Release_ProfessionalTestServer] + B --> B2[Release_TestServer] + B --> B3[Release_DemoServer] + B1 --> G[TESTPRO on master] + B2 --> H[TEST on master] + B3 --> I[DEMO on master] + + C --> C1[Release_DemoServer] + C --> C2[Release_ProfessionalTestServer] + C1 --> J[DEMO on stable] + C2 --> K[TESTPRO on stable] + + D --> D1[Release_ProductionServer] + D --> D2[Release_ProfessionalServer] + D1 --> L[PROD Staging on deployment] + D2 --> M[PRO on deployment] + + E --> E1[Staging_TestServer] + E1 --> N[TEST-Staging on GAT-5073] + + F --> F1[Staging_DemoServer] + F1 --> O[DEMO-Staging on GAT-5098] + + style A fill:#f9f,stroke:#333,stroke-width:2px + + style C1 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 + style C2 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 + diff --git a/python/deployments_graph.py b/python/deployments_graph.py new file mode 100644 index 0000000..7d118c8 --- /dev/null +++ b/python/deployments_graph.py @@ -0,0 +1,85 @@ +import yaml + +# Load the YAML content from the file +with open('appveyor.yml', 'r') as file: + appveyor_yml = file.read() + +# Parsing the YAML content +config = yaml.safe_load(appveyor_yml) + +# Extract branches and configurations from the YAML +branches = {} +deployments = {} +inactive_branches = [] + +# Extract specific branch configurations +if 'for' in config: + for branch_config in config['for']: + branch_names = branch_config.get('branches', {}).get('only', []) + configurations = branch_config.get('configuration', []) + for branch in branch_names: + if branch not in branches: + branches[branch] = [] + branches[branch].extend(configurations) + +# Manually add common branches and configurations if not already included +if 'branches' in config: + common_branches = config['branches'].get('only', []) + for branch in common_branches: + if branch not in branches: + branches[branch] = config.get('configuration', []) + +# Check for inactive branches in the comments +lines = appveyor_yml.splitlines() +for i, line in enumerate(lines): + if line.strip().startswith('#') and i + 2 < len(lines) and 'branches:' in lines[i + 1] and 'only:' in lines[i + 2]: + inactive_branches.append(lines[i + 2].split(':')[1].strip()) + +# Extract deployment configurations +if 'deploy' in config: + deployments['common'] = config['deploy'] + +if 'for' in config: + for branch_config in config['for']: + branch_names = branch_config.get('branches', {}).get('only', []) + if 'deploy' in branch_config: + for branch in branch_names: + if branch not in deployments: + deployments[branch] = [] + deployments[branch].extend(branch_config['deploy']) + +# Generate the Mermaid graph content +mermaid_graph = """ +graph TD + A[Common Configuration] --> B[master] +""" + +# Add branches to the graph +for branch in branches.keys(): + if branch != 'master': + mermaid_graph += f" A --> {branch.replace('-', '_')}\n" + +# Add configurations to the branches +for branch, configs in branches.items(): + for config in configs: + mermaid_graph += f" {branch.replace('-', '_')} --> {branch.replace('-', '_')}{config}\n" + +# Add deployments to the configurations +for branch, deploys in deployments.items(): + for deploy in deploys: + configuration = deploy.get('configuration') + website = deploy.get('website') + if configuration and website: + mermaid_graph += f" {branch.replace('-', '_')}{configuration.replace('_', '')} --> {branch.replace('-', '_')}{website.replace('-', '_')}\n" + +# Highlight inactive branches +for inactive_branch in inactive_branches: + mermaid_graph += f" style {inactive_branch.replace('-', '_')} fill:#f96,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5\n" + +# Add styles to the graph +mermaid_graph += """ + style A fill:#f9f,stroke:#333,stroke-width:2px + style B fill:#bbf,stroke:#333,stroke-width:2px +""" + +print(mermaid_graph) From bb9fa824cc8000769a900d69ea73e80739e4d0b6 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 14:27:05 +0300 Subject: [PATCH 10/17] script improved --- python/deployments_graph.py | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/python/deployments_graph.py b/python/deployments_graph.py index 7d118c8..f6d9e0e 100644 --- a/python/deployments_graph.py +++ b/python/deployments_graph.py @@ -1,4 +1,5 @@ import yaml +import re # Load the YAML content from the file with open('appveyor.yml', 'r') as file: @@ -11,6 +12,7 @@ config = yaml.safe_load(appveyor_yml) branches = {} deployments = {} inactive_branches = [] +inactive_configs = {} # Extract specific branch configurations if 'for' in config: @@ -29,11 +31,13 @@ if 'branches' in config: if branch not in branches: branches[branch] = config.get('configuration', []) -# Check for inactive branches in the comments +# Check for inactive branches and configurations in the comments lines = appveyor_yml.splitlines() for i, line in enumerate(lines): + if re.match(r'#\s*-\s*(\w+)', line): + inactive_configs.setdefault(lines[i-1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_')) if line.strip().startswith('#') and i + 2 < len(lines) and 'branches:' in lines[i + 1] and 'only:' in lines[i + 2]: - inactive_branches.append(lines[i + 2].split(':')[1].strip()) + inactive_branches.append(lines[i + 2].split(':')[1].strip().replace('-', '_')) # Extract deployment configurations if 'deploy' in config: @@ -51,35 +55,41 @@ if 'for' in config: # Generate the Mermaid graph content mermaid_graph = """ graph TD - A[Common Configuration] --> B[master] + A[Common Configuration] """ # Add branches to the graph for branch in branches.keys(): - if branch != 'master': - mermaid_graph += f" A --> {branch.replace('-', '_')}\n" + branch_id = branch.replace('-', '_') + mermaid_graph += f" A --> {branch_id}\n" # Add configurations to the branches for branch, configs in branches.items(): + branch_id = branch.replace('-', '_') + for idx, config in enumerate(configs): + config_id = f"{branch_id}{idx+1}" + mermaid_graph += f" {branch_id} --> {config_id}[{config}]\n" + # Add deployments to the configurations + for deploy in deployments.get(branch, []): + configuration = deploy.get('configuration') + if configuration == config: + service = deploy.get('service', '') + mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('on', {}).get('configuration', '')} on {branch}]\n" + +# Highlight inactive branches and configurations with a dotted style +for branch in inactive_branches: + mermaid_graph += f" style {branch} fill:#f96,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5\n" + +for branch, configs in inactive_configs.items(): + branch_id = branch.replace('-', '_') for config in configs: - mermaid_graph += f" {branch.replace('-', '_')} --> {branch.replace('-', '_')}{config}\n" - -# Add deployments to the configurations -for branch, deploys in deployments.items(): - for deploy in deploys: - configuration = deploy.get('configuration') - website = deploy.get('website') - if configuration and website: - mermaid_graph += f" {branch.replace('-', '_')}{configuration.replace('_', '')} --> {branch.replace('-', '_')}{website.replace('-', '_')}\n" - -# Highlight inactive branches -for inactive_branch in inactive_branches: - mermaid_graph += f" style {inactive_branch.replace('-', '_')} fill:#f96,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5\n" + config_id = f"{branch_id}_{config}" + mermaid_graph += f" style {config_id} fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5\n" # Add styles to the graph mermaid_graph += """ style A fill:#f9f,stroke:#333,stroke-width:2px - style B fill:#bbf,stroke:#333,stroke-width:2px """ +# Output the graph print(mermaid_graph) From e570f0a1b2ca0eed255e18f11685c152fe7b5bea Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 16 Jul 2024 14:27:16 +0300 Subject: [PATCH 11/17] new commands added to wiki --- git/git combine multiple commits.md | 2 ++ linux/setup aider.md | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/git/git combine multiple commits.md b/git/git combine multiple commits.md index 66cbffc..4b4767c 100644 --- a/git/git combine multiple commits.md +++ b/git/git combine multiple commits.md @@ -78,3 +78,5 @@ git apply changes.patch +# push to new remote branch (if not existing) + git push -u origin main \ No newline at end of file diff --git a/linux/setup aider.md b/linux/setup aider.md index 61fdb23..947088e 100644 --- a/linux/setup aider.md +++ b/linux/setup aider.md @@ -48,9 +48,9 @@ usage: aider [-h] [--openai-api-key OPENAI_API_KEY] [--anthropic-api-key ANTHROP [FILE ...] ### OLLAMA || GROQ -export GROQ_API_KEY=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 -aider --models groq/ # #################################################### # -aider --model groq/llama3-70b-8192 --no-auto-commits +aider --models groq/ +export GROQ_API_KEY=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 +aider --model groq/llama3-70b-8192 --no-auto-commits --show-repo-map # OLLAMA? aider --openai-api-base https://ollama.d-popov.com --models openai/ \ No newline at end of file From a2457e8006a73293a6013d77f4a5c7bc061030bd Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Mon, 29 Jul 2024 18:20:51 +0300 Subject: [PATCH 12/17] notes --- dev/sample mermaid.mmd | 31 +++++++++++++++ linux/docker install.md | 4 ++ linux/setup forticlient.sh | 15 +++++++- python/appveyor.mmd | 41 ++++++++++++++++++++ python/deployments_graph.py | 29 +++++++++----- windows/wsl.cmd | 76 +++++++++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 dev/sample mermaid.mmd create mode 100644 windows/wsl.cmd diff --git a/dev/sample mermaid.mmd b/dev/sample mermaid.mmd new file mode 100644 index 0000000..be830ac --- /dev/null +++ b/dev/sample mermaid.mmd @@ -0,0 +1,31 @@ +``` mermaid +graph TD + A[Common Configuration] --> B[master] + A[Common Configuration] --> C[stable] + A[Common Configuration] --> D[deployment] + A[Common Configuration] --> E[GAT-5073] + A[Common Configuration] --> F[GAT-5098] + + B --> B1[Release_ProfessionalTestServer] + B --> B2[Release_TestServer] + B --> B3[Release_DemoServer] + B1 --> G[TESTPRO on master] + B2 --> H[TEST on master] + B3 --> I[DEMO on master] + + C --> C1[Release_DemoServer] + C --> C2[Release_ProfessionalTestServer] + C1 --> J[DEMO on stable] + C2 --> K[TESTPRO on stable] + + D --> D1[Release_ProductionServer] + D --> D2[Release_ProfessionalServer] + D1 --> L[PROD Staging on deployment] + D2 --> M[PRO on deployment] + + E --> E1[Staging_TestServer] + E1 --> N[TEST-Staging on GAT-5073] + + F --> F1[Staging_DemoServer] + F1 --> O[DEMO-Staging on GAT-5098] +``` \ No newline at end of file diff --git a/linux/docker install.md b/linux/docker install.md index cac3c86..19b9101 100644 --- a/linux/docker install.md +++ b/linux/docker install.md @@ -28,3 +28,7 @@ sudo docker build -t your-image-name . # attach to container docker exec -it potainer /bin/sh +# on windows - setup port forwarding +#netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=9000 connectaddress=172.29.111.255 connectport=9000 +netsh interface portproxy add v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport=9000 connectaddress=172.29.104.23 +netsh interface portproxy delete v4tov4 listenaddress=127.0.0.1 listenport=9000 diff --git a/linux/setup forticlient.sh b/linux/setup forticlient.sh index 80fe0bb..c2fe637 100644 --- a/linux/setup forticlient.sh +++ b/linux/setup forticlient.sh @@ -2,7 +2,20 @@ #wget https://filestore.fortinet.com/forticlient/forticlient_vpn_7.0.7.0246_amd64.deb apt update apt install -y openfortivpn ppp -openfortivpn vpn.gateway.one:10443 -u 'dobromir.popov@gateway.one' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +openfortivpn vpn.gateway.one:10443 -u 'dobromir.popov@gateway.one' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +U6n4A7^8^c7dX&p6s + + +or +nano /etc/openfortivpn/config +> +host = vpn.gateway.one +port = 10443 +trusted-cert = bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +pppd-use-peerdns = 1 +set-routes = 1 +username = dobromir.popov@gateway.one +password = U6n4A7^8^c7dX&p6s #ERROR: pppd: The kernel does not support PPP, for example, the PPP kernel driver is not included or cannot be loaded. diff --git a/python/appveyor.mmd b/python/appveyor.mmd index 84ab1a8..dcbdd43 100644 --- a/python/appveyor.mmd +++ b/python/appveyor.mmd @@ -33,3 +33,44 @@ graph TD style C1 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 style C2 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 + + +%% graph TD +%% A[Branches] --> B[master] +%% A --> C[stable] +%% A --> D[deployment] +%% A --> E[GAT-5073] +%% A --> F[GAT-5098] + +%% B --> G[Release_ProfessionalTestServer] +%% B --> H[Release_DemoServer] + +%% C --> I[Release_DemoServer] +%% C --> J[Release_ProfessionalTestServer] + +%% D --> K[Release_ProductionServer] +%% D --> L[Release_ProfessionalServer] + +%% E --> M[Staging_TestServer] + +%% F --> N[Staging_DemoServer] + +%% G --> O[TESTPRO - production] +%% H --> P[DEMO - production] + +%% I --> Q[DEMO - production] +%% J --> R[TESTPRO - production] + +%% K --> S[PROD - staging] +%% L --> T[PRO - production] + +%% M --> U[TEST - staging] + +%% N --> V[DEMO - staging] + +%% style A fill:#f9f,stroke:#333,stroke-width:2px +%% style B fill:#bbf,stroke:#333,stroke-width:2px +%% style C fill:#bbf,stroke:#333,stroke-width:2px +%% style D fill:#bbf,stroke:#333,stroke-width:2px +%% style E fill:#bbf,stroke:#333,stroke-width:2px +%% style F fill:#bbf,stroke:#333,stroke-width:2px \ No newline at end of file diff --git a/python/deployments_graph.py b/python/deployments_graph.py index f6d9e0e..8eddfbd 100644 --- a/python/deployments_graph.py +++ b/python/deployments_graph.py @@ -34,10 +34,15 @@ if 'branches' in config: # Check for inactive branches and configurations in the comments lines = appveyor_yml.splitlines() for i, line in enumerate(lines): + # Check for commented branches if re.match(r'#\s*-\s*(\w+)', line): - inactive_configs.setdefault(lines[i-1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_')) - if line.strip().startswith('#') and i + 2 < len(lines) and 'branches:' in lines[i + 1] and 'only:' in lines[i + 2]: - inactive_branches.append(lines[i + 2].split(':')[1].strip().replace('-', '_')) + branch_name = re.findall(r'#\s*-\s*(\w+)', line)[0] + if 'branches' in lines[i - 1] and 'only:' in lines[i - 2]: + inactive_branches.append(branch_name.replace('-', '_')) + + # Check for commented configurations + if re.match(r'#\s*-\s*(\w+)', line): + inactive_configs.setdefault(lines[i - 1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_')) # Extract deployment configurations if 'deploy' in config: @@ -67,14 +72,18 @@ for branch in branches.keys(): for branch, configs in branches.items(): branch_id = branch.replace('-', '_') for idx, config in enumerate(configs): - config_id = f"{branch_id}{idx+1}" + config_id = f"{branch_id}{idx + 1}" mermaid_graph += f" {branch_id} --> {config_id}[{config}]\n" - # Add deployments to the configurations - for deploy in deployments.get(branch, []): - configuration = deploy.get('configuration') - if configuration == config: - service = deploy.get('service', '') - mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('on', {}).get('configuration', '')} on {branch}]\n" + +# Add deployments to the configurations +for branch, deploys in deployments.items(): + branch_id = branch.replace('-', '_') + for deploy in deploys: + configuration = deploy.get('configuration') + if configuration: + config_id = f"{branch_id}{branches[branch].index(configuration) + 1}" + service_id = deploy.get('website', '').replace('-', '_') + mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('provider', '')} on {branch}]\n" # Highlight inactive branches and configurations with a dotted style for branch in inactive_branches: diff --git a/windows/wsl.cmd b/windows/wsl.cmd new file mode 100644 index 0000000..769cdf8 --- /dev/null +++ b/windows/wsl.cmd @@ -0,0 +1,76 @@ +@REM run image (alpine) as root user + wsl -d Alpine -u root + + +@REM wsl install docker cuda +# Update the package list and install dependencies +sudo apt update +sudo apt install -y ca-certificates curl gnupg lsb-release + +# Add Docker’s official GPG key +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + +# Set up the Docker repository +echo \ +"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ +$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +# Update the package list +sudo apt update + +# Install Docker Engine +sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +# Start Docker +sudo service docker start + +# Enable Docker to start at boot +sudo systemctl enable docker + +# Allow Docker commands without sudo +sudo usermod -aG docker $USER + + +@REM Install WSL-Ubuntu Package for CUDA: + +@REM Follow the instructions to install the CUDA toolkit specifically designed for WSL. Do not install the default CUDA toolkit that includes the drivers. + + +wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin +sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 +wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb +sudo dpkg -i cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb +sudo cp /var/cuda-repo-wsl-ubuntu-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/ +sudo apt-get update +sudo apt-get install cuda +Install NVIDIA Container Toolkit: + +@REM Set up the package repository and install the NVIDIA Container Toolkit: + +distribution=$(. /etc/os-release;echo $ID$VERSION_ID) +curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - +curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list + +sudo apt-get update +sudo apt-get install -y nvidia-docker2 + + +# Create/update Docker daemon configuration +mkdir -p /etc/docker +echo '{ + "runtimes": { + "nvidia": { + "path": "nvidia-container-runtime", + "runtimeArgs": [] + } + } +}' > /etc/docker/daemon.json + + +sudo systemctl restart docker + + +@REM Run a test container to ensure everything is set up correctly: + +sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi \ No newline at end of file From deab2815fe706f8b2a2903a54508758daceffb34 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 31 Jul 2024 09:27:52 +0300 Subject: [PATCH 13/17] more notes --- linux/.setup aider.md.swp | Bin 0 -> 1024 bytes linux/docker commands.md | 7 ++++++ linux/linux disk.md | 27 -------------------- linux/linux disks.md | 39 ++++++++++++++++++++++++++++- linux/setup aider.md | 11 ++++++++- linux/setup android emulator.md | 42 ++++++++++++++++++++++++++++++++ linux/sysyem maintain.md | 0 windows/.net/ef+asp notes.md | 0 8 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 linux/.setup aider.md.swp delete mode 100644 linux/linux disk.md create mode 100644 linux/setup android emulator.md create mode 100644 linux/sysyem maintain.md create mode 100644 windows/.net/ef+asp notes.md diff --git a/linux/.setup aider.md.swp b/linux/.setup aider.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..91ebb4bde5644f98127750e1fd84026f4b47ee39 GIT binary patch literal 1024 zcmYc?$V<%2S1{8vVn6|vQVa} 2fauth docker load -i docker run -d --name + +# cleanup +Remove all unused images/volumes: +docker image prune -a +docker volume prune +# containers, networks, images, and volumes +docker system prune -a --volumes diff --git a/linux/linux disk.md b/linux/linux disk.md deleted file mode 100644 index eaf57db..0000000 --- a/linux/linux disk.md +++ /dev/null @@ -1,27 +0,0 @@ -# disk info -lsblk -sudo fdisk -l -sudo parted -l -gnome-disks - - -sudo umount -f /mnt - - -umount --lazy /mnt/data - - -## ntfs resize: -sudo ntfsfix /dev/sda2 -# Shrink the NTFS Partition: -sudo ntfsresize --size 100G /dev/sda2 (-f) - - -mkdir - - -# folder size: -du -hs - -# find big files -find / -type f -size +100M diff --git a/linux/linux disks.md b/linux/linux disks.md index bf9bc0f..38cd896 100644 --- a/linux/linux disks.md +++ b/linux/linux disks.md @@ -11,6 +11,43 @@ fdisk p # existing partitions # Press n to create a new partition. # press w to write the changes to the disk. sudo mkfs.ext4 /dev/sdXN + # mount -docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always --pull=always -v /var/run/docker.sock:/var/run/docker.sock -v /mnt/apps/docker_volumes/portainer_data:/data portainer/portainer-ce \ No newline at end of file +docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always --pull=always -v /var/run/docker.sock:/var/run/docker.sock -v /mnt/apps/docker_volumes/portainer_data:/data portainer/portainer-ce + +# --------------------- +# disk info +lsblk +sudo fdisk -l +sudo parted -l +gnome-disks + + +sudo umount -f /mnt + + +umount --lazy /mnt/data + + +## ntfs resize: +sudo ntfsfix /dev/sda2 +# Shrink the NTFS Partition: +sudo ntfsresize --size 100G /dev/sda2 (-f) + + +mkdir + + +# folder size: +du -hs + +# find big files +find / -type f -size +100M + + + +# find big files - NCurses Disk Utility - https://dev.yorhel.nl/ncdu +sudo apt-get install ncdu +ncdu +Delete the File: Once you have highlighted the file you want to delete, press the d key. ncdu will prompt you to confirm the deletion. \ No newline at end of file diff --git a/linux/setup aider.md b/linux/setup aider.md index a95e330..bf3dbb6 100644 --- a/linux/setup aider.md +++ b/linux/setup aider.md @@ -21,4 +21,13 @@ export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin/ctags export OPENAI_API_KEY=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 # dev-bro GPT4 -export OPENAI_API_KEY=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 \ No newline at end of file +export OPENAI_API_KEY=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 + + + +# models: +https://aider.chat/docs/leaderboards/ + +aider --model openrouter/meta-llama/llama-3.1-405b-instruct +# https://openrouter.ai/settings/keys +OPENROUTER_API_KEY=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 diff --git a/linux/setup android emulator.md b/linux/setup android emulator.md new file mode 100644 index 0000000..c1abc33 --- /dev/null +++ b/linux/setup android emulator.md @@ -0,0 +1,42 @@ +# https://docs.waydro.id/usage/install-on-desktops +apt update +apt install curl ca-certificates -y +curl https://repo.waydro.id | bash +apt install waydroid -y + + + +ensure we have in yml: +devices: + - "/dev/binder:/dev/binder" + - "/dev/ashmem:/dev/ashmem" +privileged: true + +# +waydroid init +systemctl start waydroid-container +systemctl enable waydroid-container +systemctl status waydroid-container + + + +# +# export WAYLAND_DISPLAY=wayland-0 +# export XDG_RUNTIME_DIR=/run/user/$(id -u) + +useradd -m -s /bin/bash user +passwd user +usermod -aG sudo user +su - user + +export DISPLAY=:1 +export XDG_RUNTIME_DIR=/run/user/$(id -u) + +# Start Waydroid if it is not already running +$waydroid session start + diff --git a/linux/sysyem maintain.md b/linux/sysyem maintain.md new file mode 100644 index 0000000..e69de29 diff --git a/windows/.net/ef+asp notes.md b/windows/.net/ef+asp notes.md new file mode 100644 index 0000000..e69de29 From 9e540fea8c14c7a26c887c37d6acd90fd31a33c6 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 31 Jul 2024 09:35:49 +0300 Subject: [PATCH 14/17] aider updated from 0.7.2 to 0.46.2.dev0 --- linux/setup aider.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/linux/setup aider.md b/linux/setup aider.md index f4c3c48..7764c84 100644 --- a/linux/setup aider.md +++ b/linux/setup aider.md @@ -36,15 +36,16 @@ export OPENAI_API_KEY=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 -usage: aider [-h] [--openai-api-key OPENAI_API_KEY] [--anthropic-api-key ANTHROPIC_API_KEY] [--model MODEL] [--models MODEL] [--opus] [--sonnet] [--4] [--4-turbo-vision] [--35turbo] - [--voice-language VOICE_LANGUAGE] [--openai-api-base OPENAI_API_BASE] [--openai-api-type OPENAI_API_TYPE] [--openai-api-version OPENAI_API_VERSION] - [--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID] [--openai-organization-id OPENAI_ORGANIZATION_ID] [--edit-format EDIT_FORMAT] [--weak-model WEAK_MODEL] - [--show-model-warnings | --no-show-model-warnings] [--map-tokens MAP_TOKENS] [--input-history-file INPUT_HISTORY_FILE] [--chat-history-file CHAT_HISTORY_FILE] [--dark-mode] - [--light-mode] [--pretty | --no-pretty] [--stream | --no-stream] [--user-input-color USER_INPUT_COLOR] [--tool-output-color TOOL_OUTPUT_COLOR] - [--tool-error-color TOOL_ERROR_COLOR] [--assistant-output-color ASSISTANT_OUTPUT_COLOR] [--code-theme CODE_THEME] [--show-diffs] [--git | --no-git] - [--gitignore | --no-gitignore] [--aiderignore AIDERIGNORE] [--auto-commits | --no-auto-commits] [--dirty-commits | --no-dirty-commits] [--dry-run | --no-dry-run] [--commit] - [--version] [--check-update] [--skip-check-update] [--apply FILE] [--yes] [-v] [--show-repo-map] [--message COMMAND] [--message-file MESSAGE_FILE] [--encoding ENCODING] - [-c CONFIG_FILE] +usage: aider [-h] [--file FILE] [--openai-api-key OPENAI_API_KEY] [--anthropic-api-key ANTHROPIC_API_KEY] [--model MODEL] [--opus] [--sonnet] [--4] [--4o] [--4-turbo] [--35turbo] [--models MODEL] [--openai-api-base OPENAI_API_BASE] + [--openai-api-type OPENAI_API_TYPE] [--openai-api-version OPENAI_API_VERSION] [--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID] [--openai-organization-id OPENAI_ORGANIZATION_ID] + [--model-settings-file MODEL_SETTINGS_FILE] [--model-metadata-file MODEL_METADATA_FILE] [--verify-ssl | --no-verify-ssl] [--edit-format EDIT_FORMAT] [--weak-model WEAK_MODEL] + [--show-model-warnings | --no-show-model-warnings] [--map-tokens MAP_TOKENS] [--max-chat-history-tokens MAX_CHAT_HISTORY_TOKENS] [--env-file ENV_FILE] [--input-history-file INPUT_HISTORY_FILE] + [--chat-history-file CHAT_HISTORY_FILE] [--restore-chat-history | --no-restore-chat-history] [--llm-history-file LLM_HISTORY_FILE] [--dark-mode] [--light-mode] [--pretty | --no-pretty] [--stream | --no-stream] + [--user-input-color USER_INPUT_COLOR] [--tool-output-color TOOL_OUTPUT_COLOR] [--tool-error-color TOOL_ERROR_COLOR] [--assistant-output-color ASSISTANT_OUTPUT_COLOR] [--code-theme CODE_THEME] [--show-diffs] + [--git | --no-git] [--gitignore | --no-gitignore] [--aiderignore AIDERIGNORE] [--auto-commits | --no-auto-commits] [--dirty-commits | --no-dirty-commits] [--attribute-author | --no-attribute-author] + [--attribute-committer | --no-attribute-committer] [--attribute-commit-message | --no-attribute-commit-message] [--dry-run | --no-dry-run] [--commit] [--lint] [--lint-cmd LINT_CMD] [--auto-lint | --no-auto-lint] + [--test-cmd TEST_CMD] [--auto-test | --no-auto-test] [--test] [--vim] [--voice-language VOICE_LANGUAGE] [--version] [--just-check-update] [--check-update | --no-check-update] [--apply FILE] [--yes] [-v] [--show-repo-map] + [--show-prompts] [--exit] [--message COMMAND] [--message-file MESSAGE_FILE] [--encoding ENCODING] [-c CONFIG_FILE] [--gui] [FILE ...] ### OLLAMA || GROQ From 68c7edafd2ef7412f4f151435164467b4193fb9a Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Thu, 15 Aug 2024 15:59:40 +0300 Subject: [PATCH 15/17] add containers in scripts project: add HA --- .../homeassistant/configuration.yaml | 62 ++++++++++ .../homeassistant/home.yml | 115 ++++++++++++++++++ .../homeassistant - setup HACS.md | 14 +++ 3 files changed, 191 insertions(+) create mode 100644 portainer-compose-stacks/homeassistant/configuration.yaml create mode 100644 portainer-compose-stacks/homeassistant/home.yml create mode 100644 portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md diff --git a/portainer-compose-stacks/homeassistant/configuration.yaml b/portainer-compose-stacks/homeassistant/configuration.yaml new file mode 100644 index 0000000..26d6907 --- /dev/null +++ b/portainer-compose-stacks/homeassistant/configuration.yaml @@ -0,0 +1,62 @@ +# NOT USED. Check /hassio folder +panel_iframe: + portainer: + title: "Portaiiner" + url: "https://docker.d-popov.com//#!/1/docker/containers" + icon: mdi:docker + require_admin: true + +# Loads default set of integrations. Do not remove. +default_config: + +# Load frontend themes from the themes folder +frontend: + themes: !include_dir_merge_named themes + +# Text to speech +tts: + - platform: google_translate + +http: + use_x_forwarded_for: true + trusted_proxies: + - 192.168.0.10 # Add the IP address of the proxy server + +#almond: +# type: local +# host: http://192.168.0.10:3001 + + +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml + + +homeassistant: + external_url: "https://home.d-popov.com" + packages: !include_dir_named integrations/ + +sensor: + - platform: command_line + name: CPU Temp + command: "cat /sys/class/thermal/thermal_zone0/temp" + unit_of_measurement: "C" + value_template: "{{ value | multiply(0.001) | round(1) }}" + + - platform: command_line + name: GPU Temp + command: "/opt/vc/bin/vcgencmd measure_temp" + unit_of_measurement: "C" + value_template: '{{ value | regex_findall_index("=([0-9]*\.[0-9]*)", 0) }}' + + - platform: command_line + name: CPU Clock + command: "/opt/vc/bin/vcgencmd measure_clock arm" + unit_of_measurement: "MHz" + value_template: '{{ value | regex_findall_index("=([0-9]*)", 0) | multiply(0.000001) | round(0) }}' + +mqtt: + sensor: + state_topic: 'Esp/bedroom/temperature' + name: 'Bedroom Temperature' + unit_of_measurement: 'C' \ No newline at end of file diff --git a/portainer-compose-stacks/homeassistant/home.yml b/portainer-compose-stacks/homeassistant/home.yml new file mode 100644 index 0000000..1d0fe4e --- /dev/null +++ b/portainer-compose-stacks/homeassistant/home.yml @@ -0,0 +1,115 @@ +version: '3.8' +services: + homeassistant: + container_name: homeassistant + image: homeassistant/home-assistant:stable + volumes: + - /mnt/apps/docker_volumes/homeassistant/config:/config + - /etc/localtime:/etc/localtime:ro + - /run/dbus:/run/dbus + - /dev/bus/usb:/dev/bus/usb + - /dev/hci0:/dev/hci0 + privileged: true # Required for full access to host devices + # cap_add: + # - NET_ADMIN + # - SYS_ADMIN + # - SYS_RAWIO + # restart: unless-stopped + network_mode: host + #devices: + # - /dev/ttyACM0:/dev/ttyACM0 + # - /dev/hci0:/dev/hci0 + dind: + deploy: + replicas: 0 + image: docker:dind + container_name: docker_in_docker + privileged: true + environment: + - DOCKER_TLS_CERTDIR=/certs + volumes: + - docker_in_docker_vol:/var/lib/docker + #- /mnt/apps/docker_volumes/dind:/var/lib/docker + - /mnt/apps/docker_volumes/haos:/mnt/haos + - /mnt/apps/DEV/docker-compose/home-infrastructure:/mnt/setup + - /mnt/apps/docker_volumes/dind/certs:/certs + - /mnt/apps/docker_volumes/dind/etc-docker:/etc/docker + #- /sys/fs/cgroup:/sys/fs/cgroup:ro + ports: + - "2376:2376" + - "8122:8123" # hassio HTTP + restart: unless-stopped + tty: true + stdin_open: true + homeassistant_old: + deploy: + replicas: 0 + container_name: homeassistant + image: homeassistant/home-assistant:latest + volumes: + - /mnt/apps/docker_volumes/homeassistant/:/config + environment: + - TZ=YOUR_TIMEZONE + restart: unless-stopped + #network_mode: host + ports: + - "8123:8123" + esphome: + container_name: esphome + image: esphome/esphome:latest + volumes: + - /mnt/apps/docker_volumes/esphome/config:/config # Maps the configuration directory to a local folder + ports: + - "6052:6052" # Optional: for API communication + - "6123:6123" # Optional: for OTA updates + restart: unless-stopped + network_mode: host # Recommended for discovery to work properly + wyoming-piper: + image: rhasspy/wyoming-piper + command: --voice en_US-lessac-medium + volumes: + - /mnt/apps/docker_volumes/ha/piper:/data + ports: + - "10200:10200" + stdin_open: true + tty: true + wyoming-whisper: + image: rhasspy/wyoming-whisper # tiny-int8 base 1GB, small 2GB RAM {tiny,tiny-int8,base,base-int8,small,small-int8,medium,medium-int8} + command: --model small --language en + volumes: + - /path/to/local/data:/data + ports: + - "10300:10300" + stdin_open: true + tty: true + wyoming-whisper-bg: + image: rhasspy/wyoming-whisper # tiny-int8 + command: --model small --language bg + volumes: + - /path/to/local/data:/data + ports: + - "10301:10300" + stdin_open: true + tty: true + openwakeword: + image: dalehumby/openwakeword-rhasspy + restart: always + ports: + - "12202:12202/udp" + volumes: + - /mnt/apps/docker_volumes/ha/openwakeword-rhasspy/config:/config + # openwakeword: + # container_name: openwakeword + # image: homeassistant/amd64-addon-openwakeword + # restart: unless-stopped + # volumes: + # - /mnt/apps/docker_volumes/ha/openwakeword/models:/data/models + # network_mode: host + # environment: + # - TZ=Your/Timezone + # - MODELS_DIR=/data/models + # - CUSTOM_MODEL_DIR=/data/models + # - THRESHOLD=0.5 # Example threshold value + # - TRIGGER_LEVEL=3 # Example trigger level +volumes: + docker_in_docker_vol: diff --git a/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md b/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md new file mode 100644 index 0000000..0211005 --- /dev/null +++ b/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md @@ -0,0 +1,14 @@ +use 'homeassistant/home-assistant:stable' container + +# https://community.home-assistant.io/t/addons-for-docker-installation/436190/42 +enter container shell: +docker exec -it homeassistant bash +wget -O - https://get.hacs.xyz | bash - + + + + + + +custom agent AI +https://community.home-assistant.io/t/custom-integration-ollama-conversation-local-ai-agent/636103/7 \ No newline at end of file From 2596ad0f0edc6dea183eeef8a388578a97daf182 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Thu, 15 Aug 2024 16:00:00 +0300 Subject: [PATCH 16/17] add logging --- portainer-compose-stacks/homeassistant/configuration.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/portainer-compose-stacks/homeassistant/configuration.yaml b/portainer-compose-stacks/homeassistant/configuration.yaml index 26d6907..61d25b5 100644 --- a/portainer-compose-stacks/homeassistant/configuration.yaml +++ b/portainer-compose-stacks/homeassistant/configuration.yaml @@ -59,4 +59,7 @@ mqtt: sensor: state_topic: 'Esp/bedroom/temperature' name: 'Bedroom Temperature' - unit_of_measurement: 'C' \ No newline at end of file + unit_of_measurement: 'C' +logger: + logs: + custom_components.extended_openai_conversation: info \ No newline at end of file From 962a7109e0f3c9c480dd30ee905f1888d3ba068d Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Thu, 15 Aug 2024 16:35:47 +0300 Subject: [PATCH 17/17] more notes --- .../homeassistant/homeassistant - setup HACS.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md b/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md index 0211005..2ab7481 100644 --- a/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md +++ b/portainer-compose-stacks/homeassistant/homeassistant - setup HACS.md @@ -1,6 +1,9 @@ use 'homeassistant/home-assistant:stable' container # https://community.home-assistant.io/t/addons-for-docker-installation/436190/42 +# resource: https://community.home-assistant.io/t/problems-installing-ha-supervisor-on-docker/526234/5 + + enter container shell: docker exec -it homeassistant bash wget -O - https://get.hacs.xyz | bash - @@ -11,4 +14,10 @@ wget -O - https://get.hacs.xyz | bash - custom agent AI -https://community.home-assistant.io/t/custom-integration-ollama-conversation-local-ai-agent/636103/7 \ No newline at end of file +https://community.home-assistant.io/t/custom-integration-ollama-conversation-local-ai-agent/636103/7 + + + +custom functions: +https://community.home-assistant.io/t/custom-component-extended-openai-conversation-lets-control-entities-via-chatgpt/636500 +