afunny.top Blog

website·Indexed 31 days ago

https://www.afunny.top/

A personal blog by a Shanghai-based frontend developer featuring technical tutorials on React, Node.js, Python, and micro-frontends (qiankun), alongside personal journals on photography, parenting, and travel.

Tokens
18.6K
Snippets
75
Records
124
Agent score
56%

What's inside afunny.top

  1. Overview of Story Relay mini-program features

    The Story Relay mini-program allows users to collaboratively write stories. Key features include:

    • Story Creation: Users create a title and a starting sentence, then share it with friends to continue the narrative.
    • Notifications: Users receive notifications when someone comments on their story, and all participants in a story are notified of new additions.
    • Discovery: A home page allows users to browse, like, and comment on all published stories.
    • User Profile: A personal center displays stories the user has created, liked, or commented on.
  2. Overview of Micro-Frontend Architecture

    Micro-frontend architecture decomposes a monolithic frontend application into multiple independent, flexible small applications. Each micro-app can be developed, run, and deployed independently, then integrated into a single cohesive application. Key characteristics include:

    • Technology Stack Agnostic: The main framework does not restrict the tech stack of the micro-apps.
    • Independent Development and Deployment: Micro-apps have independent repositories and can be updated automatically by the main framework upon deployment.
    • Incremental Upgrades: Allows for progressive refactoring of existing systems without requiring a full-scale rewrite.
    • Independent Runtime: State is isolated between micro-apps; runtime states are not shared.
  3. Implement a Docker-based CI/CD pipeline for Vue and Flask projects

    This architecture uses a Vue.js frontend (vue-admin-template) and a Python 3.6 Flask backend. The deployment strategy involves packaging services into Docker images, pushing them to a private registry (Harbor), and using Nginx as a load balancer to distribute requests to multiple backend containers using the ip_hash algorithm.
  4. Photography tips for Pudong Art Museum

    The Pudong Art Museum provides a vantage point facing the Bund, making it an ideal spot to photograph the sunset and the lighting of the historic buildings (Wan Guo Architecture) which typically occurs at 19:00.
  5. Understand qiankun architecture and sub-app registration

    The qiankun framework is composed of three main parts:

    1. qiankun: Manages sub-route registration, project startup, and JS sandbox lifecycle.
    2. single-spa: Manages sub-app registration, route listening, and the mounting/unmounting process.
    3. import-html-entry: Handles fetching remote HTML resources and parsing them for templates, CSS, and JS.

    Sub-applications are registered using registerMicroApps, which wraps single-spa's registerApplication to integrate qiankun's loading and sandbox logic.

    import { registerApplication } from 'single-spa';
    
    export function registerMicroApps(apps, lifeCycles) {
      const unregisteredApps = apps.filter((app) => !microApps.some((registeredApp) => registeredApp.name === app.name));
      microApps = [...microApps, ...unregisteredApps];
    
      unregisteredApps.forEach((app) => {
        const { name, activeRule, loader = noop, props, ...appConfig } = app;
    
        registerApplication({
          name,
          app: async () => {
            loader(true);
            await frameworkStartedDefer.promise;
            const { mount, ...otherMicroAppConfigs } = (
              await loadApp({ name, props, ...appConfig }, frameworkConfiguration, lifeCycles)
            )();
    
            return {
              mount: [async () => loader(true), ...toArray(mount), async () => loader(false)],
              ...otherMicroAppConfigs,
            };
          },
          activeWhen: activeRule,
          customProps: props,
        });
      });
    }
  6. Implement basic module isolation using Closures

    Before the introduction of formal module systems, closures were used to create local scopes to prevent global scope pollution and protect data from being modified externally. Properties are kept private within the closure and only exposed via specific methods.
    var moduleA = (function() {
        var name = 'zdy-a';
        var age = 23;
        return {
            getName: () => {
                return name;
            },
            rename: function(newName) {
                name = newName;
            }
        };
    })();
    
    console.log(moduleA.getName()); // 'zdy-a'
    moduleA.rename('shayebushi');
  7. Implement a high-performance edge stack with Cloudflare Workers and Hono

    To eliminate cold starts and reduce request latency, use a stack consisting of Next.js for the frontend, Hono as the lightweight web framework for the API, Cloudflare D1 for a serverless relational database, and Drizzle ORM for database management. This architecture leverages Cloudflare's global edge network and V8 engine for faster execution.
  8. BlogNews Project Overview and Tech Stack

    BlogNews is an RSS-based blog aggregation project that automatically fetches articles from interesting blogs daily to keep users updated on blog dynamics. The project is built using the following technology stack:

    • Next.js
    • Hono: A fast, lightweight web framework compatible with Cloudflare Workers
    • Cloudflare D1: A SQL database
    • Drizzle ORM: A TypeScript ORM for database interactions
  9. Automate Vaultwarden backups to Aliyun OSS

    Back up the Vaultwarden data directory by compressing it into a tarball and syncing it to Aliyun OSS using ossutil64.
    #!/bin/bash
    
    # Compress data directory
    cd /data/data/
    tar -czvf ./bitwarden-data-backup/bitwarden-data.tar.gz bitwarden-data/
    
    # Sync to Aliyun OSS
    echo "======================" >> /var/log/ossutil64-bitwarden.log
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting sync operation" >> /var/log/ossutil64-bitwarden.log
    /usr/bin/ossutil64 sync /data/data/bitwarden-data-backup/ oss://userdata-backup/bitwarden/ -f >> /var/log/ossutil64-bitwarden.log 2>&1

    Add to crontab for daily backup at 3 AM:

    0 3 * * * /root/autoBackup/bitwarden-backup.sh

  10. Understand the Shanghai Residence Permit Points application timeline

    The typical application process follows these stages:

    1. Data Entry: Fill in information in the application system.
    2. Submission: Submit original documents and photocopies to the company HR.
    3. HR Processing: HR prints the application form for signature and submits it to the Talent Center. The applicant receives back originals and an 'External Inquiry Letter' (外调函) and a 'Personnel Archive Verification Form'.
    4. Archive Verification: The applicant mails the inquiry letter and verification form to the Talent Center where their archives are stored.
    5. Acceptance: Once accepted, the application enters the Human Resources and Social Security Bureau approval stage (approximately 30 working days).
    6. Approval: Upon approval, the Points Notification (积分通知书) can be printed online or at the service outlet.
  11. Install and use git-push-console CLI

    The git-push-console package simplifies Git operations by allowing users to push local changes to a remote repository with a single command. It prompts the user for a commit message or allows the use of a default one.
    # Install the package globally
    npm install git-push-console -g
    
    # Usage: Navigate to your project directory and run
    git-push-console
  12. Self-host Immich for photo management on PVE

    Immich is an open-source, self-hostable photo management software that can be deployed on a HomeServer (e.g., using a CentOS VM on a PVE platform). Key features include:

    • Automatic mobile background backup (supports iPhone .heic and Live Photos).
    • Multi-user support with shared albums.
    • Advanced search using metadata, object detection, face recognition, and semantic search.
    • Cross-platform support for mobile and web interfaces.
    # Immich is available on GitHub
    # Repository: https://github.com/immich-app/immich/