Zenonux Technical Blog

website·Indexed 29 days ago

https://zenonux.github.io

A collection of technical notes, scenario-based solutions, and configuration guides covering a wide range of technologies including Vue, Vite, NestJS, Ubuntu, Raspberry Pi, Webpack, and various server-side tools like PM2, Seafile, and PostgreSQL.

Tokens
48.7K
Snippets
287
Records
358
Agent score
75%

What's inside Zenonux

  1. Overview of frp for Intranet Penetration

    frp is a Go-based intranet penetration tool used to expose local servers to the internet. This is particularly useful for remote collaboration (letting colleagues access a local development server) or testing webhooks (e.g., WeChat Official Account callbacks) without deploying to a production server. It consists of a server-side component (frps) and a client-side component (frpc). A critical requirement is that both the server and client must use the exact same version to ensure compatibility.
  2. Configure Tsinghua University mirror for Ubuntu 20.04 on Raspberry Pi (ARM)

    When using Ubuntu Mate on a Raspberry Pi (ARM architecture), standard Ubuntu mirrors (like those from Tsinghua or Alibaba) may cause errors because ARM packages are hosted in the ubuntu-ports repository rather than the main ubuntu repository. To resolve this, replace ubuntu with ubuntu-ports in your sources list.
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
  3. Improve SPA SEO using Rendertron dynamic rendering

    For Single Page Applications (SPAs) built with Vue, React, or Angular that suffer from poor SEO, Rendertron provides a dynamic rendering solution. Unlike pre-rendering or Server-Side Rendering (SSR), this approach requires minimal to no changes to the original project. Rendertron intercepts requests from search engine bots, renders the page using Puppeteer, and returns the fully rendered HTML to the bot, while routing regular users directly to the application server.
  4. Install and run frpc on Android via Termux

    You can run the frp client (frpc) on Android without root by using Termux. Download the appropriate binary for your CPU architecture (typically arm64) using wget, then start the client by specifying your configuration file.
    # Start frpc with a specific config file
    frpc -c frpc.ini
  5. Configure Ubuntu mirror sources for Raspberry Pi (ARM)

    When installing or updating Ubuntu (such as Ubuntu Mate) on a Raspberry Pi, using standard x86 Ubuntu mirror URLs (like those from Tsinghua or Alibaba) will cause errors because ARM architecture packages are hosted in the ubuntu-ports repository rather than the main ubuntu repository. To resolve this, replace ubuntu with ubuntu-ports in your sources list.
    # Example: Tsinghua University Mirror for Ubuntu 20.04 (Focal) on ARM/Raspberry Pi
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
  6. Improve SPA SEO using Rendertron

    Single Page Applications (SPAs) built with Vue, React, or Angular often suffer from poor SEO. Rendertron solves this by intercepting requests from search engine bots, rendering the page using Puppeteer, and returning the fully rendered HTML to the crawler. Regular users continue to receive the standard SPA, meaning no changes are required to the original frontend project code.
  7. Implement vertical centering in CSS

    Depending on the layout requirements, use one of these methods to center content vertically:

    • Vertical Align (Pseudo-element): Use a pseudo-element (:after) on the parent with vertical-align: middle and height: 100%, and set the child to display: inline-block with vertical-align: middle.
    • Transform (Dynamic Height): Use position: absolute with top: 50% and transform: translate(0, -50%) (or translate(-50%, 0) for horizontal) to offset the element by its own height.
    • Absolute Positioning (Fixed Height): Set the parent to position: relative, the child to position: absolute with top: 50%, and apply a negative margin-top equal to half of the element's height.
    • Flexbox (Dynamic Height): Set the parent to display: flex and align-items: center.
    /* Vertical Align */
    .parent { height: 200px; }
    .parent:after { display: inline-block; width: 0; height: 100%; vertical-align: middle; content: ''; }
    .parent .child { display: inline-block; vertical-align: middle; }
    
    /* Transform */
    .parent { position: relative; height: 200px; }
    .parent .child { position: absolute; top: 50%; transform: translate(0, -50%); }
    
    /* Absolute Positioning */
    .parent { position: relative; }
    .child { position: absolute; top: 50%; height: 200px; margin-top: -100px; }
    
    /* Flexbox */
    .flex-v-center { display: flex; align-items: center; }
  8. Wake on LAN for Mac using Raspberry Pi and etherwake

    To wake a Mac (such as an iMac) from a sleep state within the same local area network, you can use a Raspberry Pi as a trigger device. This requires the Mac to be powered on (even if sleeping) and supports Wake on LAN (WOL). Note that this process only wakes the computer from sleep; it does not bypass or unlock the system lock screen.
    # Install etherwake on Raspberry Pi
    sudo apt install etherwake
    
    # Wake the Mac using its MAC address
    sudo etherwake 31:6G:11:66:3f:5d
  9. Create a local administrator account for remote access via SSH tunnel

    To maintain security, it is recommended to disable root remote login and instead create a dedicated administrator account restricted to 'localhost'. This account can then be used in conjunction with an SSH tunnel (e.g., via Navicat) for remote management.
    -- Log in to MySQL
    -- sudo mysql
    
    USE mysql;
    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'strongpassword';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
  10. Install the VS Code 'code' shell command via Command Palette

    To add the code command to your system environment variables:

    1. Open Visual Studio Code.
    2. Press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the Command Palette.
    3. Type shell command.
    4. Select the option to install the 'code' command in PATH.
  11. Install and trust Charles SSL certificate on iOS for HTTPS interception

    To intercept HTTPS traffic, the iOS device must trust the Charles root certificate:

    1. On the Computer (Charles): Navigate to Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device or Remote Browser to initiate the process.
    2. On the iOS Device: Open Safari and visit chls.pro/ssl to download and install the certificate.
    3. Enable Full Trust: After installation, go to Settings → General → About → Certificate Trust Settings and enable full trust for the Charles proxy certificate.
  12. Configure custom Webpack for Angular 8 to use PostCSS

    Since Angular 8 does not natively provide a way to modify the Webpack configuration, use the @angular-builders/custom-webpack package to integrate PostCSS for mobile adaptation (e.g., converting px to vw) and other custom loaders.
    npm i @angular-builders/custom-webpack --save-dev