hqy.life Documentation and Blog

website·Indexed 31 days ago

https://hqy.life

A personal knowledge base and blog featuring technical notes on C programming (including memory management, type definitions, and const vs define), Termux SSH configuration, SiYuan Note usage, and web development experiences with Docusaurus, CloudFlare, and Algolia.

Tokens
7.6K
Snippets
36
Records
54
Agent score
52%

What's inside hqy.life

  1. Apply for Algolia DocSearch for personal or open-source sites

    Algolia provides a free search service for personal blogs and open-source software documentation. You must apply via the DocSearch portal. Note that the crawler is bound to the specific domain approved during the application; if you change your domain, you must re-apply.
  2. Extend Docusaurus layouts using React

    Docusaurus is powered by React, enabling developers to extend or customize the website layout. You can create custom components or modify the site structure while maintaining the existing header and footer.
  3. Set up SSH remote access in Termux

    To enable SSH access to Termux, install the openssh package, set a password, generate host keys, and start the SSH daemon. Termux uses port 8022 by default. You do not need to specify a username when connecting from a remote machine.
    # On Termux device:
    pkg upgrade
    pkg install openssh
    passwd
    ssh-keygen -A
    sshd
    
    # From remote machine (replace with your device IP):
    ssh 192.168.1.7 -p 8022
  4. Use short-circuit evaluation with && and || operators

    The logical AND (&&) and OR (||) operators provide "short-circuiting" behavior. For &&, if the left-hand operand is false, the right-hand operand is not evaluated. For ||, if the left-hand operand is true, the right-hand operand is not evaluated. This is critical for preventing crashes when checking pointers before dereferencing them.
    // The expression *ptr > 3 is only evaluated if ptr is not NULL
    if (ptr && *ptr > 3) {
        // Do something
    }
  5. Inject Waline comments into Docusaurus Blog and Doc pages

    To add the comment component to the bottom of blog posts and documentation pages, you must 'swizzle' the theme components to make them editable. Use the Eject (Unsafe) option during the swizzle process.
    # For Blog posts
    yarn swizzle @docusaurus/theme-classic BlogPostPage
    
    # For Documentation pages
    yarn swizzle @docusaurus/theme-classic DocItem/Layout
  6. Get started with Docusaurus documentation

    Docusaurus is designed for quick installation and setup. To begin building your website, place your documentation files into the docs directory, allowing the framework to handle the structural 'chores' of the site.
  7. Criteria for selecting a programming font

    When choosing a long-term programming font, consider the following technical requirements to maintain efficiency and readability:

    1. Full Monospace Support: Ensure both English and Chinese characters are monospaced, with Chinese characters exactly twice the width of English characters. This is essential for creating tables or ASCII flowcharts in code comments.
    2. Character Distinction: The font should clearly distinguish between similar characters (e.g., digit 0 vs. uppercase O, digit 1 vs. lowercase l). Some serif elements may be necessary for this distinction without making the overall font look cluttered.
    3. Nerd Font Integration: Support for Nerd Fonts (glyphs/icons) is preferred, though this can be added via patching.
    4. Ligatures: Consider whether you prefer font ligatures for improved code readability.
  8. Install and configure Termux:API

    The Termux:API extension allows Termux to interact with Android system features. It requires installing the Termux:API APK (available via F-Droid or Google Play) and then installing the corresponding command-line tools within Termux.
    pkg install termux-api
  9. Enable local Image OCR in SiYuan Note

    SiYuan Note has a built-in Image OCR feature accessible via the right-click menu (e.g., 'Re-OCR'), but it requires the installation of external software to function. Without the necessary backend software installed, clicking the OCR options will result in no action. Once configured, images pasted directly into the editor are automatically processed for OCR. Note that images inserted via external image bed links may not be supported for OCR; however, adding searchable text to block properties can serve as a workaround for retrieval.
  10. Transfer domain DNS management to Cloudflare

    To move DNS management from Tencent Cloud to Cloudflare:

    1. Log into the Cloudflare dashboard (dash.cloudflare.com).
    2. Click 'Add a Site' and enter the purchased domain.
    3. Select the 'Free Plan'.
    4. Cloudflare will provide two nameservers. Copy these nameservers and update the DNS settings in the Tencent Cloud console.
    5. Wait for the DNS propagation to complete before performing DNS resolution.
  11. Integrate Waline comment system into Docusaurus

    To add Waline comments to a Docusaurus site, you need to install the client library, create a React wrapper component, and inject that component into the blog and documentation layouts using Docusaurus 'swizzle'.
    yarn add @waline/client
  12. Monitor webpage changes using Check 酱 (CheckChan)

    Check 酱 (CheckChan) is an open-source tool used to monitor changes on webpages and send notifications. It is particularly useful for pages that do not require CAPTCHAs.

    Key usage tips:

    • Development Workflow: Use the browser plugin to configure and test the monitoring logic locally before deploying to a cloud Docker server.
    • Handling Dynamic Content: If the webpage uses asynchronous requests to render data, add a few seconds of content capture delay to ensure the data is loaded before the check occurs.
    • Alternative for Media Sites: For tracking media websites, RSSHub combined with an RSS reader is recommended over Check 酱.

    Official Documentation: https://gitee.com/easychen/checkchan-dist