lebalz Knowledge Base

website·Indexed 31 days ago

https://lebalz.ch

A personal collection of technical synopses, blog posts, and guides covering Dokku server setup, Unix/Windows troubleshooting, Python, MicroPython, PostgreSQL, and OpenSCAD, alongside a personal recipe collection.

Tokens
21K
Snippets
136
Records
141
Agent score
58%

What's inside lebalz

  1. Use DB-SQL for online database querying

    DB-SQL is an online DBMS that allows users to query hosted databases (including PostgreSQL and MySQL) without requiring local installations or worrying about closed network ports, making it suitable for restricted environments like schools or companies.
  2. Disable Bing search in the Windows Search bar

    To disable Bing search results from appearing in the Windows Search bar, create a specific DWORD value in the Windows Registry. This requires a system restart to take effect.
    1. Press Win+R and type `regedit` to open the registry editor.
    2. Navigate to: `Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search`
    3. Right-click Search and select New > DWORD (32-bit) Value.
    4. Name the value `BingSearchEnabled`.
    5. Set the data for `BingSearchEnabled` to 0.
    6. Restart the PC.
  3. Secure Drone CI with Let's Encrypt on Dokku

    To enable HTTPS for your Drone CI instance via Let's Encrypt on Dokku, set your contact email and run the letsencrypt plugin.
    # Set email for Let's Encrypt (no-restart to avoid unnecessary downtime)
    dokku config:set --no-restart drone-server DOKKU_LETSENCRYPT_EMAIL=foo@bar.ch
    
    # Enable Let's Encrypt
    dokku letsencrypt drone-server
  4. Disable and remove Linux swap space

    To remove a swap file, deactivate the swap space, remove the corresponding entry from /etc/fstab, and delete the physical file.
    # Deactivate swap
    sudo swapoff -v /swapfile
    
    # Remove the file
    sudo rm /swapfile
    
    # Note: Manually remove '/swapfile swap swap defaults 0 0' from /etc/fstab
  5. Add a new field to existing sidebar_custom_props in Docusaurus frontmatter

    Use VS Code's regular expression Search & Replace to inject a new key-value pair (e.g., foo: bar) into an existing sidebar_custom_props block within the frontmatter of multiple files.

    Search Pattern:

    ---
    ((.*\r?\n)+?)?sidebar_custom_props:
    (  .+\r?\n)+?((.*\r?\n)+?)?---

    Replace Pattern:

    ---
    $1sidebar_custom_props:
    $3  foo: bar
    $4---
  6. Install Rust using rustup

    The recommended way to install Rust is via rustup. Use the following curl command to download and run the installation script on Unix-like systems.
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  7. Deploy GitLab EE on Dokku

    Deploy GitLab EE using Dokku by creating the app, configuring domains, ports, and persistent storage. It is critical to set the GITLAB_OMNIBUS_CONFIG to use HTTP for the internal listener since GitLab runs behind the Dokku Nginx reverse proxy.
    # Create app and domain
    dokku apps:create sdg-gitlab
    dokku domains:add sdg-gitlab gitlab.domain.ch
    dokku ports:add sdg-gitlab http:80:80
    
    # Optional: Open SSH port via docker-options
    dokku docker-options:add sdg-gitlab deploy -p 2222:22
    
    # Setup persistent storage with root permissions
    dokku storage:ensure-directory --chown root sdg-gitlab
    
    mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/config
    chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/config
    dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/config:/etc/gitlab
    
    mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/logs
    chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/logs
    dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/logs:/var/log/gitlab
    
    mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/data
    chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/data
    dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/data:/var/opt/gitlab
    
    # Configure environment (Use http for internal nginx listener)
    dokku config:set sdg-gitlab GITLAB_OMNIBUS_CONFIG="external_url 'https://gitlab.domain.ch'; nginx['listen_port'] = 80; nginx['listen_https'] = false;"
    
    # Assign GitLab EE image
    dokku git:from-image sdg-gitlab gitlab/gitlab-ee:18.10.0-ee.0
    
    # Optional: Enable Let's Encrypt
    dokku letsencrypt:enable sdg-gitlab
  8. Deploy JupyterHub on Dokku

    To deploy a dockerized JupyterHub instance on Dokku, you must configure the application, set up networking for container spawning, and link a PostgreSQL database. Key requirements include mounting the Docker socket to allow JupyterHub to spawn new containers and configuring the proxy port map to route traffic to the hub.
    APP="jupyterhub"
    DOMAIN="your.domain.com"
    
    # Create app and set scheduler
    dokku apps:create $APP
    dokku scheduler:set $APP selected docker-local
    
    # Configure port mapping (Host 80 -> Container 8000)
    dokku config:set $APP DOKKU_PROXY_PORT_MAP="http:80:8000"
    
    # Mount docker socket for spawning containers
    dokku storage:mount $APP /var/run/docker.sock:/var/run/docker.sock
    
    # Domain and Network setup
    dokku domains:add $APP $DOMAIN
    dokku network:create $APP
    dokku network:set $APP bind-all-interfaces true
    dokku network:set $APP attach-post-create $APP
    
    # Network environment variables
    dokku config:set $APP DOCKER_NETWORK_NAME=$APP
    dokku config:set $APP HUB_IP=$APP.web
    
    # Database setup (PostgreSQL)
    dokku postgres:create $APP
    dokku postgres:link $APP $APP
    
    # Fix DATABASE_URL for SQLAlchemy (change postgres:// to postgresql://)
    DB_URL=$(dokku config:get $APP DATABASE_URL)
    dokku config:set --no-restart $APP DATABASE_URL="${DB_URL//postgres:\/\//postgresql:\//}"
  9. Configure MySQL 8+ authentication for standard clients

    To ensure compatibility with standard MySQL clients (such as Sqlectron) that may not support the default MySQL 8 authentication plugin, change the authentication method to mysql_native_password for the target users.
    alter user 'root'@'localhost' identified with mysql_native_password by 'plaintext-pw';
    alter user 'root'@'%' identified with mysql_native_password by 'plaintext-pw';
    alter user 'mysql'@'%' identified with mysql_native_password by 'plaintext-pw';
  10. Install Node.js and Yarn on Ubuntu/Debian without nvm

    To perform a quick installation of Node.js (version 16.x) and the Yarn package manager on a Debian-based system without using a version manager, update the package list, install curl, add the NodeSource repository, and install nodejs and yarn globally.
    sudo apt update
    sudo apt upgrade
    sudo apt install -y curl
    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    sudo apt install -y nodejs
    
    sudo npm install --global yarn