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/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/git/generae_overview_mermaid.sh b/git/generae_overview_mermaid.sh new file mode 100644 index 0000000..7b88d18 --- /dev/null +++ b/git/generae_overview_mermaid.sh @@ -0,0 +1,92 @@ +#!/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" + +# Set master as the main branch +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") + +# 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 merge-base --fork-point "$branch" "$main_branch" || echo "$main_branch") + 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 ! is_branch_declared "$branch"; then + echo " branch $(escape_for_mermaid "$branch")" + declared_branches+=("$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")\"" + process_merged_branches "$branch" +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\" - 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" \ 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..b5fda81 --- /dev/null +++ b/git/git combine multiple commits.md @@ -0,0 +1,84 @@ + +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 + + +# search for 'App_Code' in commit msgs +git log --all --grep="App_Code" + +# push to new remote branch (if not existing) + git push -u origin main \ No newline at end of file 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/docker install.md b/linux/docker install.md index 98765c1..19b9101 100644 --- a/linux/docker install.md +++ b/linux/docker install.md @@ -1,5 +1,7 @@ # install sudo apt-get update +sudo apt update +sudo apt install gnupg sudo apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" @@ -9,6 +11,11 @@ sudo apt-get install docker-ce # add portainer 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/storage/docker_volumes/portainer_data:/data portainer/portainer-ce +# change portainer admin password +docker stop portainer +docker pull portainer/helper-reset-password +docker run --rm -v /mnt/storage/docker_volumes/portainer_data:/data portainer/helper-reset-password + # start sudo systemctl start docker @@ -17,3 +24,11 @@ sudo systemctl enable docker # build image 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/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 + diff --git a/linux/linux_network.sh b/linux/linux_network.sh index 7c5d555..efc4e76 100644 --- a/linux/linux_network.sh +++ b/linux/linux_network.sh @@ -3,3 +3,11 @@ sudo systemctl stop systemd-resolved sudo systemctl disable systemd-resolved sudo systemctl enable systemd-resolved sudo systemctl start systemd-resolved + + + +# show all interfaces except docker +ifconfig | awk '/^(br-|veth)/ {flag=1; next} /^$/ {flag=0} !flag' + + + diff --git a/linux/setup aider.md b/linux/setup aider.md index bf3dbb6..f4c3c48 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,16 +16,47 @@ 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 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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 +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 +# #################################################### # +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/ + + + # models: https://aider.chat/docs/leaderboards/ diff --git a/linux/setup forticlient.sh b/linux/setup forticlient.sh index 6e2b526..c2fe637 100644 --- a/linux/setup forticlient.sh +++ b/linux/setup forticlient.sh @@ -1,6 +1,30 @@ #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 +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. +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 diff --git a/python/appveyor.mmd b/python/appveyor.mmd new file mode 100644 index 0000000..dcbdd43 --- /dev/null +++ b/python/appveyor.mmd @@ -0,0 +1,76 @@ +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 + + + +%% 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 new file mode 100644 index 0000000..8eddfbd --- /dev/null +++ b/python/deployments_graph.py @@ -0,0 +1,104 @@ +import yaml +import re + +# 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 = [] +inactive_configs = {} + +# 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 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): + 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: + 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] +""" + +# Add branches to the graph +for branch in branches.keys(): + 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 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: + 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: + 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 +""" + +# Output the graph +print(mermaid_graph) 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() 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