• Use "bun"

    • bun add -g @enclosed/cli # Replace add with remove to remove it
  • Notes
    • Because it is faster than npm.
    • curl https://bun.sh/install | bash # Install dependencies
    • bun pm ls -g # List installed packages globally
  • References
    • Speed
      # Pnpm
      yaoniplan@tux ~ $ pnpm install @enclosed/cli -g
      Packages: +95
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      Progress: resolved 105, reused 0, downloaded 95, added 95, done
      
      /home/yaoniplan/.local/share/pnpm/global/5:
      + @enclosed/cli 1.15.0
      
      Done in 10.2s using pnpm v10.8.0
      yaoniplan@tux ~ $ pnpm uninstall @enclosed/cli -g
      Already up to date
      
      /home/yaoniplan/.local/share/pnpm/global/5:
      - @enclosed/cli 1.15.0
      
      Done in 564ms using pnpm v10.8.0
      yaoniplan@tux ~ $
      
      # Bun
      yaoniplan@tux ~ $ bun add @enclosed/cli -g
      bun add v1.2.9 (9a329c04)
      
      installed @enclosed/cli@1.15.0 with binaries:
       - enclosed
      
      1 package installed [9.32s]
      yaoniplan@tux ~ $ bun remove @enclosed/cli -g
      bun remove v1.2.9 (9a329c04)
      
      - @enclosed/cli
      1 package removed [5.00ms]
      yaoniplan@tux ~ $
      
    • https://github.com/oven-sh/bun/issues/1863#issuecomment-1401169766
    • Artificial intelligence

  • Use "pnpm"

    • pnpm install @enclosed/cli -g # Replace install with uninstall to uninstall it
  • Notes
    • Because it can solve the error reported by npm command.
    • nix profile install nixpkgs#pnpm # Install dependencies
  • References
    • Artificial intelligence

  • Use "iwctl"

    • iwctl device list # List available devices (e.g. wlan0)
    • iwctl station wlan0 scan # Scan for available Wi-Fi networks (Refresh)
    • iwctl station wlan0 get-networks # List scanned networks (e.g. iPhone)
    • iwctl station wlan0 connect iPhone # Connect to a network
    • Type the network passphrase for iPhone psk if prompt this message
  • Notes
    • doas systemctl enable iwd --now # Run IWD service at boot time to solve the problem
      yaoniplan@tux ~ $ iwctl
      Waiting for IWD to start...
      
    • iwctl # Interactive mode
      • station wlan0 scan # Scan to refresh
      • station wlan0 get-networks # Get WiFi network name
      • station wlan0 connect "iPhone" # Replace iPhone with your WiFi name
    • Because to connect to WiFi (e.g. Hotspot) without nmcli software.
  • References
    • The abbreviation of "internet wireless control" is "iwctl".
    • man iwctl
    • Artificial intelligence

  • Use "dig"

    • dig +short TXT _psl.dpdns.org
      "https://github.com/publicsuffix/list/pull/2414"
      
  • Notes
    • +short # Return TXT record's value only (Without additional metadata)
    • Because to query the DNS TXT record. (Associated with the subdomain _psl.dpdns.org)
    • nix profile install nixpkgs#dig # Install dependencies
  • References
    • The abbreviation of "Public Suffix List" is "psl".
    • https://github.com/publicsuffix/list/pull/2414
    • Artificial intelligence

  • Use "cloudpaste"

    • Create two KV Namespaces
      • PASTE_STORE
      • UPLOAD_STATUS
    • Create a R2 Bucket
      • cloudpaste-files
    • Create a Worker
      • Variables and Secrets
        Type Name Value
        Plaintext ADMIN_PASSWORD your-password-here
        Plaintext ADMIN_USERNAME your-username-here
      • Bindings
        Type Name Value
        R2 bucket FILE_STORE cloudpaste-files
        KV namespace PASTE_STORE PASTE_STORE
        KV namespace UPLOAD_STATUS UPLOAD_STATUS
      • Copy and paste worker.js to Worker
  • Notes
    • Upload text
      curl --request POST 'https://cloudpaste.yaoniplan.eu.org/api/paste' \
        --header 'Content-Type: application/json' \
        --header 'Authorization: Basic Encode-username:password-with-base64' \
        --data '{
          "content": "This is a secret message",
          "password": "",
          "expiresIn": "1h",
          "isMarkdown": true,
          "customId": "",
          "maxViews": 0,
          "note": ""
        }'
      
    • Upload file
      curl --request POST 'https://cloudpaste.yaoniplan.eu.org/api/file' \
        --header 'Authorization: Basic Encode-username:password-with-base64' \
        --form 'files=@/home/yaoniplan/Downloads/CloudPaste/worker.js' \
        --form 'expiresIn=1d' \
        --form 'maxViews=0'
      
    • Get text content
      curl --request GET https://cloudpaste.yaoniplan.eu.org/api/paste/iYyHIDXr
      
    • Because to share information temporarily and stably.
  • References
    • https://github.com/ling-drag0n/CloudPaste # /manual /api endpoint
    • Artificial intelligence

  • Use "yofi"

    • yofi
  • Notes
    • Warnings: it takes longer than other launchers.
    • nix profile install nixpkgs#yofi # Install dependencies
  • References
    • Artificial intelligence

  • Use "fuzzel"

    • vim ~/.config/fuzzel/fuzzel.ini # Dmenu layout
      [main]
      # Set Fuzzel's position to the top of the screen by default
      anchor=top
      # Set the window width to 100 characters
      width=100
      # Set font (Or FiraCode Nerd Font to display iconic font) and font size
      font=Fira Code:size=14
      # Set prompt
      prompt="-> "
      # No padding
      horizontal-pad=0
      vertical-pad=0
      inner-pad=0
      
      # No border
      [border]
      width=0
      radius=0
      
      # Change to a more modern theme
      [colors]
      background=1e1e2edd
      text=cdd6f4ff
      prompt=bac2deff
      placeholder=7f849cff
      input=cdd6f4ff
      match=f38ba8ff
      selection=585b70ff
      selection-text=cdd6f4ff
      selection-match=f38ba8ff
      counter=7f849cff
      border=f38ba8ff
      
      [key-bindings]
      # Use `Ctrl-m` to Confirm (Same as: `Enter`)
      execute=Control+j Control+m Return KP_Enter Control+y
      insert-selected=Control+i
      
  • Notes
    • Ctrl-n # Next line (Opposite: Ctrl-p)
    • Ctrl-[ # Exit (Same as: Esc)
    • --list-executables-in-path # List excutables in the PATH environment variable
    • --dmenu # Use dmenu compatibility mode
    • nix profile install nixpkgs#fuzzel # Install dependencies
  • References
    • https://github.com/catppuccin/fuzzel/blob/main/themes/catppuccin-mocha/red.ini
    • man fuzzel.ini # /colors /--dmenu
    • Artificial intelligence

  • If this URL http://localhost does not open in your browser

    • doas vim /etc/hosts # Map the IP address (127.0.0.1: the loopback address)to the hostname (localhost)
      127.0.0.1 localhost
      
    • Remember to restart your computer to make changes effective.
  • Notes
    • Because to open a project's developer mode with this wrangler command (npx wrangler pages dev .) failed.
  • References
    • Artificial intelligence

  • Solve the problem about filesystem type

    • Solve the problem
      mount: /run/media/yaoniplan: unknown filesystem type 'exfat'.
      
  • Notes
    • Because I accidentally deleted the dependency, the USB drive was not mounted after being inserted.
    • Manually
      • doas pacman --sync exfatprogs # Install dependencies
      • doas modprobe exfat # Add exfat modules to the Linux Kernel
    • Automatically
      • doas pacman --sync exfat-utils fuse-exfat
  • References
    • Artificial intelligence

  • Use "adb"

    • adb connect localhost:5555 # Connect to an instance
  • Notes
    • nix profile install nixpkgs#android-tools # Install dependencies
  • References
    • Artificial intelligence

  • Use "redroid"

    • vim ~/.config/redroid/compose.yaml
      services:
        redroid:
          image: redroid/redroid:latest
          container_name: redroid
          privileged: true
          volumes:
            - ./data:/data
          ports:
            - "5555:5555"
          environment:
            androidboot.redroid_width=1080
            androidboot.redroid_height=1920
            androidboot.redroid_dpi=480
          restart: always
      
      • docker compose up --detach # Run in the background
      • adb connect localhost:5555 # Connect to the Redroid instance
      • scrcpy -s localhost:5555 # Mirror and control the Redroid instance
  • Notes
    • Warnings: Some software crashes when opened (Perhas due to my PC hardware performance issues)
    • adb -s localhost:5555 install com.kiwibrowser.browser-x64-8822657649-github.apk # Install the APK on a specific device
    • adb -s localhost:5555 uninstall com.kiwibrowser.browser # Uninstall the APK on a specific device
      • adb -s localhost:5555 shell pm list packages | grep kiwibrowser # List the installed packages
    • adb -s localhost:5555 shell getprop ro.product.cpu.abi # Get architecture (e.g. x86_64: x86 64-bit -> x64)
    • Solve the problem
      [server] ERROR: Could not create default audio encoder for opus
      List of audio encoders:
          --audio-codec=aac --audio-encoder=OMX.google.aac.encoder          (hybrid)
          --audio-codec=flac --audio-encoder=OMX.google.flac.encoder        (hybrid)
      
      • --audio-codec aac # Use software rendering (e.g. advanced audio coding)
    • Because to run Android software on Linux.
  • References
    • https://hub.docker.com/r/redroid/redroid
    • Artificial intelligence

  • Use "waydroid"

    • waydroid show-full-ui # Launch a GUI
    • waydroid app install ~/Downloads/com.kiwibrowser.browser-arm64-8822657649-github.apk # Install a new Android app from a file
  • Notes
    • Warnings: No Internet connection
    • yay --sync waydroid # Install dependencies (Install waydroid-image-gapps if the download of Android images is slow)
      • doas waydroid init -s GAPPS # Init waydroid with GApps support
      • doas systemctl start waydroid-container # Start waydroid-container service
      • waydroid session start # Start waydroid session
  • References
    • https://wiki.archlinux.org/title/Waydroid#Installation
    • tldr waydroid
    • Artificial intelligence

  • Use "dmidecode"

    • doas dmidecode --type memory
  • Notes
    • Because to get information about the memory sticks of the desktop computer I just bought.
      • Size (e.g. 8GB)
      • Type (e.g. DDR3)
      • Speed (e.g. 1333 MT/s)
      • Manufacturer (e.g. Kingston)
  • References
    • dmi # Desktop management interface
    • Artificial intelligence

  • Use "yazi"

    • yazi
      • . # Show or hide dotfiles
      • q # Quit
      • ~ # Open the help menu
      • g<Space> # Go to the path you want to go
  • Notes
    • vim ~/.config/yazi/keymap.toml # Configure keybindings
      [[manager.prepend_keymap]]
      on   = [ "g", "b" ]
      run  = "cd ~/.local/bin"
      desc = "Goto ~/.local/bin"
      
    • v # Visial mode (Selection mode, select multiple and delete in batches)
    • Delete a directory
      • /tachi # Search for the directory you watn to delete
      • d # Delete (Move it to ~/.local/share/Trash/)
      • y # Yes
    • Because to use the fastest file manager.
    • nix profile install nixpkgs#yazi # Install dependencies
  • References
    • https://yazi-rs.github.io/docs/quick-start
    • Artificial intelligence

  • Use "shuf"

    • vi ~/.local/bin/changeWallpaperRandomly.sh
      wallpaper_list="$HOME/.cache/wallpaper-compgen"
      
      # Get random wallpaper
      random_wallpaper="$(shuf --head-count 1 "$wallpaper_list")"
      
  • Notes
    • Because to select one line from the file randomly.
  • References
    • vi ~/.cache/wallpaper-compgen
      wallpaper-w8v91r.jpg
      wallpaper-zmwryj.png
      wallpaper-1513849.jpg
      ...
      
    • shuf # Shuffle
    • Artificial intelligence

  • Use menu SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
          <circle cx="12" cy="12" r="11"></circle>
          <line x1="12" y1="7" x2="12" y2="17"></line>
          <line x1="7" y1="12" x2="17" y2="12"></line>
      </svg>
      
  • Notes
    • A circle with a plus sign inside
  • References
    • Artificial intelligence

  • Use QR code SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <rect x="4" y="4" width="6" height="6" stroke="currentColor" stroke-width="2"/>
          <rect x="6" y="6" width="2" height="2" fill="currentColor"/>
          
          <rect x="14" y="4" width="6" height="6" stroke="currentColor" stroke-width="2"/>
          <rect x="16" y="6" width="2" height="2" fill="currentColor"/>
          
          <rect x="4" y="14" width="6" height="6" stroke="currentColor" stroke-width="2"/>
          <rect x="6" y="16" width="2" height="2" fill="currentColor"/>
          
          <rect x="14" y="14" width="2" height="2" fill="currentColor"/>
          <rect x="18" y="14" width="2" height="2" fill="currentColor"/>
          <rect x="14" y="18" width="2" height="2" fill="currentColor"/>
          <rect x="18" y="18" width="2" height="2" fill="currentColor"/>
          <rect x="16" y="16" width="2" height="2" fill="currentColor"/>
      </svg>
      
  • Notes
    • A mini QR code
  • References
    • Artificial intelligence

  • Use feedback SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M21 12C21 16.9706 16.9706 21 12 21C10.8029 21 9.6603 20.7663 8.61872 20.3419L3 21L4.27477 16.0491C3.48187 14.8357 3 13.4059 3 11.8587C3 6.88811 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" 
                stroke="currentColor" 
                stroke-width="2" 
                stroke-linecap="round" 
                stroke-linejoin="round"/>
          <circle cx="12" cy="12" r="1" fill="currentColor"/>
          <circle cx="8" cy="12" r="1" fill="currentColor"/>
          <circle cx="16" cy="12" r="1" fill="currentColor"/>
      </svg>
      
  • Notes
    • A chat bubble shape with rounded corners includes three dots inside
  • References
    • Artificial intelligence

  • Use profile SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <circle cx="12" cy="12" r="11" stroke="currentColor" stroke-width="2"/>
          <circle cx="12" cy="8" r="4" stroke="currentColor" stroke-width="2"/>
          <path d="M4 19.5C4 15.9101 7.58172 13 12 13C16.4183 13 20 15.9101 20 19.5" 
                stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
      </svg>
      
  • Notes
    • An outer circle
    • A small circle at the top (The head)
    • An arc at the bottom (The body)
  • References
    • Artificial intelligence

  • Use share SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="share-icon">
          <path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"></path>
          <polyline points="16 6 12 2 8 6"></polyline>
          <line x1="12" y1="2" x2="12" y2="15"></line>
      </svg>
      
  • Notes
    • A square with an upward arrow (Like a potted plant)
  • References
    • Artificial intelligence

  • Disable the pull-to-refresh gesture

    • vi ~/.config/store/supermarket/styles.css
      html, body {
          overscroll-behavior-y: none;
      }
      
  • Notes
    • Because to prevent accidentally triggering the browser's scroll-down update page functionality.
  • References
    • Artificial intelligence

  • Support scan QR code feature for a website

    • vi ~/.config/store/scan/index.html
      <!DOCTYPE html>
      <html>
        <head>
          <title>QR Code Scanner</title>
          <meta charset="UTF-8" />
          <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
          <link rel="stylesheet" href="src/styles.css" />
          <script src="./src/qr_packed.js"></script>
        </head>
      
        <body>
          <div id="container">
            <h1>QR Code Scanner</h1>
      
            <button id="btn-scan-qr" class="scan-button">
              <span>Scan QR Code</span>
            </button>
      
            <canvas hidden="" id="qr-canvas"></canvas>
      
            <div id="qr-result" hidden="">
              <b>Data:</b> <span id="outputData"></span>
            </div>
          </div>
      
          <script src="./src/qrCodeScanner.js"></script>
        </body>
      </html>
      
  • Notes
    • Warnning: This needs to work under HTTPS protocol or localhost.
    • vi ~/.config/store/src/qr_packed.js
      # Copy the content of the link and paste it here
      # https://rawgit.com/sitepoint-editors/jsqrcode/master/src/qr_packed.js
      
    • vi ~/.config/store/src/qrCodeScanner.js
      const video = document.createElement("video");
      const canvasElement = document.getElementById("qr-canvas");
      const canvas = canvasElement.getContext("2d");
      
      const qrResult = document.getElementById("qr-result");
      const outputData = document.getElementById("outputData");
      const btnScanQR = document.getElementById("btn-scan-qr");
      
      let scanning = false;
      
      qrcode.callback = res => {
        if (res) {
          outputData.innerText = res;
          scanning = false;
      
          video.srcObject.getTracks().forEach(track => {
            track.stop();
          });
      
          qrResult.hidden = false;
          canvasElement.hidden = true;
          btnScanQR.hidden = false;
        }
      };
      
      btnScanQR.onclick = () => {
        navigator.mediaDevices
          .getUserMedia({ video: { facingMode: "environment" } })
          .then(function(stream) {
            scanning = true;
            qrResult.hidden = true;
            btnScanQR.hidden = true;
            canvasElement.hidden = false;
            video.setAttribute("playsinline", true); // required to tell iOS safari we don't want fullscreen
            video.srcObject = stream;
            video.play();
            tick();
            scan();
          });
      };
      
      function tick() {
        canvasElement.height = video.videoHeight;
        canvasElement.width = video.videoWidth;
        canvas.drawImage(video, 0, 0, canvasElement.width, canvasElement.height);
      
        scanning && requestAnimationFrame(tick);
      }
      
      function scan() {
        try {
          qrcode.decode();
        } catch (e) {
          setTimeout(scan, 300);
        }
      }
      
    • vi ~/.config/store/src/styles.css
      html {
        height: 100%;
      }
      
      body {
        font-family: sans-serif;
        padding: 0 10px;
        height: 100%;
        background: black;
        margin: 0;
      }
      
      h1 {
        color: white;
        margin: 0;
        padding: 15px;
      }
      
      #container {
        text-align: center;
        margin: 0;
      }
      
      #qr-canvas {
        margin: auto;
        width: calc(100% - 20px);
        max-width: 400px;
      }
      
      #btn-scan-qr {
        cursor: pointer;
        background: white;
        border: 2px solid #222;
        border-radius: 8px;
        padding: 15px 20px;
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 20px auto;
        transition: all 0.2s ease;
      }
      
      #btn-scan-qr:hover {
        background: #f0f0f0;
      }
      
      #btn-scan-qr .camera-icon {
        font-size: 24px;
        line-height: 1;
      }
      
      #btn-scan-qr span {
        font-size: 16px;
        font-weight: 500;
        color: #222;
      }
      
      #qr-result {
        font-size: 1.2em;
        margin: 20px auto;
        padding: 20px;
        max-width: 700px;
        background-color: white;
      }
      
    • Because to obtain the member's username by scanning the QR code.
  • References
    • https://www.sitepoint.com/create-qr-code-reader-mobile-website/
    • Artificial intelligence

  • Use shopping cart SVG icon

    • vi ~/.config/store/supermarket/index.html
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="cart-icon">
          <circle cx="9" cy="21" r="1"></circle>
          <circle cx="20" cy="21" r="1"></circle>
          <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
      </svg>
      
  • Notes
    • stroke-width="1.5" # Make the lines thinner
    • r="2" fill="none" # Change the wheels of shopping cart from real to hollow
    • Because we want the shopping cart icon to give people a sense of relaxation.
  • References
    • Artificial intelligence

  • Use clear search SVG icon

    • vi ~/.config/store/supermarket/index.html
      <button id="clear-search" class="hidden">
          <svg class="clear-search-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
              <circle cx="12" cy="12" r="12" fill="currentColor"/>
              <path d="M16 8L8 16M8 8L16 16" stroke="white" stroke-width="2" stroke-linecap="round"/>
          </svg>
      </button>
      
  • Notes
    • r="12" # Circle radius
    • d="M16 8L8 16M8 8L16 16" # Make the X larger
    • stroke-width="2" # Make the X more visible
    • Because to improve the user experience
      • Click the Clear Search button to enter a new
      • Double-click Select All to enter a new
  • References
    • Artificial intelligence

  • Draw a SVG search icon

    • vi ~/.config/store/supermarket/index.html
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48" fill="none" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search" id="search-icon">
          <circle cx="24" cy="24" r="20"></circle>
          <line x1="44" y1="44" x2="40" y2="40"></line>
      </svg>
      
  • Notes
    • stroke-width="5" # The thickness of the lines
    • <circle cx="24" cy="24" r="20"></cricle> # A circle
      • Centered at (24,24) with a radius of 20 units
    • <line x1="44" y1="44" x2="40" y2="40"></line> # The handle of the magnifying glass
      • Start as (44,44) and end at (40,40)
  • References
    • Artificial intelligence

  • Backup R2

    • crontab -e
      00 17 * * * /usr/bin/rclone sync r2:products /mnt/grow/image/backups --backup-dir=/mnt/grow/image/archive/$(date +\%Y\%m\%d.\%H\%M\%S)
      
  • Notes
    • --backup-dir # Move deleted or overwritten files to archive directory
    • \ # Escape special characters (e.g. %) to prevent command errors
    • Because to prevent pictures from being accidentally deleted.
  • References
    • Artificial intelligence

  • Use "qrencode"

    • qrencode --output=/dev/stdout "Your text or URL here" | feh -
  • Notes
    • qrencode --type=ansiutf8 "hello" # Print to terminal
    • qrencode --output=output.png "Your text or URL here" # Save it
    • nix profile install nixpkgs#qrencode # Install dependencies
    • Because to implement the feature of aggregating QR codes.
  • References
    • Artificial intelligence

  • Implement the QR code feature of aggregated payment

    • vi ~/.config/store/payment/app.py # Run on a server
      from flask import Flask, request, redirect
      
      app = Flask(__name__)
      
      # Define payment links
      ALIPAY_LINK = "https://qr.alipay.com/example"  # Replace with your actual Alipay link
      WECHAT_PAY_LINK = "https://payapp.wechatpay.cn/sjt/qr/example"  # Replace with your actual WeChat Pay link
      
      @app.route('/generate_qr', methods=['GET'])
      def generate_qr():
          user_agent = request.headers.get('User-Agent', '')
      
          # Return the corresponding payment link according to User-Agent
          if 'Alipay' in user_agent:
              return redirect(ALIPAY_LINK)
          elif 'MicroMessenger' in user_agent:
              return redirect(WECHAT_PAY_LINK)
          else:
              return {"error": "Unsupported payment method"}, 400
      
      if __name__ == '__main__':
          app.run(host='0.0.0.0', port=5000, debug=True)
      
  • Notes
    • qrencode -o payment.png "http://192.168.1.100:5000/generate_qr" # Generate a QR code for others to access
    • Because I don't want to add a button to switch payment methods for the website.
      • After scanning the QR code
      • The user will first access the intermediate URL
      • And then automatically redirect to the corresponding payment link according to its User-Agent
    • Cloudflare Worker (Optional)
      addEventListener('fetch', event => {
          event.respondWith(handleRequest(event.request));
      });
      
      async function handleRequest(request) {
          const userAgent = request.headers.get('User-Agent') || '';
      
          const ALIPAY_LINK = "https://qr.alipay.com/example"; // Replace with your Alipay link
          const WECHAT_PAY_LINK = "https://payapp.wechatpay.cn/sjt/qr/example"; // Replace with your WeChat link
      
          if (userAgent.includes('Alipay')) {
              return Response.redirect(ALIPAY_LINK, 302);
          } else if (userAgent.includes('MicroMessenger')) {
              return Response.redirect(WECHAT_PAY_LINK, 302);
          } else {
              return new Response(JSON.stringify({ error: "Unsupported payment method" }), {
                  status: 400,
                  headers: { 'Content-Type': 'application/json' }
              });
          }
      
  • References
    • Artificial intelligence

  • Use x-callback-url in iPhone

    • Check Out
      - Text
        """
        shortcuts://x-callback-url/run-shortcut?name=getBarcode&x-cancel=shortcuts://run-shortcut?name=openShoppingCart
        """
      - Open Text
      
    • getBarcode
      - Number (99)
      - Repeat (Number)
          - Scan QR or barcode
          - Add QR/Barcode to Barcode
          - Text (Barcode)
          - Set variable `All barcode` to `Text`
          - Replace `click return key` with `:1,` in `All barcode`
          - Set variable `Formatted barcode` to `Updated Text`
          - Text (https://example.com/?cart=`Formatted barcode`:1)
          - Set variable `URL` to `Text`
          - Copy `URL` to clipboard
      - End Repeat
      
    • openShoppingCart
      Open Clipboard
      
  • Notes
    • Because to scan barcode, get barcode, and repeat this process until click Cancel to proceed to the next step.
  • References
    • https://safereddit.com/r/shortcuts/comments/y5f119/ # /full URL
    • https://safereddit.com/r/shortcuts/comments/9sq058/creating_a_while_loop_sort_of/ # Number action (No need to click manually 98 times)
    • https://safereddit.com/r/shortcuts/comments/9j3yga/example_do_while_loop/ # Add to Variable action (Add each obtained value to a variable)

  • Convert Chinese text into Pinyin

    • vi ~/.config/store/supermarket/convertToPinyin.py
      import sys
      from pypinyin import pinyin, Style
      
      def convert_to_pinyin_without_tones(chinese_text):
          # Convert Chinese text to Pinyin without tones
          return ''.join([item[0] for item in pinyin(chinese_text, style=Style.NORMAL)])
          
      # Check if a parameter was provided
      if len(sys.argv) > 1:
          product_name = sys.argv[1] # Get the first argument passed to the script
      else:
          print("Please provide a product name as a parameter.")
          sys.exit(1) # Exit if no parameter is provided
      
      # Convert the product name to Pinyin without tones
      pinyin_without_tones = convert_to_pinyin_without_tones(product_name)
      
      # Print the result without line breaks
      print(pinyin_without_tones, end='')
      
  • Notes
    • , end='' # Remove line breaks (Take the output as a parameter)
    • Because we need to support product pinyin search.
  • References
    • Sample
      {
        "barcode": "6934567890123",
        "name": "一瓶水",
        "cost": "0.5",
        "category": "饮料酒水",
        "price": "1",
        "image": "https://example.com/example.png",
        "pinyin": "yipingshui"
      }
      
    • Artificial intelligence

  • Check if an image has transparency

    • vim ~/.local/bin/uploadImage.sh
      determine_opaque() {
          convert "$name" -format "%[opaque]" info:
      }
      
      if [[ "$(determine_opaque)" == "False" ]]; then
          ...
      
  • Notes
    • Because to identify the target image of the cutout image of the iPhone.
  • References
    • Artificial intelligence

  • Get image extension

    • vim ~/.local/bin/uploadImage.sh
      # Expand the wildcard to the actual file path
      file=$(realpath ~/Downloads/69*)
      extension="${file##*.}"
      
  • Notes
    • ##*. # Extract everything after the last dot
    • Because to determine whether the extension of the image file is PNG or JPEG.
  • References
    • Artificial intelligence

  • Get image size

    • vim ~/.local/bin/uploadImage.sh
      size=$(stat --format=%s "$file")
      
  • Notes
    • %s # Size in bytes
  • References
    • Artificial intelligence

  • Get the dimensions (e.g. 3032x3032) of an image

    • identify -format "%wx%h" ~/Downloads/6970873413839.jpg
  • Notes
    • %w # Width
    • %h # Height
  • References
    • Artificial intelligence

  • Rotate an image

    • convert 6930487901795.jpeg -rotate 90 6930487901795-rotated.jpeg
  • Notes
    • -rotate 90 # Rotate an image by 90 degrees clockwise
  • References
    • Artificial intelligence

  • Reduce image pixels

    • convert 6901028118187-705x705-1.jpg -resize 225x225! 6901028118187-705x705-2.jpg # From 705x705 to 225x225
  • Notes
    • mogrify -resize 225x225 6901028118187-705x705.jpg # Another method
    • Because to minimize the loss of quality.
  • References
    • Artificial intelligence

  • Fill color

    • convert 6901028133906-180x180.jpeg -fill '#e8e8e8' -draw "rectangle 160,140 180,180" 6901028133906-180x180-withoutWatermark.jpeg
  • Notes
    • 160,140 # Coordinates of the upper left corner
    • 180,180 # Coordinates of the lower right corner
    • Because to cover the watermark in the lower right corner.
  • References
    • Artificial intelligence

  • Convert PNG to JPEG

    • convert 6947739101445-235x235-fs8.png 6947739101445-235x235-fs8.jpeg
  • Notes
    • Solve the problem
      yaoniplan@tux ~/Downloads $ jpegoptim --size=3K --verbose 6947739101445-235x235.png
      Target size for output files set to: 3 Kbytes.
      Using maximum of 1 parallel threads
      6947739101445-235x235.png  (Not a JPEG file: starts with 0x89 0x50)  [ERROR]
      yaoniplan@tux ~/Downloads $
      
  • References
    • Artificial intelligence

  • Use the built-in color picker in the developer tools

    • Ctrl-Shift-i # Inspect
    • Elements tab - Styles siderbar
    • Colored box - Eye dropper icon
  • Notes
    • Because to check whether the background color of a picture is pure white (#ffffff).
  • References
    • Artificial intelligence

  • Crop an image

    • convert 6934502301850.jpeg -gravity center -crop 198x198+0+0 output.jpeg
      • -gravity center # Center the crop area around the middle of the image
      • 198x198 # Set the width and height of the cropped area to 198 pixels each
      • +0+0 # The offset from the gravity point
  • Notes
    • -background white -gravity center -extent 277x277 # Pad rectangular image with white space to make it square
      • "#fefefe" # Enclose the color code in double quotes if not using color word
      • -extent 277x277 # resize the canvas (e.g. 182x277) to 277x277 pixels
    • -gravity west -crop 50%x100% # Crop out the right half fo image
      • west # Leave the left
      • 50% # Width
      • 100% # Height
    • -20+0 # Offset the crop area 20 pixels to the left
      • Imagine moving the picture in coordinates (+x+y)
      • Increase the Y value moves the image upward
      • Fixed cropping area
    • Because to crop the image (254x198) into a square (198x198).
      • Cut off the extra parts on the left and right sides
  • References
    • Artificial intelligence

  • Compress images

    • jpegoptim ~/Downloads/6901754220802.jpeg
      • --size=3K # To a specific size
  • Notes
    • nix profile install nixpkgs#jpegoptim # Install dependencies
    • Because to upload pictures to Cloudflare R2.
  • References
    • Artificial intelligence

  • Disable cache when develop a website

    • Chromium (Or Firefox)
      • Open developer tools (Ctrl-Shift-i)
      • Click on the Network tab (Ctrl-])
      • Check the Disable cache checkbox
      • Refresh page (Ctrl-r)
  • Notes
    • Because to visualize code changes.
  • References
    • Artificial intelligence

  • Set up a profile

    • Contribution snake
      ![github-snake](https://raw.githubusercontent.com/yaoniplan/yaoniplan/output/github-contribution-grid-snake.svg)
      
    • Typing SVG
      ![Typing SVG](https://readme-typing-svg.demolab.com/?lines=Hello%20there%2C%20I'm%20yaoniplan%20%F0%9F%91%8B)
      
      • &font=Fira%20Code
      • Remember to encode the string
    • Skill icons
      ![skills](https://skillicons.dev/icons?i=arch,bash)
      
      • arch # Replace it with other icon id (e.g. debian)
      • &perline=14
      • &theme=light
    • Repo cards
      [![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=yaoniplan&repo=note)](https://github.com/yaoniplan/note)
      
      • &theme=dark # Replace dark with other theme (e.g. cobalt)
      • &show_owner=true
      • &border_color=3c4043
  • Notes
    • Support dark and light mode
      <a href="https://github.com/yaoniplan/note">
      <picture>
        <source media="(prefers-color-scheme: dark)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=yaoniplan&repo=note&theme=dark">
        <source media="(prefers-color-scheme: light)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=yaoniplan&repo=note&theme=default">
        <img alt="Repo-card" src="https://github-readme-stats.vercel.app/api/pin/?username=yaoniplan&repo=note&theme=default">
      </picture>
      </a>
      
      • Anchor tag (<a> and </a>) is optional
    • Use GitHub Actions
      • vi ~/.config/yaoniplan/.github/workflows/main.yml
        name: generate animation
        
        on:
          # Run automatically every 24 hours
          schedule:
            - cron: "0 */24 * * *"
          # Allows to manually run the job at any time
          workflow_dispatch:
          # Run on every push on the development branch
          push:
            branches:
            - development
        
        jobs:
          generate:
            permissions:
              contents: write
            runs-on: ubuntu-latest
            timeout-minutes: 5
            steps:
              # Generates a snake game from a GitHub user (<github_user_name>) contributions graph, output a svg animation at <svg_out_path>
              - name: generate github-contribution-grid-snake.svg
                uses: Platane/snk/svg-only@v3
                with:
                  github_user_name: ${{ github.repository_owner }}
                  outputs: |
                    dist/github-contribution-grid-snake.svg
                    dist/github-contribution-grid-snake-dark.svg?palette=github-dark
              # Push the content of <build_dir> to a branch
              # The content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file>, or as github page
              - name: push github-contribution-grid-snake.svg to output branch
                uses: crazy-max/ghaction-github-pages@v3.1.0
                with:
                  target_branch: output
                  build_dir: dist
                env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        
    • Becuase to highlight my skills and experience.
  • References
    • https://github.com/Platane/snk#usage # dist: distribution
    • https://github.com/anuraghazra/github-readme-stats#themes
      • https://github.com/anuraghazra/github-readme-stats/discussions/1684#discussioncomment-3777805 # Light and dark mode
    • https://github.com/tandpfun/skill-icons#example
    • https://github.com/DenverCoder1/readme-typing-svg#-quick-setup

  • Use "wrangler"

    • npm create cloudflare@latest -- products # Create a project
    • npx wrangler d1 create products # Create a database
    • vi ~/.config/store/products/wrangler.toml # Append to end of file
      [[d1_databases]]
      binding = "DB"
      database_name = "products"
      database_id = "<unique-ID-for-your-database>"
      
    • vi ~/.config/store/products/products.sql # Configure your D1 database
      DROP TABLE IF EXISTS products;
      CREATE TABLE IF NOT EXISTS products (
          barcode TEXT PRIMARY KEY,
          name TEXT,
          price TEXT
      );
      INSERT INTO products (barcode, name, price) VALUES
      ('6934567890123','water1','1'),
      ('6934567890124','water2','2'),
      ('6934567890125','water3','3');
      
      • npx wrangler d1 execute products --local --file=./products.sql # Initialize database to test locally first
      • npx wrangler d1 execute products --local --command="SELECT * FROM products" # Validate your data
    • vi ~/.config/store/products/src/index.ts # Configure your Worker
      export interface Env {
        DB: D1Database;  // The D1 database binding
      }
      
      const JSON_HEADERS = { "Content-Type": "application/json" };
      
      export default {
        async fetch(request: Request, env: Env): Promise<Response> {
          const url = new URL(request.url);
          const pathname = url.pathname;
          const method = request.method;
      
          try {
            // Return all products by default
            if (pathname === "/" && method === "GET") {
                const results = await env.DB.prepare("SELECT barcode, name, price FROM products").all();
                return new Response(JSON.stringify(results.results), { headers: JSON_HEADERS });
            }
      
            if (pathname === "/search_product" && method === "GET") {
              const barcode = url.searchParams.get("barcode");
              const name = url.searchParams.get("name");
      
              // Ensure at least one search parameter is provided
              if (!barcode && !name) {
                return new Response(
                  JSON.stringify({ error: "Missing barcode or name" }),
                  { status: 400, headers: JSON_HEADERS }
                );
              }
      
              let query = "SELECT barcode, name, price FROM products WHERE ";
              const params: string[] = [];
      
              if (barcode) {
                query += "barcode = ?";
                params.push(barcode);
              }
      
              if (name) {
                if (params.length > 0) {
                  query += " OR "; // If there's already a condition, use OR
                }
                query += "name LIKE ?";
                params.push(`%${name}%`);
              }
      
              const stmt = env.DB.prepare(query);
              const results = await stmt.bind(...params).all();
      
              return new Response(
                JSON.stringify(results.results),
                { headers: JSON_HEADERS }
              );
            }
      
            if (pathname === "/add_product" && method === "POST") {
              const data = await request.json();
              const { barcode, name, price } = data;
      
              if (!barcode || !name || !price) {
                return new Response(
                  JSON.stringify({ error: "Missing data" }),
                  { status: 400, headers: JSON_HEADERS }
                );
              }
      
              await env.DB.prepare(
                "INSERT INTO products (barcode, name, price) VALUES (?, ?, ?)"
              ).bind(barcode, name, price).run();
      
              return new Response(
                JSON.stringify({ message: "Product added successfully" }),
                { status: 201, headers: JSON_HEADERS }
              );
            }
      
            if (pathname === "/delete_product" && method === "DELETE") {
              const barcode = url.searchParams.get("barcode");
      
              if (!barcode) {
                return new Response(
                  JSON.stringify({ error: "Missing barcode" }),
                  { status: 400, headers: JSON_HEADERS }
                );
              }
      
              await env.DB.prepare(
                "DELETE FROM products WHERE barcode = ?"
              ).bind(barcode).run();
      
              return new Response(
                JSON.stringify({ message: "Product deleted successfully" }),
                { headers: JSON_HEADERS }
              );
            }
      
            if (pathname === "/update_product" && method === "PUT") {
              const data = await request.json();
              const { barcode, name, price } = data;
      
              if (!barcode || !name || price == null) {
                return new Response(
                  JSON.stringify({ error: "Missing barcode, name, or price" }),
                  { status: 400, headers: JSON_HEADERS }
                );
              }
      
              // Check if the product exists before updating
              const existingProduct = await env.DB.prepare(
                "SELECT 1 FROM products WHERE barcode = ?"
              ).bind(barcode).first();
      
              if (!existingProduct) {
                return new Response(
                  JSON.stringify({ error: "Product not found" }),
                  { status: 404, headers: JSON_HEADERS }
                );
              }
      
              await env.DB.prepare(
                "UPDATE products SET name = ?, price = ? WHERE barcode = ?"
              ).bind(name, price, barcode).run();
      
              return new Response(
                JSON.stringify({ message: "Product updated successfully" }),
                { headers: JSON_HEADERS }
              );
            }
      
            return new Response(
              "Route not found",
              { status: 404 }
            );
      
          } catch (error) {
            return new Response(
              JSON.stringify({ error: "Database error" }),
              { status: 500, headers: JSON_HEADERS }
            );
          }
        },
      } satisfies ExportedHandler<Env>;
      
      • npx wrangler dev # Develop locally
      • npx wrangler d1 execute products --remote --file=./products.sql # Import the data into the production version of your database
      • wrangler d1 export DB --output products.sql --remote # Export the database (Optional: For backup)
      • npx wrangler d1 execute products --remote --command="SELECT * FROM products" # Validate the data
      • npx wrangler deploy # Deploy your Worker on the Internet
  • Notes
    • vi ~/.config/store/auth-db/wrangler.toml # Define environment variables
      [vars]
      JWT_SECRET = "yourValue"
      
      • wrangler secret put JWT_SECRET # Create a secret before defining (This will create a Worker)
      • vi ~/.config/store/auth-db/src/index.js # Access the secret
        env.JWT_SECRET
        
      • npm install hono bcryptjs # Install dependencies if you import these modules in src/index.js file
    • wrangler tail # Show real-time logs
      (error) Signup error: Error: D1_ERROR: no such table: users: SQLITE_ERROR
      
      • vi ~/.config/store/auth-db/schema.sql # Remember to add IF NOT EXISTS to create the users table
        DROP TABLE IF EXISTS users;
        CREATE TABLE IF NOT EXISTS users (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            email TEXT UNIQUE NOT NULL,
            password_hash TEXT NOT NULL,
            created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
            last_login DATETIME
        );
        
    • Create (Add the new product to the database)
      curl --request POST http://localhost:8787/add_product \
          --header "Content-Type: application/json" \
          --data '{
              "barcode": "6934567890123",
              "name": "water",
              "price": "1"
          }'
      
    • Read (Get product by barcode)
      curl http://localhost:8787/search_product?barcode=6934567890123
      
      • barcode # Replace it with name to get product by name
    • Update (Update the information of a product)
      curl --request PUT "http://localhost:8787/update_product" \
          --header "Content-Type: application/json" \
          --data '{
              "barcode": "6934567890123"
              "name": "water2"
              "price": "2"
          }'
      
    • Delete (Delete product by barcode)
      curl --request DELETE http://localhost:8787/delete_product?barcode=6934567890123
      
    • Because to open the database to the Internet for easy query.
      • Use Cloudflare D1 as a backend
  • References
    • https://developers.cloudflare.com/d1/get-started/
    • Artificial intelligence

  • Integrate Cloudflare Workers KV for low-latency access

    • npm create cloudflare@latest -- feedback # Create a project (e.g. feedback)
    • npx wrangler kv namespace create feedback # Create a KV namespace (e.g. feedback)
    • vi ~/.config/store/feedback/wrangler.toml
      [[kv_namespaces]]
      binding = "feedback"
      id = "<your-kv-namespace-id>"
      
    • vi ~/.config/store/feedback/src/index.ts
      export interface Env {
          feedback: KVNamespace; // Ensure this matches your binding name
      }
      
      // Define header constants
      const JSON_HEADERS = { "Content-Type": "application/json" };
      
      const CORS_HEADERS = {
          "Access-Control-Allow-Origin": "*", // Allow all origins
          "Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS", // Allow these methods
          "Access-Control-Allow-Headers": "Content-Type", // Allow these headers
      };
      
      export default {
          async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
              const url = new URL(request.url);
      
              // Handle preflight requests
              if (request.method === 'OPTIONS') {
                  return new Response(null, {
                      status: 204,
                      headers: CORS_HEADERS,
                  });
              }
      
              // Handle POST requests for submitting feedback
              if (request.method === 'POST' && url.pathname === '/submit') {
                  const { message } = await request.json();
      
                  if (!message) {
                      return new Response("Message is required", { status: 400, headers: CORS_HEADERS });
                  }
      
                  // Use the current timestamp as the key
                  const timestamp = Date.now().toString();
      
                  // Store the message in KV
                  await env.feedback.put(timestamp, message);
      
                  return new Response("Feedback submitted successfully", { status: 201, headers: CORS_HEADERS });
              }
      
              // Handle GET requests for retrieving all feedback
              if (request.method === 'GET' && url.pathname === '/') {
                  const keys = await env.feedback.list();
                  const feedbackEntries: { timestamp: string; message: string }[] = [];
      
                  // Fetch all feedback messages using their keys
                  for (const key of keys.keys) {
                      const value = await env.feedback.get(key.name);
                      if (value !== null) {
                          feedbackEntries.push({ timestamp: key.name, message: value });
                      }
                  }
      
                  return new Response(JSON.stringify(feedbackEntries), {
                      headers: { ...CORS_HEADERS },
                  });
              }
      
              // Handle DELETE requests for removing feedback
              if (request.method === 'DELETE' && url.pathname.startsWith('/delete/')) {
                  const timestamp = url.pathname.split('/delete/')[1];
      
                  if (!timestamp) {
                      return new Response("Timestamp is required", { status: 400, headers: CORS_HEADERS });
                  }
      
                  // Delete the feedback entry from KV
                  await env.feedback.delete(timestamp);
      
                  return new Response("Feedback deleted successfully", { status: 200, headers: CORS_HEADERS });
              }
      
              // Return 404 for unsupported routes
              return new Response("Not Found", { status: 404, headers: CORS_HEADERS });
          },
      } satisfies ExportedHandler<Env>;
      
      • Resolve the CORS issue
        // Define header constants
        const JSON_HEADERS = { "Content-Type": "application/json" };
        const CORS_HEADERS = {
            "Access-Control-Allow-Origin": "*", // Allow all origins
            "Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS", // Allow these methods
            "Access-Control-Allow-Headers": "Content-Type", // Allow these headers
        };
        
    • npx wrangler kv key put --binding=feedback "$(date +%s%3N)" "A small bottle of detergent" # Write a key-value pair
    • npx wrangler kv key get --binding=feedback "1730448992271" --text # Get a value of key (e.g. 1730448992271)
    • npx wrangler deploy # Deploy your Worker on the Internet
  • Notes
    • Create (Submit feedback)
      curl --request POST "https://feedback.example.com/submit" \
          --header "Content-Type: application/json" \
          --data '{"message": "This is my feedback!"}'
      
    • Read (Retrieve feedback)
      curl --request GET "https://feedback.example.com/"
      
    • Delete (Delete feedback)
      curl --request DELETE "https://feedback.example.com/delete/1730448251417"
      
    • Because to add a message board feature for collecting user feedback about a product or service.
  • References
    • Artificial intelligence

  • Use Cloudflare Pages

    • vi wrangler.toml
      [[d1_databases]]
      binding = "DB"
      database_name = "products"
      database_id = "<unique-ID-for-your-database>"
      
    • wrangler pages dev . # Develop full-stack Pages application locally
      • --ip 0.0.0.0 # Make it accessible on WLAN
    • wrangler pages deploy . # Deploy project
      • --project-name supermarket # Specify the project name
      • --branch production # To production branch if it works properly
  • Notes
    • Change production name (Optional)
      curl --request PATCH \
        --url https://api.cloudflare.com/client/v4/accounts/YOUR_ACCOUNT_IDENTIFIER_HERE/pages/projects/YOUR_PROJECT_IDENTIFIER_HERE \
        --header 'Content-Type: application/json' \
        --header 'Authorization: Bearer YOUR_API_TOKEN_HERE' \
        --data '{ "production_branch": "YOUR_PRODUCTION_BRANCH_HERE" }'
      
      • Because I use the default (Production) as the production
    • Because to become a full stack developer.
  • References
    • https://github.com/cloudflare/pages-action/issues/63#issuecomment-1680360933
    • https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
    • https://developers.cloudflare.com/workers/wrangler/commands/#pages
    • Artificial intelligence

  • Change wallpaper color in iPhone Shortcuts

    • Get All wallpapers
    • Get Random Item from Wallpapers
    • Switch to Item from List
  • Notes
    • Because to randomize the color of the wallpaper.
      • Make sure add the other three colors of wallpaper (Silver, Gold, Deep purple) before running.
  • References
    • https://libreddit.nohost.network/r/shortcuts/comments/ydd9ir/ios_162_beta_set_wallpaper_photo_you_can_now_set/itu067k/

  • Use Systemd timers

    • doas vi /etc/systemd/system/checkIn.timer
      [Unit]
      Description=Check in
      
      [Timer]
      OnCalendar=12:30
      
      [Install]
      WantedBy=timers.target
      
    • doas vi /etc/systemd/system/checkIn.service
      [Unit]
      Description=Check in
      
      [Service]
      ExecStart=/home/yaoniplan/.config/store/signIn/.venv/bin/python3 /home/yaoniplan/.config/store/signIn/autoSignIn.py
      
  • Notes
    • doas systemctl enable checkIn.timer --now # Enable the timer now
  • References
    • ChatGPT

  • Use "selenium"

    • Imports
      from selenium import webdriver
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.support import expected_conditions as EC
      import time
      
    • Define a function
      def auto_sign_in_and_check_in(driver, username, password):
          # Log in (Update with actual selector)
          username_field = WebDriverWait(driver, 10).until(
              EC.presence_of_element_located((By.CSS_SELECTOR, "#user_login"))
          )
          password_field = driver.find_element(By.CSS_SELECTOR, "#password")
          submit_button = driver.find_element(By.CSS_SELECTOR, "#userlogin-submit")
      
          # Fill in the username and password
          username_field.send_keys(username)
          password_field.send_keys(password)
      
          # Click the submit button
          submit_button.click()
      
          WebDriverWait(driver, 10).until(
              EC.presence_of_element_located((By.CSS_SELECTOR, "i.pps-icon.pps-icon-close-clear")) # Update with actual selector
          )
      
          # Click the pps icon
          pps_icon = driver.find_element(By.CSS_SELECTOR, "i.pps-icon.pps-icon-close-clear") # Update with actual selector
          pps_icon.click()
                  
          # Wait for the page to load after login (Update with actual selector)
          WebDriverWait(driver, 10).until(
              EC.presence_of_element_located((By.CSS_SELECTOR, "div.login_text.mobie a.slide-user-menu"))
          )
      
          # Click the slide user menu (Update with actual selector)
          slide_user_menu = driver.find_element(By.CSS_SELECTOR, "div.login_text.mobie a.slide-user-menu")
          slide_user_menu.click()
      
          # Wait for the page to load after login (Update with actual selector)
          WebDriverWait(driver, 10).until(
              EC.presence_of_element_located((By.CSS_SELECTOR, ".meiriqiandao > span:nth-child(1)"))
          )
      
          # Click the check-in button
          check_in_button = driver.find_element(By.CSS_SELECTOR, ".meiriqiandao > span:nth-child(1)")  # Update with actual selector
          check_in_button.click()
      
    • # Setup WebDriver
      driver = webdriver.Chrome()  # Make sure to have the appropriate WebDriver executable
      
      # Open the login URL (Replace with the actual URL)
      driver.get("https://example.com/login")
      
    • Call the function
      # Update with the actual username and password
      auto_sign_in_and_check_in(driver, "yourUsername", "yourPassword")
      
      # Wait to see the result before closing (adjust as needed)
      time.sleep(5)
      
      # Optionally, close the browser after the task is completed
      driver.quit()
      
  • Notes
    • Because to complete some repetitive but meaningless work. (e.g. check-in)
  • References
    • ChatGPT

  • Use "eval"

    • eval rsync -av "$option" # Handle the variable containing spaces correctly
  • Notes
    • Solve the problem
      yaoniplan@tux ~/.config $ syncFiles.sh store                   
      receiving incremental file list
      rsync: [sender] change_dir "/home/yaoniplan/.config/store /home/yaoniplan" failed: No such file or directory (2)
      
      sent 8 bytes  received 8 bytes  32.00 bytes/sec
      total size is 0  speedup is 0.00
      rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1852) [Receiver=3.3.0]
      rsync: [Receiver] write error: Broken pipe (32)
      yaoniplan@tux ~/.config $
      
  • References
    • ChatGPT

  • Allow others in your WLAN to access the API

    • vim ~/.config/store/serverSideQuery/app.py
      if __name__ == '__main__':
        app.run(debug=True)
      
      • Replace debug=True with host='0.0.0.0', port=5000
  • Notes
    • http://192.168.10.100:5000
  • References
    • ChatGPT

  • Set up a Flask web server

    • Imports
      from flask import Flask, request, jsonify
      import sqlite3
      
    • Create a new Flask web application instance named app
      app = Flask(__name__)
      
    • Function to get a product by barcode
      def get_product_by_barcode(barcode):
          conn = sqlite3.connect('products.db')
          cursor = conn.cursor()
          cursor.execute("SELECT name, price, image_url FROM products WHERE barcode=?", (barcode,))
          product = cursor.fetchone()
          conn.close()
          return product
      
    • Route to search for a product
      @app.route('/search_product', methods=['GET'])
      def search_product():
          barcode = request.args.get('barcode')
          product = get_product_by_barcode(barcode)
          
          if product:
              return jsonify({"name": product[0], "price": product[1], "image_url": product[2]})
          else:
              return jsonify({"error": "Product not found"}), 404
      
    • Application runner
      if __name__ == '__main__':
          app.run(host='0.0.0.0', port=5000)
      
  • Notes
    • Add a new product
      # Function to add a new product
      def add_product(barcode, name, price, image_url):
          conn = sqlite3.connect('products.db')
          cursor = conn.cursor()
          cursor.execute("INSERT INTO products (barcode, name, price, image_url) VALUES (?, ?, ?, ?)", (barcode, name, price, image_url))
          conn.commit()
          conn.close()
      
      # Route to add a new product
      @app.route('/add_product', methods=['POST'])
      def add_product_route():
          data = request.json
          barcode = data.get('barcode')
          name = data.get('name')
          price = data.get('price')
          image_url = data.get('image_url')
          
          # Validate input data
          if not all([barcode, name, price, image_url]):
              return jsonify({"error": "Missing data"}), 400
      
          # Add product to database
          add_product(barcode, name, price, image_url)
          return jsonify({"message": "Product added successfully"}), 201
      
    • Add the new product to the database
      curl --request POST http://192.168.10.100:5000/add_product
          --header "Content-Type: application/json"
          --data '{
              "barcode": "6934567890123",
              "name": "Water",
              "price": 1,
              "image_url": "http://example.com/image.png"
          }'
      
    • Get prodect details
      curl http://192.168.10.100:5000/search_product?barcode=6934567890123
      
  • References
    • ChatGPT

  • Understand product barcode

    • 13 digits
      • International
      • 6934567890123 (Sample in China)
  • Notes
    • Because to build a small cash register software.
  • References
    • ChatGPT

  • Save the browser text as a file in iPhone Shortcuts

    • If Shortcut Input does not have any value
      • Text # Clipboard
    • Otherwise
      • Text # Shortcut Input
    • End If
    • Ask for Text with Enter file name:
    • Set name of If Result to Provided Input
    • Save Renamed Item to Downloads
      • Subpath # Provided Input
    • Open Saved File in Files
  • Notes
    • Open directory where the file is located
      • Open Saved File in Files
    • Because to save text as file.
  • References
    • https://discussions.apple.com/thread/254774502?answerId=258905532022#258905532022

  • Save selection as file in iPhone Shortcuts

    • Text
      • Shortcut Input
    • Ask for Text with Enter file name:
      • Allow Multiple Lines (Disable)
    • Set name of Text to Provided Input
    • Save Renamed Item to Downloads
      • Subpath Provided Input
  • Notes
    • Because it's suitable for some short JSON text.
  • References
    • ChatGPT

  • Save the entire text content of a webpage as file in iPhone Shortcuts

    • var result = []; # Initialize an empty array
    • body = document.body; # Get the entire body of the document
    • Create a selection object and a range object
      sel = window.getSelection();
      range = document.createRange();
      
    • range.selectNodeContents(body); # Select the contents of the body
    • sel.removeAllRanges(); # Clear any existing selections
    • sel.addRange(range); # Add the new range to the selection
    • selString = sel.toString(); # Convert the selected content to a string
    • completion(selString); # Call a function named completion with the selected string
  • Notes
    • Run JavaScript on Web Page (Shortcut Input, paste the code above) - Ask fro Input (Text, Enter file name:, config.json) - Set Name (JavaScript Result, Provided Input) - Save File (Renamed Item, Downloads, Provided Input) - Open File (Saved File, Files)
      • completion(document.body.innerText); # Easier method
      • Set Name # This will change the document type (Used to rename the file name)
    • Because just like saving a file with Ctrl-s in browser.
  • References
    • https://libreddit.nohost.network/r/shortcuts/comments/r22gfe/getting_contents_of_webpage_behind_a_login/hm2mmhq
    • ChatGPT

  • Use "xlsx2csv"

    • xlsx2csv input.xlsx output.csv
  • Notes
    • Because to edit the file simply.
  • References
    • ChatGPT

  • The abbreviation of "Comma-separated values" is "csv"

    • A text file format
      • Use commas to separate values
      • Use newlines to separate records
  • Notes
    • Because to record the information of the goods.
      • Name, price, barcode
  • References
    • https://en.wikipedia.org/wiki/Comma-separated_values

  • Close the keyboard after pressing the Enter key

    • vim ./script.js
      taskInput.addEventListener('keydown', function(event) {
        if (event.key === 'Enter') {
          addTask(taskInput.value);
          taskInput.value = ''; // Clear the input field
          hideInputBox(); // HIde the input box after adding the task
          taskInput.blur(); // Blur the input field to close the keyboard
        }
      })
      
  • Notes
    • blur() # Remove focus
  • References
    • ChatGPT

  • Use "EOF"

    • Write multiple lines text into a new file
      tee ./styles.css << EOF
      # Paste multiple lines text here
      EOF
      
  • Notes
    • << # An operator (Take the text that follows as input)
    • EOF # A delimiter (Between them)
  • References
    • man tee # /append
    • ChatGPT

  • Understand Exodus in the Bible

    • Who
      • Moses (God's agent) and the Israelites
    • Why
      • Lead the Israelites out of slavery in Egypt
    • Result
      • Leave Egypt and approach Canaan
  • Notes
    • Artificial intelligence is like God (Humans on Earth are like Moses)
  • References
    • Please tell me the story of Exodus in the Bible # ChatGPT

  • View system information without third-party tools

    • cat /proc/cpuinfo # CPU information
      • Number of processors
      • Number of CPU cores of the processor
      • Model name
    • cat /proc/version # Kernel version
    • cat /proc/meminfo # Memory information
    • cat /proc/partitions # Disk partitions
    • cat /proc/filesystems # File systems
      • nodev # No device
      • What file system types are currently used by disks
  • Notes
    • Because to view the basic information of a computer.
  • References
    • https://wiki-power.com/%E5%B5%8C%E5%85%A5%E5%BC%8FLinux-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86

  • Use "sheets"

    • =SUM(E2:E126) # Calculate the sum of this range
      • = # Start a formula
  • Notes
    • Because the user experience is better than "excel".
      • Support dark mode
      • Open files faster
      • Simpler user interface
    • Disadvantages
      • No version control feature
  • References
    • https://drive.google.com/drive/home
    • A simple cheat sheet about Google Sheets software # ChatGPT

  • Fetch an icon of a website

    • https://favicone.com/google.com?s=32
  • Notes
    • google.com # Replace it with other domain name of a website
    • s # Size
    • 32 # 32x32 pixels (Clearer)
    • https://api.faviconkit.com/google.com/64 # Another method
  • References
    • ChatGPT

  • If vectors $a=(0,1)$, $b=(2,x)$, $b\perp(b-4a)$, then $x=$

    • $\cos\theta=1$ # The expression ($-\sqrt{2}\cos\theta$) will be the smallest when the value ($\cos\theta$) is the largest
      • The ratio of the adjacent (connected) side to the hypotenuse in a right triangle (Like a point on the unit circle)
    • $|\vec{a}+\vec{b}|=\sqrt{|\vec{a}|^{2}+|\vec{b}|^{2}}$ # Properties of orthogonal (e.g. $\vec{a}\perp\vec{b}$) vectors (Pythagorean theorem)
      • The magnitude of the vector $\vec{a}+\vec{b}$ is the hypotenuse of the right triangle with sides of length $|\vec{a}|$ and $|\vec{b}|$
    • $|\vec{c}|=1$ # A unit vector has a magnitude of 1
      • $\vec{c} \cdot \vec{c}=|\vec{c}| |\vec{c}| \cos\theta$ # Dot product formula
      • $u \cdot v=0$ # Two vectors are perpendicular ($\cos90\degree$) if their dot product is zero
    • $(\vec{a}-\vec{c})\cdot(\vec{b}-\vec{c})=\vec{a} \cdot \vec{b}-\vec{a} \cdot \vec{c}-\vec{c} \cdot \vec{b}+\vec{c} \cdot \vec{c}$ # Distributive property of the dot product
    • $u \cdot v = u_{1}v_{1}+u_{2}v_{2}$ # Vector multiplication
    • $u - v=(u_{1}-v_{1},u_{2}-v_{2})$ # Vector subtraction
  • Notes
    • $4a=4 \cdot (0,1)=(0,4)$ # Each component of the vector is multiplied by scalar (A single number)
    • Express $\overrightarrow{AD}$ in terms of vectors $\vec{b}$ and $\vec{c}$
      • $\overrightarrow{BD}=2\overrightarrow{DC}$ # Point D divides side BC into three equal parts ($BD:DC = 2:1$, $BD=\frac{2}{3}BC$)
      • Vector = scalar + direction
      • $\overrightarrow{AD}=\overrightarrow{AB}+\overrightarrow{BD}$ # Position vector addition
      • $\overrightarrow{BC}=\overrightarrow{AC}-\overrightarrow{AB}$ # Position vector subtraction
  • References
    • If $\vec{a}$ $\vec{b}$ $\vec{c}$ are unit vectors, $\vec{a} \cdot \vec{b}=0$, then the minimum value of $(\vec{a}-\vec{c}) \cdot (\vec{b}-\vec{c})$ is
    • In the $\triangle ABC$, if $\overrightarrow{AB}=\vec{c}$, $\overrightarrow{AC}=\vec{b}$, $\overrightarrow{BD}=2\overrightarrow{DC}$, then $\overrightarrow{AD}=$
    • College Entrance Math in Jiangxi
    • ChatGPT

  • Increase the number in output filenames

    • i=1; for f in *.MOV; do ffmpeg -i "$f" -c:v libx265 -crf 28 -preset slow -c:a aac -b:a 128k 240627checkTheCigarettes${i}.mp4; i=$((i + 1)); done
  • Notes
    • ${} # Reference the value of a variable ($ is ok, but ${} is powerful)
    • $(()) # Perform arithmetic operations (Calculate the value)
    • Because to achieve semi-automation in the shell.
  • References
    • ChatGPT

  • Use "a-shell"

    • help -l # List all installed packages
  • Notes
    • Install yt-dlp
      pip install chardet requests -q --disable-pip-version-check
      pip install yt-dlp -q --disable-pip-version-check -i https://pypi.tuna.tsinghua.edu.cn/simple/
      
    • Because to download a piece of music from YouTube in iPhone.
  • References
    • https://libreddit.eu.org/r/shortcuts/comments/17vgexp/seeking_inspiration_how_do_you_use_ashell_and/k9c13mo/
    • https://github.com/net00-1/SW-DLT/blob/master/src/SW_DLT.py#L80
    • Artificial intelligence

  • The abbreviation of "the first floor" is "1F".

    • B1 # Basement level 1
  • Notes
    • Because to distinguish floors when using map navigation software.
  • References
    • ChatGPT

  • Open a department store in Dongguan City, Guangdong Province, China. (2024-06-30)

    • Don't join other brands
  • Notes
    • The other party may not perform the specific things metioned in the contract
      • Indoor and outdoor cameras must be included
      • The glass door must include a glass frame and a glass fan
      • Air conditioning must be available
      • One-hand payment and one-hand delivery
      • Bulid an artificial intelligence to answer questions about commodity information
    • Provide Free services
      • Hot water (Make hot instand noodles)
    • Business cooperation
      • Find each other
    • Wear seat belts for rear seats in small cars (Impose a fine of RMB 10, deduct 0 points, late payment fee will be RMB 0)
    • Require
      • Awnings (If the sun will hit the product)
      • Shelves
      • Banknote detector
      • Monitor
      • Rice cooker
      • Business license
      • Food business license (Maybe just record it)
      • Health certificate
      • Real estate certificate
      • Lease contract
    • Because to help my cousin's family pay off their debts by providing food services.
  • References
    • http://txjy.syggs.mofcom.gov.cn/ # Enter the brand name in the "特许品牌" to query the company registration information
    • https://www.gov.cn/banshi/2005-08/23/content_25575_2.htm # /第五十一条
    • https://www.gov.cn/banshi/2005-08/23/content_25575_3.htm # /第八十九条
    • https://www.gd.gov.cn/zwgk/wjk/zcfgk/content/post_2531572.html # /第五十五条

  • Use "excel"

    • Ctrl-z # Undo
    • Ctrl-y # Redo
    • Alt-q # Query
    • Use keyboard shortcuts
      • Long press Alt
  • Notes
    • Formulas
      • =M2*0.8 # 20% off price (M: column; 2: row)
    • Because to deal with a .xlsx file.
  • References
    • https://www.office.com/launch/excel

  • Capture a long screenshot

    • Firefox
      • Ctrl-Shift-s # Select a region
    • Chromium
      • Ctrl-Shift-i # Inspect
      • Ctrl-Shift-p # Prompt a command palette
      • screenshot # Type to select 'Capture full size screenshot'
  • Notes
    • Because to share with others.
  • References
    • https://askubuntu.com/questions/1413989/how-do-i-take-a-long-screenshot-in-linux/1414000#1414000

  • Use "sing-box"

    • doas sing-box run -c ~/.config/sing-box/config.json # Replace config.json with your configuration
    • vim ~/.bash_profile
      # Set proxy
      export all_proxy="socks://127.0.0.1:2333"
      export no_proxy="127.0.0.1, localhost, 192.168.10.0/24, 100.65.173.16"
      
      • all_proxy # Both HTTP and HTTPS connections (Sometimes doesn't work, try both http_proxy and https_proxy)
      • 2333 # Search 'listen_port' to get the port
      • 100.65.173.16 # Use no_proxy (Remember to new a terminal to make changes effective)
    • Direct (Do not use a proxy for domains)
      [
        "route": {
          "rules": [
            {
              "domain_suffix": [
                "example.com",
                "example2.com"
              ],
              "outbound": "direct"
            },
            {
              ...
            }
          ]
        }
      ]
      
    • Select a server
      {
        "experimental": {
          "clash_api": {
            "external_controller": "0.0.0.0:9090",
            "secret": ""
          }
        },
      }
      
      • https://clash.razord.top/
      • https://yacd.haishan.me/
  • Notes
    • Install dependencies
      • doas mv sing-box-1.10.0-alpha.16-linux-amd64/sing-box /usr/local/bin/sing-box # Install dependencies
      • nix profile install nixpkgs#sing-box # Another method
    • Solve the problem
      FATAL[0000] start service: initialize inbound/tun[0]: configure tun interface: operation not permitted
      
      • doas sing-box run -c ~/.config/sing-box/config.json # Add permission
    • Because to use a faster proxy tool.
  • References
    • https://gist.github.com/yangchuansheng/5182974442015feeeeb058de543a00fd#file-gistfile1-txt-L245
    • https://forum.qubes-os.org/t/how-to-bypass-the-gfw-on-qubes-os-when-youre-in-china-qubes-os/14957
    • https://libreddit.nohost.network/r/archlinux/comments/17v2ajb/singbox_proxy_drive_me_crazy/

  • Use "ffprobe"

    • ffprobe yourVideoFile.mp4
      • -show_streams # Show streams (e.g. video, audio)
  • Notes
    • Because to get video and audio information.
      • (e.g. Duration, bitrate, video codec, resolution, audio codec, etc.)
  • References
    • ChatGPT

  • Display the help message and exit if no arguments are provide

    • vim ~/.local/bin/getInformation.sh
      # If the number of arguments is equal to zero
      if [ "$#" -eq 0 ]; then
          echo "Usage: $(basename $0) <arg1> <arg2> ..."
          exit 1
      fi
      
  • Notes
    • Because to make the Shell script more user-friendly.
  • References
    • ChatGPT

  • Use "nvim"

    • nix run github:jordanisaacs/neovim-flake
  • Notes
    • Ctrl-^ # Switch to next tab in normal mode (file)
    • "+y # Copy text into clipboard
      • " # Specify the register
      • + # System clipboard register
      • y # Yank (Copy)
    • vim ~/.config/nvim/init.lua # Manage plugins using built-in package manager
      -- Call their setup function
      require('noice').setup()
      
      • git clone https://github.com/folke/noice.nvim ~/.config/nvim/pack/vendor/start/noice.nvim # Install a plugin (e.g. nui.nvim)
    • Warning: It takes a long time to download and bulid the first time.
    • Because to try to use nvim.
  • References
    • https://programmingpercy.tech/blog/learn-how-to-use-neovim-as-ide/#enabling-language-server-protocolsupport
    • https://github.com/rcallaby/Learn-Vim-and-NeoVim/blob/main/Lessons/Part-14-Using-Lua-In-NeoVIM/usingLua.md#loading-the-plugin
    • https://www.youtube.com/watch?v=O-VcTY0umMc
    • https://github.com/jordanisaacs/neovim-flake#documentation
    • ChatGPT

  • Use "matplotlib"

    • python # Import dependencies
      import matplotlib.pyplot as plt
      import numpy as np
      
      • matplotlib.pyplot # The pyplot module from the matlotlib library
      • as # Alias
      • plt # For plotting
      • numpy # The library
      • np # For numerical operations
    • python # Save and close
      plt.savefig('function.svg', format='svg', transparent=True)
      plt.close()
      
      • savefig('...', ...) # Save the current figure as an image file
      • format='svg' # Set image format to SVG
      • transparent=True # Set image background to transparent
  • Notes
    • Define functions and variables
      def f(x):
        return np.sqrt(x * (x - 1)) + np.sqrt(x)
      x = np.linspace(-0.5, 2, 400)
      y = np.zeros_like(x)
      valid_indices = (x >= 0) & (x >= 1) | (x == 0)
      y[valid_indices] = f(x[valid_indices])
      
      • linspace() # Generate a linearly spaced array of numbers
      • -0.5 # Starting point of the sequence
      • 2 # Ending point of the sequence
      • 400 # The number of points between them
      • zeros_like(x) # The same shape as x filled with zeros
      • & # And
      • | # Or
      • == # Equal to
    • Set the curve
      plt.figure(figsize=(10, 6), facecolor='none')
      plt.style.use('dark_background')
      plt.plot(x, y, label='$f(x) = \sqrt{x(x-1)} + \sqrt{x}$', color='yellow')
      
      • figsize=(10, 6) # Set figure size to 10x6 inches
      • facecolor='none' # Set facecolor to transparent
      • style.use('dark_background') # Set dark background style
      • plot.(x, y) # Plot the function
      • label='$f(x) = ...$' # Display a mathematical expression in LaTex syntax
    • Set the axes
      plt.axhline(0, color='white', linewidth=0.5)
      plt.axvline(0, color='white', linewidth=0.5)
      
      • ax # Axes
      • h # Horizontal (v: Vertical)
      • 0 # Coordinate
      • 0.5 # Units
    • Set auxiliary markers
      plt.grid(color='gray', linestyle='--', linewidth=0.5)
      plt.title('Plot of $f(x) = \sqrt{x(x-1)} + \sqrt{x}$', color='white')
      plt.xlabel('x', color='white')
      plt.ylabel('f(x)', color='white')
      plt.ylim(-0.5, 2.5)
      
      • $...$ # Display a mathematical expression in LaTex syntax
      • -- # Dashed lines
      • xlabel # Set the label for the x-axis
      • ylabel # Set the y-axis label
      • ylim(-0.5, 2.5) # Set the y-axis limits from -0.5 to 2.5
    • Set label and legend
      plt.fill_between(x, y, where=valid_indices, color='brown', alpha=0.5, label='Valid domain')
      plt.legend(loc='upper left')
      
      • fill_between(x, y, ...) # Fill the area between the curve defined by x and y
      • label='Valid domain' # Display the label in the plot legend
      • plt.legend() # Adjust the position of the legend
      • loc='upper left' # Move the position of the legend to upper left corner
      • From default lower right corner
    • Because to plot graphs of mathematical functions.
  • References
    • https://mathpretty.com/13603.html
    • ChatGPT

  • Use "library"

    • library listen ~/classical_music.tl.db
  • Notes
    • library next # Playback next
    • --random # Playback shuffle
    • pipx install xklb # Install dependencies
    • Because to listen to classical music.
  • References
    • https://github.com/chapmanjacobd/library/tree/main/example_dbs # classical_music.tl.db
    • https://github.com/chapmanjacobd/library#examples
    • library listen --help

  • Use "sqlite"

    • python # Create a connection
      import sqlite3
      connection = sqlite3.connect("aquarium.db")
      cursor = connection.cursor()
      
      • connection # Variable (e.g. cursor, etc.)
      • sqlite3.connect("") # Connect to (Or create) the database
      • aquarium.db # Database name
    • python # Close the connection
      cursor.close()
      connection.close()
      
      • close() # Close the connection (e.g. connection)
  • Notes
    • Create
      cursor.execute("CREATE TABLE fish (name TEXT, species TEXT, tank_number INTEGER)")
      cursor.execute("INSERT INTO fish VALUES ('Sammy', 'shark', 1)")
      cursor.execute("INSERT INTO fish VALUES ('Jamie', 'cuttlefish', 7)")
      connection.commit()
      
      • execute("") # Execute a SQL command
      • "CREATE TABLE ... ()" # Create a table
      • fish # Table name
      • name # Column name (e.g. species, tank_number)
      • TEXT # Type name (e.g. INTEGER)
      • "INSERT INTO ... VALUES ('...', '...', ...)" # Insert a row into the table
      • Sammy # Insert the value into the first column (e.g. name)
      • commit() # Commit (Or save) changes to the database
    • Read
      rows = cursor.execute("SELECT name, species, tank_number FROM fish").fetchall()
      print(rows)
      
      • "SELECT ..., ..., ... FROM ..." # Select columns from the table
      • fetchall() # Retrieve all remaining rows of the query result as a list ([]) of tuples (())
    • Update
      new_tank_number = 2
      moved_fish_name = "Sammy"
      cursor.execute(
        "UPDATE fish SET tank_number = ? WHERE name = ?",
        (new_tank_number, moved_fish_name)
      )
      connection.commit()
      
      • "UPDATE ... SET ... = ? WHERE ... = ?", (..., ...) # Update a value in the row of the table
      • ? # Placeholder
    • Delete
      released_fish_name = "Sammy"
      cursor.execute(
        "DELETE FROM fish WHERE name = ?",
        (released_fish_name,)
      )
      connection.commit()
      
      • "DELETE FROM ... WHERE ... = ?", (...,) # Delete a row in the table
    • Because to use a database to store data.
    • Use SQLite command line
      • sqlite3 products.db .dump > products.sql # Generate the SQL dump
      • sqlite3 products.db 'SELECT * FROM products;' # Execute a SQL statement
      • sqlite3 products.db # Interact with the database
      • .tables # Get tables (In an interactive shell)
      • SELECT * FROM products; # Select all entries from a table
      • nix profile install nixpkgs#sqlite # Install dependencies
      • Because to show it quickly temporarily.
  • References
    • https://mathpretty.com/16311.html
    • tldr sqlite3
    • ChatGPT

  • Calculate the square root of a number in Python interpreter

    • python # Use math module
      import math
      print(math.sqrt(25))
      
      • math # Built-in module
      • sqrt # Function
      • 25 # Argument
    • python # Use ** operator
      print(25 ** 0.5)
      
      • ** # Exponentiation operator
  • Notes
    • Because to verify that $\sqrt{}$ is the principal square root function which outputs non-negative value.
  • References
    • https://libreddit.tux.pizza/r/learnmath/comments/10oebmz/is_square_root_always_a_positive_number/j6f3aqc
    • 2024-06-11-104608.png
    • ChatGPT

  • The domain of the function $y=\sqrt{x(x-1)}+\sqrt{x}$ is

    • Square root
      • Every nonnegative real number $x$ has a unique nonnegative square root
  • Notes
    • $x(x-1)\ge0$ ($x=0$ and $x=1$) # $x\le0$ or $x\ge1$
      • If $x<0$, then $x$ is negative and $x-1$ is negative, so $x(x-1)$ is positive
      • If $0<x<1$, then $x$ is positive and $x-1$ is negative, so $x(x-1)$ is negative
      • If $x>1$, then $x$ is positive and $x-1$ is positive, so $x(x-1)$ is positive
    • $x\ge0$
  • References
    • 2024-06-11-120020.svg
    • https://en.wikipedia.org/wiki/Domain_of_a_function#/media/File:Square_root_0_25.svg
    • https://en.wikipedia.org/wiki/Square_root
    • College Entrance Math in Jiangxi
    • ChatGPT

  • Model the Sudoku Game

    • Horizontal Blocks using TMB
      • Top, Middle, Bottom
  • Notes
    • Because to teach niece about problem-solving skills in Sudoku.
  • References
    • 2024-06-06-124844.jpeg
    • https://www.youtube.com/watch?v=URHZiLu1-LI

  • Tie a knot for the pants belt

    • Left
      • Ampersand (&)
    • Right
      • Form a loop
      • Pass through the first circle
      • Wrap the second circle
  • Notes
    • Because there is no need to tie and untie knots when go to the toilet. (except for the first)
      • Pull everything tight
  • References
    • https://www.youtube.com/watch?v=3R0Lp86GEBk

  • Select next match in Bash

    • Ctrl-i # Get two or more matching results (The same as Tab)
      • Ctrl-n # Next
  • Notes
    • Because to autocomplete file name without copying and typing manually.
  • References
    • 2024-06-04-092505.png

  • The abbreviation of "Web Distributed Authoring and Versioning" is "WebDAV".

    • A set of extensions
      • Hyprtext Transfer Protocol
  • Notes
    • Because to interact with data.
      • Upload files from local to remote
      • Synchronize personal account data by logging in
      • Share with the open source world
  • References
    • https://en.wikipedia.org/wiki/WebDAV

  • Use "webdav"

    • curl --user "admin:***" --upload-file "/mnt/grow/image/2024-06-04-171256.png" "http://192.168.10.100:5244/dav/$filePath/"
  • Notes
    • admin:*** # Replace it with your username and password
    • --upload-file "/mnt/grow/image/2024-06-04-171256.png" # Replace it with --request <method>
      • MKCOL # Make collection (folder)
      • DELETE # Delete a folder (file)
      • PROPFIND # Properties find (Metadata: name, size, creation date, modification date, etc.)
    • Solve the problem by encoding special characters (e.g. spaces, Chinese characters, etc.)
      curl: (3) URL rejected: Malformed input to a URL function
      
      • node -e 'console.log(require("querystring").escape("《新闻联播》 20240602.m4a"));' # Evaluate
      • python -c "import urllib.parse; print(urllib.parse.quote('《新闻联播》 20240602.m4a'))" # Command
      • python -c "import urllib.parse; print(urllib.parse.unquote('6934502301850%3A2%2C6911988023520%3A1%2C6901028118170%3A1%2C6902538004045%3A1%2C6901754220802%3A1'))" # Decode
      • Percent followed by two hexadecimal digits (e.g. %E3%80%8A is 《, %20 is Space)
  • References
    • https://gist.github.com/stokito/cf82ce965718ce87f36b78f7501d7940
    • man curl # /^\s*-T
      • ^ # Beginning of a line
      • \s # Space (Or )
      • * # Zero or more
      • -T # Replace it with other literal string (e.g. -u)

  • Use "h-m-m"

    • h-m-m
  • Notes
    • Warnings:
      • Configuration files sometimes do not take effect
      • CJK (Chinese, Japanese, and Korean) fonts can cause typesetting disorder
    • vim ~/.config/h-m-m/h-m-m.conf
      auto_save = true # Prevent accidental exits
      
    • s # Save
      • q # Quit (Q: Without saving)
    • Space # Toggle (Between collapse and expand)
    • o # Create a sibling node (Child node: O)
      • sibling # Type your words
      • Ctrl-w # Delete a word
      • Ctrl-c # Cancel (The current operation) Or Ctrl-[
      • e # Edit (Current node)
    • d # Delete (Current node)
      • u # Undo
    • S # Rename (Current file)
    • / # Search
      • b # Expand all (Opposite: v)
      • n # Next (Opposite: N)
    • yay --sync h-m-m-git # Install dependencies
    • Because to use a mind map tool in the terminal.
  • References
    • https://github.com/nadrad/h-m-m#default-key-bindings

  • Enable trash feature for files on Linux

    • vi ~/.bashrc
      alias rm='mv --target-directory=$HOME/.trash/'
      
      • source ~/.bashrc # Make changes effective
  • Notes
    • Warning: Delete files may result in data loss. (Unless you are an adventurer)
    • mkdir ~/.trash/ # Make the directory if no such directory
    • doas crontab -e # Enable scheduled deletion using root user (Solve permission denied problem)
      00 18 * * * /home/yaoniplan/.local/bin/cleanTrash.sh
      
      • vim ~/.local/bin/cleanTrash.sh
        #!/usr/bin/env sh
        
        # Set variables
        trashDir="/home/yaoniplan/.trash"
        
        # Delete files and directories older than 30 days
        find "$trashDir" -mindepth 1 -ctime +30 -delete
        
      • chmod +x ~/.local/bin/cleanTrash.sh # Change executable mode
    • \rm -rf ~/Downloads/trash # Unalias to delete (Solve directory not empty problem)
    • Because people in a forum mentioned this requirement.
  • References
    • man mv # /-t
    • ChatGPT

  • The abbreviation of "File Transfer Protocol" is "FTP"

    • Communication
  • Notes
    • Because to transfer files from a server to another.
  • References
    • https://en.wikipedia.org/wiki/File_Transfer_Protocol

  • Use "basename"

    • basename "$(swww query | sed --silent 's/.*image: //p')"
  • Notes
    • basename /mnt/grow/temporary/storeDiary/*.png .png # Get filename without the extension
    • Because to get current wallpaper name in script.
  • References
    • Artificial intelligence

  • The abbreviation of "scalable vector graphics" is "svg"

    • An image format
  • Notes
    • Because clearer than pictures in other formats. (e.g. GIF, PNG, etc.)
  • References
    • https://en.wikipedia.org/wiki/SVG#/media/File:Bitmap_VS_SVG.svg

  • Use "inkscape"

    • t # Text
    • Fn-1 # Adjust position
      • upArrow # Move up
  • Notes
    • Other - Icon 32x32 - New Document - Save as favicon.svg
    • vim ~/note/assets/index.html
      <head>
        <link rel="icon" type="image/svg+xml" href="../assets/favicon.svg">
      </head>
      
    • nix profile install nixpkgs#inkscape # Install dependencies
    • Because to create an SVG favicon for a website.
  • References
    • ChatGPT

  • Use "dioxionary"

    • dioxionary --read-aloud --online Jesus
  • Notes
    • dioxionary list # List all queried words
  • References
    • dioxionary --help
    • https://github.com/vaaandark/dioxionary/releases

  • Use "ftp"

    • doas systemctl enable vsftpd --now # Enable the daemon now
  • Notes
    • Other clients
      192.168.10.100 # Server
      /grow # Path (Optional)
      
    • doas vim /etc/vsftpd.conf
      # Set default directory for anonymous users
      anon_root=/mnt
      
      • doas systemctl restart vsftpd # Restart to make it effective after editing configuration file
    • doas pacman --sync vsftpd # Install dependencies
    • Because to use FTP in software that does not support SFTP.
  • References
    • https://wiki.gentoo.org/wiki/Vsftpd#Anonymous_read_access
    • man 5 vsftpd.conf # /anon_root
    • man vsftpd # /^file

  • Use "sdcv"

    • sdcv Linux
  • Notes
    • Download dictionary files
      • https://github.com/skywind3000/ECDICT/releases
      • https://web.archive.org/web/20140428004049/http://abloz.com/huzheng/stardict-dic/misc/
      • https://github.com/BoboTiG/ebook-reader-dict/blob/master/docs/en/README.md#downloads
    • Install downloaded dictionaries
      • doas tar --bzip2 -xf stardict-xfardic-gnu-linux-2.4.2.tar.bz2 -C /usr/share/stardict/dic/ # Extract '.tar.bz2'
      • doas unzip dict-en-en.zip -d /usr/share/stardict/dic/dict-en-en/ # Extract '.zip'
    • nix profile install nixpkgs#sdcv # Install dependencies
  • References
    • sdcv # StarDict console version
    • man sdcv # /^file
    • https://askubuntu.com/questions/191125/is-there-an-offline-command-line-dictionary/191268#191268

  • Use "dict"

    • dict subject
  • Notes
    • Solve the problem
      'dict.conf' doesn't specify any dict server
      
      • vim /etc/dict.conf # Use online dictionaries
        server dict.org
        
    • Because to learn how to pronounce a word and how to use it.
      • International Phonetic Alphabet
      • Make a sentence
    • nix profile install nixpkgs#dict # Install dependencies
  • References
    • https://wiki.gentoo.org/wiki/Dictd#Server_configuration
    • man dict # /^config /^file

  • Use "nmap"

    • nmap 192.168.10.0/24 # Scan all IP addresses (From 192.168.10.0 to 192.168.10.255)
    • nmap -sT -p- 192.168.10.100
      • -sT # Scan TCP connect
      • -p- # Port (From 1 to 65535)
  • Notes
    • Because to scan all ports of an IP address.
    • nix profile install nixpkgs#nmap # Install dependencies
  • References
    • man nmap # /-sT /-p-
    • ChatGPT

  • Use "cut"

    • brightnessctl --machine-readable | cut --delimiter=',' --fields='4'
  • Notes
    • Because to get the current brightness level percentage.
  • References
    • https://github.com/Hummer12007/brightnessctl/issues/55#issuecomment-732945350
    • man cut # /-d

  • Use "tr"

    • brightnessctl --machine-readable | cut --delimiter=',' --fields='4' | tr --delete '%' # Delete a percentage character
    • echo $XDG_DATA_DIRS | tr ':' '\n' # Replace colons with newlines
      • echo $XDG_DATA_DIRS | sed 's/:/\n/g' # Another method
  • Notes
    • Because to make the output human-readable.
  • References
    • ChatGPT

  • Use "subfinder"

    • subfinder -domain yaoniplan.eu.org
  • Notes
    • Other methods (e.g. enumerate DNS, etc.)
      • pipx install sublist3r # Install dependencies
      • sublist3r --domain yaoniplan.eu.org
    • Warnings: Cannot find the latest subdomain names on April 25, 2024.
    • nix profile install nixpkgs#subfinder # Install dependencies
    • Because to find all subdomain names of a domain name.
  • References
    • tldr subfinder

  • Use "epr"

    • epr yourBook.epub
  • Notes
    • Disadvantages
      • Code indentation is incorrect (epy)
    • m # Metadata
    • l # Next screen (Opposite: h)
    • t # Table of contents
    • ? # Help page
    • nix profile install nixpkgs#epr # Install dependencies
    • pipx install epy-reader # Install dependencies
  • References
    • https://github.com/wustho/epr#installation

  • Use "baca"

    • baca yourBook.epub
  • Notes
    • yay --sync baca-ereader-git # Install dependencies
  • References
    • https://github.com/wustho/baca#installation

  • Use "bk"

    • bk yourBook.epub
  • Notes
    • nix profile install nixpkgs#bk # Install dependencies
  • References
    • https://github.com/aeosynth/bk#comparison

  • Use "arianna"

    • org.kde.arianna
  • Notes
    • l # Next screen (Opposite: h)
    • flatpak install arianna # Install dependencies

  • Use "bookworm"

    • /nix/store/phxpkf9ia91k58q00niavhi8w1k4fdr1-bookworm-unstable-2022-01-09/bin/com.github.babluboy.bookworm
  • Notes
    • Ctrl-l # Library
    • Ctrl-+ # Zoom in (Opposite: Ctrl--)
    • Space # Next screen (Opposite: Shift-Space)
    • nix profile install nixpkgs#bookworm # Install dependencies
  • References
    • https://github.com/babluboy/bookworm#screenshots

  • Use "koreader"

    • rocks.koreader.KOReader
  • Notes
    • Delete a file
      • 0 # Go to the end of book
      • RightArrow # Select delete button
    • PageDown # Next list (Opposite: PageUp)
    • DownArrow # Next screen (Opposite: UpArrow)
    • t # Table of contents
    • flatpak install rocks.koreader.KOReader # Install dependencies
  • References
    • https://koreader.rocks/user_guide/#keyboardshortcuts
    • https://github.com/koreader/koreader/wiki/Installation-on-desktop-linux#flatpak # AppImage version can access the network (e.g. WebDAV)

  • Use "zellij"

    • Ctrl-p d # Split the terminal down to new a pane (Pane down)
      • Alt-n # New a pane
      • Alt-k # Move focus (Vim-like)
      • Alt-[ # Toggle layout
    • Ctrl-p e # Embed the pane in the middle or right of the tab
      • Ctrl-p w # Toggle floating pane
    • Ctrl-t n # New a tab
      • Ctrl-t 1 # Go to tab 1 (Or h/l)
  • Notes
    • vim ~/.config/zellij/config.kdl
      keybinds {
          unbind "Ctrl h" // unbind in all modes (To recover Backspace key)
      }
      
    • nix profile install nixpkgs#zellij # Install dependencies
  • References
    • https://github.com/zellij-org/zellij/discussions/2832#discussioncomment-7167742 # Toggle layout
    • https://zellij.dev/documentation/keybindings-binding.html#overriding-keys
    • https://zellij.dev/tutorials/basic-functionality/

  • The abbreviation of "International Phonetic Alphabet" is "IPA"

    • /ˌɪnfərˈmeɪʃən/
      • /ˌ/ # Secondary stress
      • /ˈ/ # Primary stress
  • Notes
    • Because to understand the stress part of a word.
  • References
    • Tell me the International Phonetic Alphabet of word 'information' # ChatGPT

  • Use "distrobox"

    • distrobox create --image debian:latest --name debian-distrobox # Create a container
      • debian # Replace it with other Linux distribution (e.g. gentoo/stage3)
    • distrobox enter debian-distrobox # Enter a container
      • distrobox list # Get container name
    • distrobox rm debian-distrobox # Remove a container
      • rm # Replace it with stop to stop it before removing if container is running
    • distrobox-export --bin /usr/bin/st --export-path ~/.local/bin/ # Export an application
      • Append -delete to the end of the line to delete the exported application
  • Notes
    • nix profile install nixpkgs#distrobox # Install dependencies
  • References
    • 2024-04-16-230933.png
    • man distrobox-export # /examples
      • Replace export with other action (e.g. create)

  • Use "imv"

    • imv -r /mnt/yaoniplan/chinaTelecom/2024/04/
      • i # Zoom in (Opposite: o)
      • a # Actual size (Restore original size)
      • r # Reset zoom and pan
      • h/j/k/l # Vim-like (Pan pictures)
      • ] # Next picture (Opposite: [)
      • p # Print image path (Need to configure it in the configuration file)
  • Notes
    • imv - < <(wl-paste --type image/png) # View an image from clipboard
      • - # Read from standard input
      • < # Redirect the contents
      • <() # Create a temporary file
      • curl -sL "$(wl-paste)" | imv - # Another method if can only copy the image address
    • Warning: Does not support web images in jpeg format. (But "feh" is OK)
      • imv https://alist.yaoniplan.eu.org/d/chinaTelecom/2024/03/26/6601c9e4474e8.jpeg
      • https://libreddit.northboot.xyz/r/swaywm/comments/fpovat/what_image_viewer_is_recommended_for_sway_use/
    • vim ~/.config/imv/config # Configure as needed
      [binds]
      # Copy path of current image to clipboard
      y = exec wl-copy "$imv_current_file"
      # Send a notification (e.g. /home/yaoniplan/.trash/2024-06-04-091824.png)
      p = exec notify-send "$imv_current_file"
      # Delete current image and quit
      <Shift+D> = exec rm "$imv_current_file"; quit
      
      • ; # Execute in order (e.g. Copy path and then send a notification)
    • doas pacman --sync imv # Install dependencies
    • Because to view pictures on Wayland.
  • References
    • https://github.com/kuhy/.dotfiles/blob/master/image/imv.org # /notify
    • less /etc/imv_config # /current
    • man imv # /binds$ /^config

  • Use "tdrop"

    • WAYLAND_DISPLAY=no tdrop -mta wayst --app-id wayst1
  • Notes
    • vim ~/.config/hypr/hyprland.conf
      # Make the window float if the window is not floating
      windowrulev2 = float, class:^(wayst1)$
      # Bind a global shortcut key to show and hide the window
      bind = $mainMod, W, exec, WAYLAND_DISPLAY=no tdrop -mta wayst --app-id wayst1
      
    • nix profile install nixpkgs#tdrop # Install dependencies
    • Because to use the drop-down terminal on Wayland.
  • References
    • https://libreddit.nohost.network/r/hyprland/comments/16acbgy/how_to_reduce_this_window_size_in_hyprland/ # /float
    • https://github.com/noctuid/tdrop#wayland-support

  • Use "hdrop"

    • vim ~/.config/hypr/hyprland.conf
      bind = $mainMod, Space, exec hdrop --floating kitty --class kitty1
      
  • Notes
    • nix profile install nixpkgs#hdrop # Install dependencies
    • Because to use the drop-down terminal on Wayland.
  • References
    • https://github.com/Schweber/hdrop#example-bindings-in-hyprland-config

  • Use "kickoff"

    • kickoff
  • Notes
    • Warning: Some custom keys don't work
      • ctrl+shift+v
    • vim ~/.config/kickoff/config.toml # Customize
      [keybindings]
      execute = ["ctrl+m"]
      delete = ["ctrl+h"]
      delete_word = ["ctrl+w"]
      complete = ["ctrl+i"]
      # Support `ctrl+[` to exit
      exit = ["ctrl+bracketleft"]
      
    • nix profile install nixpkgs#kickoff # Install dependencies
  • References
    • https://github.com/j0ru/kickoff/blob/main/assets/default_config.toml

  • The abbreviation of "HTTP Live Steaming" is "HLS".

    • An adaptive bitrate streaming protocol
  • Notes
    • Split video content into smaller segments
    • Create a playlist file (e.g. playlist2160p.m3u8) containing the URLs for these segments
    • Choose adaptive bitrates and resolutions based on bandwidth and device
    • Deliver over HTTP(S) protocols (Compatible with web infrastructure)
  • References
    • https://en.wikipedia.org/wiki/HTTP_Live_Streaming
    • ChatGPT

  • Use "wofi"

    • wofi --show dmenu # Interact with user via script
      selected_option=$(echo -e "full\nactive\nselect" | wofi --show dmenu)
      
  • Notes
    • vim ~/.config/wofi/style.css
      window {
          font-size: 28px;
      }
      
    • vim ~/.config/wofi/config
      # Like `wofi --show run` by default
      show=run
      
    • Because that "tofi" software seems to be no longer maintained.
  • References
    • https://www.youtube.com/watch?v=KfOYXvRMcIQ # Beautify it using CSS
    • man 5 wofi # /CSS SELECTOR
    • man 7 wofi # /^mode

  • Use "date"

    • date +%s # Seconds since the Epoch (1970-01-01 00:00 UTC)
      • (e.g. 1712921641)
    • date --date=@1707053016 # Convert Unix timestamp to human readable time
      • (Sun Feb 4 09:23:36 PM CST 2024)
  • Notes
    • +%s%3N # In milliseconds
      • 3 # The first three digits
      • N # Nanoseconds
    • +"%Y-%m-%dT%H:%M:%SZ" # Append to the end
      • (2024-02-04T21:23:36Z)
    • Other methods
      • perl -le 'print scalar localtime(1707053016)'
      • python -c "import datetime; print(datetime.datetime.fromtimestamp(1707053016))"
      • awk 'BEGIN { print strftime("%c", 1707053016) }'
    • Because to generate UNIX timestamp.
  • References
    • man date # /%s /-d
    • Artificial intelligence

  • Use "okular"

    • okular
  • Notes
    • Disadvantages
      • The operation is too complicated
      • The page turning animation delay is too long
    • nix shell nixpkgs#okular # Install dependencies

  • Use "xpdf"

    • nix shell nixpkgs#xpdf # The software is marked as unsafe
      ...
      error: Package ‘xpdf-4.05’ in /nix/store/bjv2qk3gg1iv69rbama3q9aprcp6d9wp-source/pkgs/applications/misc/xpdf/default.nix:61 is marked as insecure, refusing to evaluate.
      ...
      

  • Get the full path of a file

    • realpath msyh.ttc | wl-copy # Copy the full path to clipboard
  • Notes
    • Because to upload a file to remote machine via script.
  • References
    • ChatGPT

  • Resize Linux swap partition

    • doas fdisk /dev/sda
      • m # Print the memu
      • p # Print all partitions
      • e # Resize a partition (e.g. 2)
      • n # New a partition (e.g. 3)
      • t # Change a partition type (e.g. swap)
      • w # Write to disk
    • doas mkswap /dev/sda3 # Format the new swap partition
    • doas swapon /dev/sda3 # Activate it
  • Notes
    • Warning: Manipulate hard disk partitions may result in data loss. (Unless you are an adventurer)
    • Solve the problem about 'BTRFS error ... device total_bytes should be at most ...'
      btrfs rescue fix-device-size /dev/sda2
      
    • Because to solve the [ERROR]: Out of memory, exiting. problem.
  • References
    • https://mtekk.us/archives/guides/fixing-the-btrfs-block-device-size-is-smaller-than-total_bytes-in-device-item-error/
    • https://unix.stackexchange.com/questions/224156/how-to-safely-turn-off-swap-permanently-and-reclaim-the-space-on-debian-jessie/224239#224239
    • ChatGPT

  • Use "qpdfview"

    • qpdfview yourBook.pdf
  • Notes
    • Warnings: Could not load plug-in for file type 'EPUB'
      qt.qpa.wayland: EGL not available
      
    • Ctrl-f # Find text
    • Ctrl-Shift-t # Tool bar
    • Ctrl-Shift-m # Menu bar
    • Ctrl-i # Invert color (Dark mode)
    • nix profile install nixpkgs#qpdfview # Install dependencies
  • References
    • In 'Shortcuts' of 'Settings' of 'Edit'

  • Use "evince"

    • evince yourBook.pdf
  • Notes
    • Warnings: Unable to open document "file:///path/to/book.epub".
      File type Electronic book document (application/epub+zip) is not supported
      
    • Ctrl-i # Invert color (Dark mode)
    • nix profile install nixpkgs#evince # Install dependencies
  • References
    • In 'Keyboard Shortcuts' of 'File options'

  • Understand "RX" and "TX"

    • RX # Reception (Download)
    • TX # Transmission (Upload)
  • Notes
    • Because see it when using "btm".
  • References
    • 2024-04-14-014830.png
    • ChatGPT

  • Use "sioyek"

    • Shift-o # Open previous book (e.g. tutorial.pdf)
    • + # Zoom in (Opposite: -)
    • :dark # Toggle dark mode
    • :number # Jump to page by page number
      • t # Table of contents (Better method)
    • q/j/k/gg/G/ma/ # Vim-like
    • Space # Scroll pages (Opposite: Shift-Space)
  • Notes
    • vim ~/.config/sioyek/prefs_user.config
      # Set fonts for epub
      epub_css *{font-family: sans-serif;}
      # Set dark mode by default
      default_dark_mode 1
      
    • yay --sync sioyek-git # Install dependencies (Maybe it does not release any more new versions)
  • References
    • https://github.com/ahrm/sioyek/issues/706#issuecomment-1910112060 # font
    • https://sioyek-documentation.readthedocs.io/en/latest/configuration.html
    • https://github.com/ahrm/sioyek/releases # Extract portable.zip to get AppImage version
    • https://github.com/ahrm/sioyek/blob/main/tutorial.pdf
    • https://sioyek-documentation.readthedocs.io/en/latest/

  • Use "mupdf"

    • mupdf -I yourBook.epub
  • Notes
    • Zoom in
      • Z # Zoom fit
      • W # Width
      • + # Zoom in
    • -I # Invert colors (Dark mode)
      • Shift-i # Toggle
    • doas pacman --sync mupdf # Install dependencies
  • References
    • https://libreddit.northboot.xyz/r/linuxquestions/comments/mr8k85/is_there_a_good_dark_mode_pdf_reader_one_with/
    • man mupdf # /binding

  • Use "zathura"

    • zathura yourBook.pdf
  • Notes
    • Use slideshow
      git clone https://github.com/crvdgc/latex-beamer-flake
      cd latext-beamer-flake && rm -rf .git && git init
      git add . && nix build
      
      • vim ./slides.md # Write slides
      • nix build # Bulid slides
      • zathura ./result/latex-beamer-demo.pdf # View slides
      • Ctrl-n # Hide statusbar
      • Space/Shift-Space # Scroll pages
      • g # Go to the top (Opposite: G)
      • ma # Mark (Return mark: 'a)
    • / # Search
    • Tab # Table of contents
    • vim ~/.config/zathura/zathurarc
      map i recolor
      set recolor-darkcolor "#B0B002"
      
      • i # Press i to enable dark mode
    • a/s # Adjust window
      • + # Zoom in (Opposite: -)
    • j/k/q # Vim-like
    • nix profile install nixpkgs#zathura # Install dependencies
  • References
    • https://github.com/crvdgc/latex-beamer-flake#usage
    • https://github.com/pwmt/zathura/issues/103#issuecomment-2086835877 # /slide
    • https://libreddit.kavin.rocks/r/linuxmasterrace/comments/y12t6s/can_someone_point_me_to_a_good_pdf_viewer/ # /recolor
    • man zathura # binding

  • Understand a ".m3u" file

    • vi ~/playlist.m3u
      #EXTM3U
      #EXTINF:-1 tvg-name="LoveNrture" group-title="•4K",Love Nrture 4K「自然」
      https://d18dyiwu97wm6q.cloudfront.net/playlist2160p.m3u8
      
  • Notes
    • EXT # Extended
    • INF # Information
    • -1 # Indefinite (Unknown duration)
    • group-title # Category
    • Love Nrture 4K「自然」 # Name
  • References
    • https://github.com/YanG-1989/m3u/blob/main/Gather.m3u
    • ChatGPT

  • Use "hyprctl"

    • hyprctl version # Get version of Hyprland
    • hyprctl activewindow # Get geometry of current window
    • hyprctl dispatch exit # Exit hyprland
    • hyprctl dispatch movetoworkspace "1,address:0x583b23a8c460" # Fix window disappearing bug
      • hyprctl clients -j # Get address (e.g. 0x583b23a8c460)
    • hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"'
      • e.g. 690,22 654x355
  • Notes
    • -j # JSON
    • \() # Placeholders (Be replaced with actual values)
    • .at[0] # The first element (e.g. 690) of the array (e.g. at)
  • References
    • https://libreddit.nohost.network/r/hyprland/comments/12dhbuk/how_to_exitlogout_of_hyprland/jf6dfsv
    • https://github.com/hyprwm/Hyprland/issues/1452#issuecomment-1408359676 # Move a window to a workspace
    • https://github.com/equk/dotfiles/blob/master/configs/bin/screenactive
    • man hyprctl # /-j
    • ChatGPT

  • Use "exit"

    • vim ~/.local/bin/captureFullscreen2PNG.sh # Exit the script with a specific exit status
      if [[ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]]; then
          ...
      else
          echo "Error: Your \$XDG_CURRENT_DESKTOP is not Hyprland."
          exit 1
      fi
      
  • Notes
    • $XDG_CURRENT_DESKTOP # Get current desktop
    • 0 # Success (Opposite: 1)
    • Because need to modify a Bash script to improve compatibility.
  • References
    • ChatGPT

  • Use "eww"

    • eww daemon # Remember to run it in the background as a daemon
  • Notes
    • vim ~/.config/eww/eww.yuck
      • Example window
        (defwindow example
                   :monitor 0
                   :geometry (geometry :x "0%"
                                       :y "20px"
                                       :width "90%"
                                       :height "30px"
                                       :anchor "top center")
                   :stacking "fg"
                   :reserve (struts :distance "40px" :side "top")
                   :windowtype "dock"
                   :wm-ignore false
          "example content")
        
    • eww open example # Replace open with close to close a window
      • eww list-windows # Get name
    • nix profile install nixpkgs#eww # Install dependencies
  • References
    • https://elkowar.github.io/eww/configuration.html#creating-your-first-window
    • eww --help

  • Use "waybar"

    • waybar # Remember to run it in the background as a daemon
  • Notes
    • Warning: Cannot modify the value of min-height (Save space)
      • vim ~/.config/waybar/config.jsonc # This works, but the interactivity is gone
        {
            ...
            "mode": "overlay",
            ...
        }
        
      • https://github.com/Alexays/Waybar/issues/185
      • https://github.com/Alexays/Waybar/discussions/2594
    • Use "nerd-fonts" to display iconic font
      • doas pacman --sync nerd-fonts # Install dependencies
    • vim ~/.config/waybar/config.jsonc # Click to execute script
      {
          "layer": "top",
          "modules-center": ["clock"],
          "clock": {
              "format-alt": "{:%a, %d. %b  %H:%M}",
              "on-click": "bash ~/.local/bin/controlMpv.sh",
              "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>"
          }
      }
      
      • https://github.com/Alexays/Waybar/discussions/3072#discussioncomment-8903605 # Adjust calendar
      • Show calender on hover
    • vim ~/.config/waybar/config.jsonc # Display temperature
      "modules-right": ["temperature"],
      "temperature": {
          // "thermal-zone": 0,
          // "hwmon-path": "/sys/devices/platform/coretemp.0/hwmon/hwmon3/temp2_input",
          // "critical-threshold": 80,
          // "format-critical": "{temperatureC}°C ",
          "format": "{temperatureC}°C"
      }
      
    • vim ~/.config/waybar/style.css # Simulate dynamic island
      * {
          /* Make the background transparent */
          background-color: transparent;
      }
      
      .modules-center {
          font-weight: bold; /* Make font bold */
          padding: 0px 8px; /* Fill space for height and width */
          /* background-color: rgba(0, 0, 0, 1); */ /* Set dark mode */
          border-radius: 20px; /* Set rounded corners */
      }
      
      tooltip {
          /* Set dark mode for calendar that pops up when mouse is hovered */
          background-color: rgba(0, 0, 0, 1);
      }
      
    • nix profile install nixpkgs#waybar # Install dependencies
  • References
    • https://github.com/Alexays/Waybar/issues/2737#issuecomment-1870214557
    • https://wiki.hyprland.org/Useful-Utilities/Status-Bars/#waybar # If on Hyprland
    • https://github.com/Alexays/Waybar/wiki/Configuration#minimal-config # man waybar /minimal
    • The abbreviation of "dardware monitoring" is "hwmon".
    • Artificial intelligence

  • Use "uosc"

    • vim ~/.config/mpv/input.conf
      # Play next in playlist
      Enter script-binding uosc/next
      # Display playlist (Or `uosc/playlist`)
      Ctrl+p script-binding uosc/items
      
      • vim ~/.config/mpv/script-opts/uosc.conf
        autoload=yes
        
      • vim ~/.config/mpv/mpv.conf
        keep-open=yes
        
  • Notes
    • vim ~/.config/mpv/script-opts/uosc.conf
      # Hide top bar controls and title
      # Avoid the problem of always being on the screen
      top_bar_controls=no
      top_bar_title=no
      
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/tomasklaen/uosc/HEAD/installers/unix.sh)" # Install dependencies
  • References
    • https://github.com/tomasklaen/uosc/discussions/878#discussioncomment-8952348
    • https://github.com/tomasklaen/uosc/blob/e6a5fd981dadcc2a0d30ded64b7bcbd4481692cd/README.md#examples
    • https://github.com/tomasklaen/uosc/issues/464#issuecomment-1459930442
    • https://github.com/tomasklaen/uosc#linux--macos

  • Use "wine"

    • wine ~/.wine/drive_c/Program\ Files/path/to/yourProgram.exe # Run the installed package
  • Notes
    • Solve the problem which is needed for .NET applications to work correctly.
      • yay --sync wine-mono
    • Fonts
      • Copy msyh.ttc and msyhbd.ttc from https://github.com/taveevut/Windows-10-Fonts-Default/tree/master to ~/.wine/drive_c/windows/Fonts/
      • vim ~/.wine/msyh_font.reg
        REGEDIT4
        
        [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
        "Lucida Sans Unicode"="msyh.ttc"
        "Microsoft Sans Serif"="msyh.ttc"
        "MS Sans Serif"="msyh.ttc"
        "Tahoma"="msyh.ttc"
        "Tahoma Bold"="msyhbd.ttc"
        "msyh"="msyh.ttc"
        "Arial"="msyh.ttc"
        "Arial Black"="msyh.ttc"
        
      • wine regedit ~/.wine/msyh_font.reg # Make changes effective
    • yay --sync wine-staging-wow64 # Install dependencies
    • Because niece's programming class requires Windows software to be installed on Linux.
  • References
    • https://gist.github.com/dchaofei/f64a609e778bf3fdabff18dbd5710f9e
    • ChatGPT

  • Use "ble.sh"

    • Ctrl-f # Insert the suggestion
      • Alt-f # Insert only the first word of the suggestion
  • Notes
    • Warning: Flase trigger rate is higher than default. (Can't control it on March 30, 2024.)
    • Install dependencies
      git clone --recursive https://github.com/akinomyoga/ble.sh ~/.config/ble.sh
      cd ~/.config/ble.sh && make
      
      • vim ~/.bashrc # Load it by default
        # Add this lines at the top of .bashrc:
        [[ $- == *i* ]] && source ~/.config/ble.sh/out/ble.sh --noattach
        
        # your bashrc settings come here...
        
        # Add this line at the end of .bashrc:
        [[ ${BLE_VERSION-} ]] && ble-attach
        
  • References
    • https://github.com/akinomyoga/ble.sh/blob/master/README.md#13-set-up-bashrc
    • https://github.com/akinomyoga/ble.sh/blob/master/README.md#generate
    • https://github.com/akinomyoga/ble.sh/blob/master/README.md#33-use-auto-complete

  • Use "fbgrab"

    • fbgrab screenshot.png
  • Notes
    • Warning: This method can only capture the tty screen.
    • Solve the problem
      [yaoniplan@tux ~]$ doas fbgrab -w 1366 -h 768 -b 16 -f framebuffer.dump fb.png
      Line length cannot be smaller than width
      [yaoniplan@tux ~]$ 
      
      • doas fbgrab -w 1366 -h 768 -b 16 -f framebuffer.dump -l 1366 fb.png # Set the line length
    • Solve the problem
      [yaoniplan@tux ~]$ fbgrab screenshot.png
      Error: Couldn't open /dev/fb0.
      
      • doas fbgrab screenshot.png # Get permission to access the framebuffer device
    • Because to take a screenshot on server via SSH.
  • References
    • ChatGPT

  • The abbreviation of "near-filed communication" is "nfc".

    • A set
      • Communication protocols
  • Notes
    • Because need to use an electronic card on mobile phone.
  • References
    • https://en.wikipedia.org/wiki/Near-field_communication

  • Try a transit card if on iPhone

    • Add a bank card (e.g. China UnionPay Debit Card)
      • Recharge the transit card
    • Add a transit card (e.g. Beijing T-Union Transit Card)
      • Wallet - Add button - Transit Card
  • Notes
    • Because to make taking transportation (e.g. bus, subway) more convenient
      • Without opening payment software manually
  • References
    • transit card site:apple.com # Google
    • https://support.apple.com/en-us/108373
      • en-us # Replace it with your code (e.g. zh-cn, ja-JP, etc.)
      • ja # Japanese (Language code)
      • JP # Japan (Region code)
    • https://support.apple.com/en-us/HT208539
    • ChatGPT

  • The abbreviation of "electronic publication" is "epub".

    • Because mobile device compatibility is better than PDF.
  • References
    • https://en.wikipedia.org/wiki/EPUB

  • After trying the Emby for a few months #idea

    • Not many resources compared to some film and television websites

  • The abbreviation of "Really Simple Syndication" is "RSS".

    • The efficiency is not as high as active search when needed
  • Notes
    • Like a small search engine
    • Hope to save time and cost for all mankind
      • Like a product of the industrial revolution
  • References
    • https://en.wikipedia.org/wiki/RSS

  • Try another network operator if in China

    • China Mobile
    • China Telecom
    • China Unicom
    • China Broadnet
  • Notes
    • Send SMS to current network operator
      • CXXZ#yourIdName#yourIdNumber # 查询携转
      • SQXZ#yourIdName#yourIdNumber # 授权携转
      • Choose based on your needs after trying them
  • References
    • https://blog.ning.moe/posts/Mobile-Number-Portability/
    • https://www.189.cn/gs/sy_ycgg/113077.html
    • https://en.wikipedia.org/wiki/List_of_mobile_network_operators_in_Asia_and_Oceania#China_(mainland)

  • Try some song list music software

    • Like Prometheus stealing fire from the gods as a gift to mankind
  • Notes
    • It's convenient to use AppImage if in Linux.
  • References
    • https://github.com/listen1/listen1_desktop/releases
    • https://github.com/lyswhut/lx-music-desktop/releases
      • https://soso.lanzouj.com/b00p9c94f # Password: 8mno

  • Use "obsidian"

    • Ctrl-p # Open command palette
      • Find commonly used commands
    • Ctrl-o # Open quick switcher
      • New a file
      • Switch within files
  • Notes
    • Warning: It's an unfree software.
    • Tips
      • Leave professional things to professional software
      • Do not all in one (Add plugins as needed)
    • flatpak install flathub md.obsidian.Obsidian # Install dependencies
    • Because to want my friends to quickly learn about a simple and fast Markdown note-taking software.
  • References
    • https://www.youtube.com/watch?v=phEyrE5rRRg
    • In 'Hotkeys' of 'Options' of 'Settings'

  • Interact with tofi

    • vim ~/.local/bin/controlMpv.sh
      # Interact with tofi
      selected_option=$(echo -e "delete\nplay/pause" | tofi)
      
      case "$selected_option" in
          "delete")
              echo 'run rm "${path}"; playlist-remove current' | socat - "/tmp/mpvsocket"
              ;;
          "play/pause")
              echo cycle pause | socat - "/tmp/mpvsocket"
              ;;
          *)
              echo "Invalid selection. Aborting."
              exit 1
              ;;
      esac
      
  • Notes
    • Because to control "mpv" from the command-line via a script.
  • References
    • ChatGPT

  • Use "qutebrowser"

    • qutebrowser
  • Notes
    • Disadvantages
      • https://github.com/qutebrowser/qutebrowser/issues/7286#issuecomment-1168130067 # Some scripts are incompatible
      • https://github.com/qutebrowser/qutebrowser/issues/30 # Do not support Chromium extensions
    • gC # Duplicate the current tab
    • Open developer tools
      • wi # Web inspector (Ctrl-[, wIf)
      • :devtools # Developer tools
      • Right-click 'Inspect'
    • :adblock-update # Get adblock lists
    • Ctrl-Tab # Toggle between two tabs
    • Use userscripts
      • Put your file (e.g. https://github.com/AckslD/Qute-Translate/blob/master/translate) in ~/.config/qutebrowser/userscripts/ # Method one
      • Put your file (e.g. redirectUrl.user.js) in ~/.config/qutebrowser/greasemonkey/ # Method two
      • :greasemonkey-reload # Make it effective
      • Because to block advertisements and translate a word.
    • pp # Paste URL from clipboard (Pp: In new tab)
    • :wq # Restore tabs the next time you open qutebrowser
    • ;y # Yank hint link
    • go # Edit the current URL
    • Ctrl-h # Homepage (Startpage)
    • r # Reload the current tab
    • F # Open link in new tab
    • o # Complete :open automatically (O: In new tab)
      • :open gh tofi # Search in GitHub
    • :open alist.yaoniplan.eu.org # Open URL in current tab
      • Ctrl-i # Complete URL (The same as Tab)
      • Ctrl-j # Confirm (The same as Enter)
      • Ctrl-[ # Cancel (The same as Esc)
      • Ctrl-h # Delete a letter (The same as Backspace)
    • /music # Search text
      • Ctrl-j # Enter
      • n # Next match
    • d # Close the current tab (The same as Ctrl-w)
      • u # Undo closed tab
    • yy # Copy URL to clipboard
    • H # Previous page
    • i # Insert text
    • gt # Search tab (Or T)
      • J # Next tab
    • vim ~/.config/qutebrowser/config.py
      # Bind the command to set playback speed to 2 to the key 'q'
      config.bind('q', 'clear-messages ;; jseval document.querySelector("video, audio").playbackRate = 2')
      # Toggle status bar and tabs
      config.bind('X', 'config-cycle statusbar.show always never;; config-cycle tabs.show always never')
      # Hide tabs and status bar by default
      c.tabs.show = 'never'
      c.statusbar.show = 'never'
      # Custom keybindings (See: `qute://settings/` to get setting and value)
      # Translate languages: auto, en, zh-CN, etc.
      # Play videos with mpv
      c.bindings.commands = {"normal": {"<Ctrl+Shift-t>": "spawn --userscript translate --text", "<Ctrl-t>": "spawn --userscript translate", "gM": "hint links spawn --detach mpv {hint-url}"}}
      # Custom start page
      c.url.start_pages = '~/note/assets/index.html'
      # Custom search engines
      c.url.searchengines = {
          "DEFAULT": 'https://google.com/search?q={}',
          "gh": 'https://github.com/search?q={}'
          "t": 'https://translate.google.com/#auto/en/{}'
      }
      # Custom hints
      c.fonts.hints = 'bold 15px Fira Code'
      c.colors.hints.fg = 'white'
      c.colors.hints.bg = 'black'
      c.hints.border = '0px solid #E3BE23'
      # Load automatically
      config.load_autoconfig(True)
      # Enable dark mode
      c.colors.webpage.preferred_color_scheme = 'dark'
      c.colors.webpage.darkmode.enabled = True
      c.colors.webpage.bg = 'black'
      
      • :config-write-py # Generate if ~/.config/qutebrowser/config.py does not exist
      • :config-source # Make changes effective
    • yay --sync qutebrowser # Install dependencies
  • References
    • https://libreddit.perennialte.ch/r/qutebrowser/comments/os9hed/qutebrowser_video_speed_controller/
    • https://libreddit.oxymagnesium.com/r/qutebrowser/comments/hxa58m/where_do_i_see_my_consolelogs/
    • https://github.com/qutebrowser/qutebrowser/issues/6005 # /status
    • https://github.com/noctuid/dotfiles/blob/master/browsing/.config/qutebrowser/config.py
    • https://old.reddit.com/r/qutebrowser/comments/k1pr5z/greasemonkey_scripts_minimal_example/gdqyoaq/
    • https://www.ii.com/qutebrowser-configpy/
    • https://old.reddit.com/r/qutebrowser/comments/i6n71m/yank_hint_url/g0wtgd7/
    • https://old.reddit.com/r/qutebrowser/comments/7kydgn/how_to_custom_a_command/driv86o/
    • https://old.reddit.com/r/qutebrowser/comments/7gckl8/how_do_you_edit_the_current_url/dqiev2o/
    • https://old.reddit.com/r/qutebrowser/comments/la7vcy/caretmode_hints/glmdl8w/
    • https://old.reddit.com/r/qutebrowser/comments/zmqey6/an_update_on_the_status_of_dark_mode/j0dp5o4/
    • :help # Open help pages

  • Use "musikcube"

    • musikcube
    • Space # Select your music paths before using Enter, rightArrow key
    • a # Library
      • k # Volume down 5%
      • l # Next song
    • s # Settings
  • Notes
    • Warning: Use "mpv" as a music player to replace it on March 13, 2024.
    • vim ~/.config/musikcube/hotkeys.json # Enable Vi mode
      ...
      "key_down": "j",
      "key_left": "h",
      "key_right": "l",
      "key_up": "k",
      ...
      "playback_next": "M-l",
      "playback_previous": "M-j",
      "playback_volume_down": "M-k",
      "playback_volume_up": "M-i",
      ...
      
    • nix profile install nixpkgs#musikcube # Install dependencies
    • Because to play next song in the directory automatically.
  • References
    • https://github.com/clangen/musikcube/wiki/vi-style-navigation-keys#overview
    • https://ostechnix.com/musikcube-cross-platform-commandline-music-player/
    • https://absolutelybaching.com/technical-articles/music-players-for-windows-a-comparative-review/musikcube-music-player/

  • Use "tori"

    • tori
  • Notes
    • Warning: Use "mpv" as a music player to replace it on March 13, 2024.
    • vim ~/.config/tori.yaml
      playlists_dir: /mnt/server/al.jybest.ltd/
      
  • References
    • https://github.com/LeoRiether/tori/issues/3#issuecomment-1545925096

  • Use "vmn"

    • vmn
    • Enter # Play
  • Notes
    • Warning: Use "mpv" as a music player to replace it on March 13, 2024.
    • --headless=yes # No video output
    • --library=/mnt/server/al.jybest.ltd/IU专辑合集/ # Directory contains music files
    • --view=song-only # Output complete paths of all audio files
    • yay --sync vmn # Install dependencies
  • References
    • man vmn

  • The abbreviation of "featuring" is "feat.".

    • Featured guest
  • Notes
    • Because saw it while listening to music.
  • References
    • https://en.wikipedia.org/wiki/Guest_appearance

  • Extract a ".7z" file

    • ~/.venv/bin/ipython # Method one
      import py7zr
      with py7zr.SevenZipFile("./KikoPlay_1.0.1_Linux-x86_64.7z", mode='r') as z:
          z.extractall()
      
    • 7z x ~/Downloads/MTI.7z -o/mnt/grow/temporary/ankiDeck/ # Method two
      • 7z l ~/Downloads/MTI.7z # List it before extracting
      • x # Extract
      • -o # Output directory
  • Notes
    • Install dependencies
      • uv pip install ipython py7zr # Method one
      • nix profile install nixpkgs#p7zip # Method two
  • References
    • https://old.reddit.com/r/NixOS/comments/rxr458/where_is_7z_in_nixos_repository/hrk1f9g/
    • https://stackoverflow.com/questions/32797851/how-to-read-contents-of-7z-file-using-python/63012687#63012687
    • man 7z # /letter /-o

  • Use "flatpak"

    • flatpak override --user --filesystem=/home/$(whoami)/Downloads/ com.github.ahrm.sioyek # Allow access to a directory
      • /home/$(whoami)/Downloads # Replace it with other directory (e.g. /mnt/$(whoami))
    • flatpak search kikoplay # Search a package
      • --columns=application # Get Application ID
    • flatpak install io.github.KikoPlayProject.KikoPlay # Install a package
      • install # Replace it with uninstall (update) to uninstall (update)
    • flatpak run io.github.KikoPlayProject.KikoPlay # Run a package
      • io.github.KikoPlayProject.KikoPlay # Another method
    • flatpak list # List installed packages
  • Notes
    • Warning: Some software cannot run properly on Xwayland.
      yaoniplan@tux ~/Downloads $ QT_QPA_PLATFORM="xcb" flatpak run io.github.KikoPlayProject.KikoPlay
      libpng warning: iCCP: known incorrect sRGB profile
      Cannot load libcuda.so.1
      Cannot load libcuda.so.1
      Failed to recognize file format.
      yaoniplan@tux ~/Downloads $ 
      
    • Set a mirror if in China
      doas flatpak remote-add flathub https://mirror.sjtu.edu.cn/flathub/flathub.flatpakrepo
      
      • remote-add # Replace it with remote-modify if exists
      • doas vim /var/lib/flatpak/repo/config # Another way
        url=https://dl.flathub.org/repo/
        url-is-set=true
        
    • doas pacman --sync flatpak # Install dependencies
  • References
    • https://barthalion.blog/test-driving-flathub-mirror-for-users-in-china/
    • https://unix.stackexchange.com/questions/605285/how-to-always-run-a-flatpak-application-with-a-filesystem-permission/606194#606194
    • https://seekstar.github.io/2021/12/30/给flatpak添加国内镜像源%2f
    • ChatGPT

  • Use "uv"

    • Build a Python project
      • uv init # Create a new Python project in the current directory
      • uv add selenium # Add a selenium package to the project
      • uv run checkIn.py # Run a script in the project's environment
    • uv pip uninstall ani-cli # Uninstall a package
    • uv pip list # List installed packages
    • uv pip install anki # Install a package
    • Install Python tools globally (The ImportError problem makes it impossible to use)
      • uv tool install xklb # Replace install with uninstall to uninstall
      • uv tool install git+https://github.com/grqz/yt-dlp.git@ie/bilibili/pi_fallbk # From package source (Install patched software)
      • uv tool install git+https://github.com/yt-dlp/yt-dlp.git@refs/pull/12048/head # Install the specific commit from the PR
      • uv tool list # List installed tools
  • Notes
    • --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ # Use a mirror (Improve download speed)
    • nix profile install nixpkgs#uv # Install dependencies
  • References
    • https://github.com/yt-dlp/yt-dlp/issues/11665#issuecomment-2505987367
    • https://docs-next.astral.sh/uv/guides/tools/#installing-tools
    • https://github.com/search?q=repo%3Aastral-sh%2Fuv+ImportError&type=issues
    • https://github.com/astral-sh/uv/issues/5450
    • https://github.com/astral-sh/uv/issues/3560#issuecomment-2258821376
    • https://github.com/astral-sh/uv#getting-started
    • tldr uv
    • uv help tool
    • Artificial intelligence

  • The abbreviation of "internationalization" is "i18n".

    • 18 # nternationalizatio (20 - 2)
  • References
    • https://en.wikipedia.org/wiki/Internationalization_and_localization
    • The Hard Thing About Hard Things # Chapter 9: The End of the Beginning

  • Use "swww"

    • swww query # query information
    • swww img /usr/share/hyprland/wall_anime_2K.png
      • swww-daemon # Run in the background as a daemon at boot time
  • Notes
    • --transition-type any # Fashion
    • nix profile install nixpkgs#swww # Install dependencies
    • Because to set wallpaper on Wayland.
  • References
    • https://github.com/LGFae/swww#usage
    • https://wiki.hyprland.org/Useful-Utilities/Wallpapers/
    • swww img --help | less # /transition

  • Use "violentmonkey"

    • Ctrl-l # Select line
    • Ctrl-[ # Indent less
  • Notes
    • Because to write a user script for a website.
  • References
    • In ? tab of the code editing page

  • Use "obs"

    • obs # Configure recording settings to your preferences
      # In Settings of File
      MPEG-4 (.mp4) # Recording Format
      1364x768 # Output (Scaled) Resolution
      60 # Common FPS Values
      %CCYY-%MM-%DD_%hh-%mm-%ss # Filename Formatting
      
    • Add a source (e.g. Screen Capture) In Sources
    • Leave only an audio mixer (e.g. Desktop Audio) to avoid recroding environment sound (e.g. computer fan, keyboarding)
      • Or use a microphone
    • Start Recording
  • Notes
    • doas pacman --sync obs-studio # Install dependencies
      • Use Nix to install it will output errors
        error: Failed to initialize video.  Your GPU may not be supported, or your graphics drivers may need to be updated.
        
      • echo "127.0.0.1 localhost" | doas tee -a /etc/hosts # Solve the problem
        yaoniplan@tux ~ $ obs-cli recording start
        error: dial tcp: lookup localhost: Temporary failure in name resolution
        yaoniplan@tux ~ $  
        
  • References
    • ChatGPT

  • Use "javascript"

    • Interact with video
      // Enable full-screen mode for the video (Opposite: `webkitExitFullscreen`)
      document.querySelector('video').requestFullscreen();
      // Play the video (Replace `play` with `pause` to stop it)
      document.querySelector('video').play();
      // Set the video speed to 2.5
      document.querySelector('video').playbackRate = 2.5;
      
    • Press Enter key to click next episode icon
      document.addEventListener('keydown', function(event) {
        if (event.key === 'Enter') {
          let url = window.location.href;
          let nextIcon = null;
      
          if (url.includes("https://github.com")) {
            nextIcon = document.querySelector('a[rel="next"]');
          } else if (url.includes("https://www.google.com"))
            nextIcon = document.querySelector('a#pnnext');
          
          if (nextIcon) {
            nextIcon.click();
          }
        }
      });
      
      • Press Enter key to go to next episode URL
        document.addEventListener('keydown', function(event) {
          if (event.key === 'Enter') {
            let currentPageURL = window.location.href; // Get the current page URL
            let pageNumber = currentPageURL.match(/\/(\d+)\.(\w+)$/)[1]; // Extract the page number from the URL
            let fileExtension = currentPageURL.match(/\/(\d+)\.(\w+)$/)[2]; // Extract the file extension from the URL
            let nextPageNumber = parseInt(pageNumber, 10) + 1; // Increment the page number
            let nextPageNumberPadded = String(nextPageNumber).padStart(pageNumber.length, '0'); // Zero-pad the next page number
            let nextPageURL = currentPageURL.replace(`/${pageNumber}.${fileExtension}`, `/${nextPageNumberPadded}.${fileExtension}`); // Construct the next URL
            window.location.href = nextPageURL; // Redirect to the next URL
          }
        });
        
      • Redirect URL if your IP is blocked
        if (window.location.hostname === "www.reddit.com") {
          window.location.href = "https://safereddit.com" + window.location.pathname + window.location.search;
        } else if (window.location.hostname === "imgur.com") {
          window.location.href = "https://rimgo.lunar.icu" + window.location.pathname + window.location.search;
        }
        
    • Access iframe after DOM content loaded
      document.addEventListener('DOMContentLoaded', function() {
        var iframe = document.getElementById('playiframe');
      
        if (iframe) {
          // Add your code here.
        }
      });
      
  • Notes
    • div.video-switch-icon:nth-child(3) # Get CSS selector
      • Use Ctrl-Shift-c then click (Locate the element's position in HTML)
      • Right-click the pop-up location - Copy - CSS Path (Or Outer HTML, ask ChatGPT how to click it)
    • In userscript manager
      // ==UserScript==
      // @key value
      // ==/UserScript==
      
      // Add your JavaScript code here.
      
      • Replace following key and value with yours
      • // @name Press Enter key to click next episode # Script name
      • // @match http*://example.com/* # Match URL (Including http and https)
    • Because to achieve semi-automation in the website.
  • References
    • https://dev.to/walternascimentobarroso/youtube-speed-control-with-javascript-4mfb
    • https://violentmonkey.github.io/api/metadata-block/
    • ChatGPT

  • Use "fastfetch"

    • fastfetch
  • Notes
    • --pipe # Disable logo (To show full text)
      • --logo none # Another method with colors
    • Because it faster than "neofetch".
    • nix profile install nixpkgs#fastfetch # Install dependencies
  • References
    • fastfetch --logo

  • Use "cmus"

    • :unbind browser enter # Remove a key binding using Tab
    • 5 # Display the directory browser
      • Ctrl-r # Repeat current
      • Ctrl-h # Previous directory (The same as ../)
      • Ctrl-j # Play (The same as Enter)
      • D # Delete a song from library (The same as Delete)
      • a # Add to library and move to next line
      • - # Reduce volume by 10% (Opposite: +)
      • / # Search
      • c # Pause or resume while playing
      • m # Toggle aaa mode (Artist, album, or all)
    • 7 # Settings
    • 1 # Library
  • Notes
    • Warning: Use "mpv" as a music player to replace it on March 13, 2024.
    • vim ~/.config/cmus/rc # Show the directory in browser view
      cd /mnt/server/al.jybest.ltd/
      
    • nix profile install nixpkgs#cmus # Install dependencies
  • References
    • https://old.reddit.com/r/linuxquestions/comments/hbnmss/override_home_directory_in_cmus/ik0md15/
    • man cmus # /unbind
    • man cmus-tutorial

  • Use "jq"

    • echo "$response" | jq --raw-output '.content' # Replace .content with the desired key for filtering
  • Notes
    • [.[] | {(.timestamp): .message}] # Output matches your required format
    • .[].url
      • .[] # Iterate over each object
    • .data.content[] | select(.is_dir == false) | "\(.name | @uri)?sign=\(.sign)"
      • select(.is_dir == false) # Filter items where is_dir is false
      • "\()" # Embed the value of a field or expression inside a string
      • @uri # Uniform resource identifier (Encode a string)
    • .data.content[].name # Navigate to the name field within each object in the content array inside the data object, extract each name value
      • .data # Access the data key in the JSON object
      • .content # Access the content array
      • [] # Iterate over each element of the content array
      • .name # Access the name field of each object in the content array
    • jq # JSON query
    • nix profile install nixpkgs#jq # Install dependencies
    • Because to extract the value of the content key from the JSON response.
  • References
    • vi example.json
      {
        "code": 200,
        "message": "success",
        "data": {
          "content": [
            {
              "name": "001 music",
              "size": 0,
              "is_dir": true,
              "modified": "2022-04-04T01:49:16+08:00",
              "created": "2022-04-04T01:49:16+08:00",
              "sign": "",
              "thumb": "",
              "type": 1,
              "hashinfo": "null",
              "hash_info": null
            },
            {
              "name": "002 music",
              "size": 0,
              "is_dir": true,
              "modified": "2022-04-04T01:49:17+08:00",
              "created": "2022-04-04T01:49:17+08:00",
              "sign": "",
              "thumb": "",
              "type": 1,
              "hashinfo": "null",
              "hash_info": null
            }
          ]
        }
      }
      
      • jq --raw-output '.data.content[].name'
        001 music
        002 music
        
    • man jq # /-r
    • ChatGPT

  • Use "synctv"

    • vim ~/.config/synctv/docker-compose.yml
      version: '3.3'
      services:
        synctv:
          image: 'synctvorg/synctv:latest'
          container_name: synctv
          restart: always
          ports:
            - '8080:8080/tcp'
            - '8080:8080/udp'
          volumes:
            - ~/.config/synctv:/root/.synctv
          environment:
            - PUID=0
            - PGID=0
            - UMASK=022
            - TZ=Asia/Shanghai
      
    • docker-compose up --detach # Run in the background
  • Notes
    • Disadvantages: no English, complex operation steps
    • 192.168.10.100:8080 # Run in the Chromium
    • root # Account and password
  • References
    • https://synctv.wiki/#/quickstart?id=run
    • https://github.com/synctv-org/synctv/blob/ad7752a16534b9e9d8cdb34d26a032669da5c2c6/script/docker-compose.yml

  • Generate a UUID randomly

    • uuidgen
  • Notes
    • Other methods
      • cat /proc/sys/kernel/random/uuid
      • python -c 'import uuid; print(uuid.uuid4())'
    • Because to use vless on a foreign server.
  • References
    • ChatGPT

  • Use "cloudflared"

    • cloudflared tunnel login # Copy and open a URL to verify
    • cloudflared tunnel create memos2 # Create a tunnel
    • vim ~/.cloudflared/config.yml
      url: http://localhost:5230
      tunnel: 6c24fc10-8436-4adf-9f75-f5bdacdeedf8
      credentials-file: /home/yaoniplan/.cloudflared/6c24fc10-8436-4adf-9f75-f5bdacdeedf8.json
      
      • cloudflared tunnel list # Get the ID (e.g. 6c24fc10-8436-4adf-9f75-f5bdacdeedf8)
    • cloudflared tunnel route dns memos2 memos2.yaoniplan.eu.org # Assign a CNAME record to tunnel subdomain
    • cloudflared tunnel run memos2 # Run the tunnel
  • Notes
    • Run multiple services
      • vim ~/.cloudflared/config.yml
        tunnel: 2ec7443a-fc35-4160-b260-fc3055089c5d
        credentials-file: /home/yaoniplan/.cloudflared/2ec7443a-fc35-4160-b260-fc3055089c5d.json
        
        ingress:
          - hostname: alist.yaoniplan.eu.org
            service: http://localhost:28465
          - hostname: download.yaoniplan.eu.org
            service: http://localhost:53420
          - service: http_status:404
        
      • cloudflared tunnel route dns alist alist.yaoniplan.eu.org # Replace alist with other service (e.g. download)
      • cloudflared tunnel run alist # Replace alist with other service (e.g. download)
    • cloudflared tunnel delete memos2 # Delete a tunnel
      • cloudflared tunnel cleanup memos2 # Cleanup connection before deleting
    • doas pacman --sync cloudflared # Install dependencies
      • Use nix will take a lot of time to compile
    • Solve the problem
      Failed to add route: code: 1003, reason: Failed to create record alist.yaoniplan.eu.org with err An A, AAAA, or CNAME record with that host already exists. For more details, refer to <https://developers.cloudflare.com/dns/manage-dns-records/troubleshooting/records-with-same-name/>.
      
      • https://developers.cloudflare.com/dns/manage-dns-records/how-to/create-dns-records/#create-dns-records
      • Remove conflicting records (e.g. CNAME)
    • Because to try to run some applications on the internet.
  • References
    • https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/configure-tunnels/local-management/configuration-file/#file-structure-for-public-hostnames
    • https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/
    • cloudflared tunnel --help | less # /delete

  • Create a Firefox profile without cookies for testing purposes

    • firefox -CreateProfile testing_profile # Create a profile
    • firefox -P testing_profile # Launch with the profile
  • Notes
    • Delete a profile
      • firefox -ProfileManager # Select, Delete
      • rm -rf ~/.mozilla/firefox/gazu9g2t.testing_profile # Another method
  • References
    • ChatGPT

  • Use "pm2"

    • pm2 logs alist # View logs of a process
    • pm2 monit # View previous command
    • pm2 stop all # Reduce memory usage temporarily
      • pm2 start all # Start all stopped processes
    • pm2 restart alist # Restart after modifying the configuration file
    • pm2 start ./alist -- server # Start ./alist server command
    • pm2 save # Save process list
      • pm2 resurrect # Resurrect dumped processes
    • pm2 delete synctv # Delete a process
    • pm2 list # List all processes
  • Notes
    • --name cloudflared-alist # Set a name for the process
    • Because to try to use a foreign server when no docker.
    • npm install -g pm2 # Install dependencies
  • References
    • pm2 --help | less # /delete /status /save /name
    • https://github.com/Unitech/pm2

  • Use "bemenu"

    • bemenu-run --hb '#467b96' --hf '#dfdfdf' --tb '#467b96' --tf '#dfdfdf' -H 20 --fn 'Fira Code' -p '->'
  • Notes
    • Ctrl-y # Paste from clipboard
    • Advantages
      • High compatibility with dmenu
    • Disadvantages
      • Set default values (Does not support configuration files)
      • https://github.com/nix-community/home-manager/pull/4713#issue-2015985146
    • Use '##' to replace '#' to make command effective in Hyprland
    • Other theme
      • Vertical
        bemenu-run -i -l 10 -w --scrollbar=autohide -n --fn 'SF Mono 16' --nb '#282C34' --nf '#ABB2BF' --tb '#282C34' --tf '#ABB2BF' --fb '#282C34' --ff '#ABB2BF' --hf '#ABB2BF' --hb '#3E4451' --sb '#282C34' --sf '#61AFEF' --scb '#282C34' --scf '#61AFEF'
        
  • References
    • https://github.com/ayushnix/dotfiles/blob/2f32445283d337033a74f99d6e4a5ac32413ef51/dot_bash_profile#L35
    • https://old.reddit.com/r/hyprland/comments/135yiop/how_to_set_a_bemenurun_keybinding_on_hyprland/jilwtwn/

  • Use "cloudflare"

    • Use R2 (Need PayPal and debit card)
      • R2 - Create bucket - Bucket name (e.g. memos)
      • Manage R2 API Tokens - Create API token - Token name (e.g. Memos R2 Token) - Permissions (e.g. Admin Read & Write) - Copy (e.g. Access Key ID, Secret Access Key, Endpoints)
      • R2.dev subdomain - Allow Access - allow - Public R2.dev Bucket URL (copy)
    • Use Worker
      • Workers & Pages - Create application - Create Worker (Optional: Change name) - Deploy
      • Configure Worker - Edit Code - Paste the following code - Save and deploy
      • Trigers - Add Custom Domain - Domain (your subdomain, note that your domain name must be in Cloudflare)
    • Use Tunnels
      • Zero Trust - Networks - Create a tunnel - Select your connector (e.g. Cloudflared)
      • Tunnel name (e.g. memos) - Save tunnel - Choose your environment (e.g. Docker)
      • Copy and run command in your server - Subdomain (e.g. memos) - Domain (e.g. yaoniplan.eu.org) - Type (e.g. HTTP) - URL (e.g. localhost:5230)
  • Notes
    • vim worker.js
      addEventListener(
        "fetch",event => {
           let url=new URL(event.request.url);
           url.hostname="server.tail471ed.ts.net"; // Replace it with the website you want to proxy
           url.protocol='https'; // If the protocol is http, please change it to http
           let request=new Request(url,event.request);
           event. respondWith(
             fetch(request)
           )
        }
      )
      
    • Because to add subdomain in Cloudflare.
  • References
    • https://www.edony.ink/self-hosting-personal-memos-services/#cloudflare-r2-配置
    • https://www.usememos.com/docs/advanced-settings/cloudflare-r2
    • https://imnks.com/5984.html
    • https://blog.misaka.rest/2023/01/22/cf-wkrs-node/

  • The abbreviation of "disc jockey" is "DJ".

    • A person
      • Play recorded music
      • For an audience
  • Notes
    • Driving not the car but the music.
    • Because to help my brother download car music.
  • References
    • https://en.wikipedia.org/wiki/Disc_jockey

  • Use "udiskie"

    • udiskie & # Remember to run in the background as a daemon
  • Notes
    • Because to mount a hard disk (or USB) automatically.
      • My brother needs temporary access to my computer to download some resources to his USB drive.
    • Mount a hard disk without root permission manually
      • udisksctl mount --block-device /dev/sdd1 # Mount (Replace mount with unmount to unmount)
      • Use lsblk command to get /dev/sdd1 block device
      • cd /run/media/$(whoami) # Your USB directory
    • nix profile install nixpkgs#udiskie # Install dependencies
  • References
    • https://github.com/storaged-project/udisks/issues/1085#issuecomment-1495662054
    • ChatGPT

  • Check if Wayland is enabled in Firefox

    • about:support # /protocol
  • References
    • about:about

  • Use "make"

    • vim ~/.config/note/Makefile # Simplify the process
      .PHONY: build up
      
      build:
          docker-compose build
      
      up:
          docker-compose up --detach
      
      help:
          @echo "Available targets:"
          @echo "    dev    - Develop locally"
          @echo "    deploy - Deploy project"
      
      • make build # Execute command docker-compose build
      • make up # Execute command docker-command up --detach
      • make help # Print helps
    • doas make install # Install a package
    • doas make uninstall # Uninstall a package
  • Notes
    • git clone https://github.com/hyprwm/contrib; cd contrib/grimblast/; doas make install # Install the script
    • nix profile install nixpkgs#hyprpicker # Install dependencies (e.g. grim, slurp, hyprctl, hyprpicker, wl-copy, jq, notify-send)
      • grimblast check # Check if required tools are installed
      • grimblast copysave area $HOME/$(date +%F_%H-%M.png)
  • References
    • https://github.com/hyprwm/contrib#manual
    • Artificial intelligence

  • Use "wf-recorder"

    • wf-recorder -f out.gif --codec=gif # Record a GIF
  • Notes
    • -f # File name
    • Disadvantages: Large file, low quality
  • References
    • https://github.com/ammen99/wf-recorder/issues/79#issue-591769918
    • man wf-recorder # /-f

  • Use "wlsunset"

    • wlsunset -l 28.2 -L 116.6
      • Remember to run it in the background as a daemon at boot time
  • Notes
    • -l # Latitude
    • -L # Longitude
    • https://www.google.com/maps?q=Dongxiang+Fuzhou+Jiangxi+China
      • Dongxiang+Fuzhou+Jiangxi+China # Replace it with your location
      • Right-click the geographical location on the map
      • Click on the pop-up latitude and longitude to copy it
    • nix profile install nixpkgs#wlsunset # Install dependencies
    • Because it has a timing feature. (Work at sunrise and rest at sunset)
  • References
    • https://github.com/kennylevinsen/wlsunset#Example
    • wlsunset -h

  • Use "grim"

    • slurp -p | grim -g - - | convert - txt: | awk 'NR==2 { print $3 }' | tee >(wl-copy) | xargs -I {} notify-send "{}" # Get the HEX color code
      • -p # Pixel
      • tee >(wl-copy) # Copy to clipboard and pass it down the pipeline
    • grim -g "$(slurp)" $HOME/$(date +%F_%H-%M.png) # Select a region and screenshot it
      • -g # Geometry
      • $HOME/$(date +%F_%H-%M.png) # File name
    • grim -g "$(slurp)" - | wl-copy # Take a area screenshot and copy to clipboard
      • - # Send screenshot to stdout
      • tee /mnt/grow/image/"$(date +%F-%H%M%S).png" | # Specify a file name (Add it before the wl-copy)
  • Notes
    • Use "grimblast"
      • grimblast copysave area $HOME/$(date +%F_%H-%M.png)
      • grimblast check # Check if required tools are installed
      • nix profile install nixpkgs#grimblast # Install dependencies
    • nix profile install nixpkgs#grim nixpkgs#slurp # Install dependencies
    • Because to share screenshots with others in the open source world.
  • References
    • 2024-02-11_18-12.gif
    • https://github.com/reinefjord/wayshot/blob/master/wayshot#L132
    • https://www.youtube.com/watch?v=J1L1qi-5dr0
    • https://sr.ht/~emersion/grim/#example-usage
    • https://old.reddit.com/r/linuxquestions/comments/untr5f/why_isnt_there_a_standard_way_to_take_screenshots/i8agsw8/
    • Artificial intelligence

  • Use "mako"

    • notify-send "Hello, $(whoami)!" "This is an example notification."
      • mako # Remenber to run in the background as a daemon at boot time
    • vim ~/.config/mako/config
      sort=-time
      layer=overlay
      background-color=#2e34407f
      width=450
      height=150
      border-size=3
      border-color=#99c0d0
      # Rounded corners
      border-radius=12
      icons=0
      max-icon-size=64
      default-timeout=5000
      ignore-timeout=0
      font="Noto Sans CJK SC" 14
      margin=12
      padding=12,20
      
      [urgency=low]
      border-color=#cccccc
      
      [urgency=normal]
      border-color=#99c0d0
      
      [urgency=critical]
      border-color=#bf616a
      default-timeout=0
      
      • 7f # Alpha channel (transparent)
      • Noto Sans CJK SC # Changet font name with yours
      • makoctl reload # Reload configuration file to make changes effective
  • Notes
    • Use "makoctl"
      • makoctl dismiss # Dismiss a notification
      • makoctl restore # Restore the previous notification
    • Because to use the fastest notification daemon on Wayland.
    • nix profile install nixpkgs#mako # Install dependencies
    • Solve the problem
      yaoniplan@tux ~ $ mako
      Failed to acquire service name: File exists
      Is a notification daemon already running?
      yaoniplan@tux ~ $
      
      • Check for running notification daemons (e.g. xfce4-notifyd, gnome-shell)
        pgrep dunst # Check for Dunst
        
      • Stop existing daemons (e.g. xfce4-notifyd, gnome-shell)
        pkill dunst # Stop Dunst
        
    • Solve the problem
      yaoniplan@tux ~ $ notify-send
      -bash: notify-send: command not found
      yaoniplan@tux ~ $
      
      • nix profile install nixpkgs#libnotify # The notify-send command is part of the libnotify package
  • References
    • https://cascade.moe/posts/hyprland-configure/#mako
    • man 5 mako # /COLORS
    • ChatGPT

  • Use "gammastep"

    • gammastep -O 1500 & # One-shot
  • Notes
    • Because to set color temperature in Wayland.
    • nix profile install nixpkgs#gammastep # Install dependencies
  • References
    • https://old.reddit.com/r/wayland/comments/si49y1/redshift_alternatives_for_wayland/i90wwmb/

  • Use "swhkd"

    • pkexec swhkd --debug --config ~/.config/hypr/swhkdrc
  • Notes
    • swhks & # Run it before using the above command
    • yay --sync swhkd-bin # Install dependencies
  • References
    • https://github.com/EdenQwQ/hyprland-dots/blob/main/.config/autostart-scripts/autostart-wayland
    • man swhkd

  • Use "w3m"

    • w3m ~/note/index.html
  • Notes
    • unzip -p file.epub "*.h*" | w3m -T text/html # View epub file (Does not support loading images)
    • B # Close current buffer (The same as Alt-Left in Chromium)
    • T # New tab in the current link
      • } # Next tab
    • Ctrl-h # History page
      • /search # Search
      • Ctrl-j # Follow link (The same as Enter)
    • Scroll page (Vim-like)
      • Space # Next page
      • b # Previous page
      • j / Ctrl-n # Next line
    • Other tools
      • lynx ~/note/index.html
    • nix profile install nixpgks#w3m # Install dependencies (e.g. lynx)
    • Because to check notes quickly. (Like "links")
  • References
    • https://libreddit.kavin.rocks/r/commandline/comments/b40tt6/made_a_cli_epub_reader/ # /w3m
    • H # Help
    • ChatGPT

  • Use "tofi"

    • tofi-run "$@" | ${SHELL:-"/bin/sh"}
      • tofi-run | sh # It's ok.
  • Notes
    • rm ~/.cache/tofi-compgen # Remove it to force regenerate cache if newly installed software cannot be searched
    • Advantages: Sort by frequency of use.
    • Disadvantages
      • No support for custom keybindings.
      • https://github.com/philj56/tofi/issues/101#issue-1702785890
      • It has no completion feature.
    • "$@" # All arguments
    • ${SHELL} # The value of the SHELL environment variable
    • :- # Specify a default value if the variable is not set
      • "/bin/sh" # A specified value
      • Use default shell (if echo $SHELL is not empty) or /bin/sh
    • vim ~/.config/tofi/config
      # Show a text cursor in the input field
      text-cursor = true
      text-cursor-style = block
      # Transparency (#RRGGBBAA)
      background-color = #00000000
      # Accept arguments
      require-match = false
      # Set fonts
      font = /usr/share/fonts/TTF/FiraCode-Regular.ttf
      
      • fc-list | grep -i fira # Get font file path
    • Support hotkey
      • Ctrl-n/p # Next or previous (Ctrl-j/k is OK)
      • Ctrl-w # Clear a word
      • Ctrl-u # Clear a line
      • Ctrl-c # Close Tofi
    • nix profile install nixpkgs#tofi # Install dependencies
    • Because to execute scripts quickly. (Like "dmenu")
  • References
    • https://github.com/philj56/tofi/issues/108#issuecomment-1637050783
    • https://github.com/philj56/tofi/issues/34#issuecomment-1259924025
    • https://github.com/philj56/tofi#performance
    • https://github.com/philj56/tofi/blob/master/themes/dmenu
    • https://github.com/philj56/tofi/issues/55#issuecomment-1292147720
    • man 5 tofi # /require /COLORS /cursor
    • ChatGPT

  • Display unicode characters

    • doas pacman --sync noto-fonts-cjk
  • Notes
    • doas pacman --sync noto-fonts-emoji # Display emoji
    • Because to try other Chinese fonts after trying 'wqy-microhei'.
  • References
    • https://bbs.archlinux.org/viewtopic.php?pid=2031768#p2031768

  • Use "foot"

    • foot -e tmux
  • Notes
    • Enable daemon mode
      • foot --server # Remember to run in the background as a daemon
      • footclient # New the terminal
    • Hotkeys
      • Shift-pageUp # Scroll page up (Opposite: Shift-pageDown)
      • Ctrl-Shift-r # Search
      • Ctrl-s # Search for the next match (Opposite: Ctrl-r)
      • Ctrl-Shift-w # Extend current selection
      • Ctrl-Shift-c # Copy selected text to clipboard
      • Ctrl-Shift-n # New a terminal
    • Use "fira code"
      • doas pacman --sync ttf-fira-code # Install dependencies
      • nix profile install nixpkgs#nerd-fonts.fira-code # Install dependencies with icons
      • vim ~/.config/foot/foot.ini
        # font=FiraCode Nerd Font:size=12
        font=Fira Code:size=12
        [colors]
        alpha=0.8 # transparency
        
      • Restart Foot to make changes effective
    • -e # Execute
    • Solve the problem
      warning: 'C' is not a UTF-8 locale, using 'C.UTF-8' instead
      
      • LC_ALL=C.UTF-8 foot # Temporarily
    • nix profile install nixpkgs#foot # Install dependencies
    • Because to try the fastest responsive terminal in Wayland.
      • https://github.com/dabisu/sakura
      • https://github.com/ii8/havoc/issues/53 # Without CJK fonts support by default
  • References
    • https://old.reddit.com/r/swaywm/comments/kdtxik/dnklfoot_terminal_a_small_shoutout/gg3a274/
    • https://codeberg.org/dnkl/foot/issues/1067#issuecomment-452654 # /daemon
    • man foot.ini
    • man foot # /-e
    • Artificial intelligence

  • Use "wayst"

    • wayst -e tmux
      • --app-id wayst1 # Set window class for rule matching
      • --title fzf # Set window title when switching windows
    • Hotkey
      • Ctrl-Shift-d # New a terminal
      • Ctrl-d # Close a terminal
      • Ctrl-Shift-k # Enter vi-like keyboard select mode
      • Ctrl-Shift-c # Copy after selecting text like vi
      • Esc # Quit select mode
  • Notes
    • vim ~/.config/wayst/config
      font = [
          "Fira Code",
          "Noto Sans CJK SC" # Support Chinese characters
      ]
      font-size = 12
      
    • -e # Execute
    • yay --sync wayst-git # Install dependencies
    • Because to try the fastest responsive terminal in Wayland.
  • References
    • https://github.com/91861/wayst/blob/master/config.example
    • https://github.com/91861/wayst#installation-from-aur

  • Get the name of the terminal emulator

    • echo $TERM
  • Notes
    • tmux display-message -p "#{client_termname}" # If use tmux
      • -p # Print the output to stdout
  • References
    • man tmux # /display-message
    • ChatGPT

  • Check if the display server protocol is Wayland

    • if [[ "$XDG_SESSION_TYPE" = "wayland" ]]; then
  • Notes
    • Because to use Wayland.
  • References
    • ChatGPT

  • Use "wl-clipboard"

    • wl-copy # Copy to clipboard
    • wl-paste # Paste text from clipboard
  • Notes
    • Examples
      • wl-copy < /mnt/grow/image/2024-06-23-100503.png # Copy file to clipboard
      • wl-paste --type image/png | imv - # View an image from clipboard
      • echo "$(which mako)" | wl-copy # Copy file path to clipboard
    • Because to use Wayland.
    • doas pacman --sync wl-clipboard # Install dependencies
  • References
    • ChatGPT

  • Use "hyprland"

    • Super-rightClick # Adjust window size
    • Super-click # Drag window
    • Super-q # New a terminal
    • Super-c # Kill a window
    • Super-arrowKey # Move focus
    • Super-s # Show or hide scratchpad
      • Super-Shift-s # Move a window into scratchpad
    • Super-numberKey # Enter workspace 1 (e.g. 2, 3, ..., etc.)
      • Super-Shift-numberKey # Move a window into workspace
    • Super-m # Exit Hyprland
  • Notes
    • vim ~/.config/hypr/hyprland.conf # Enable as needed
      ecosystem {
          # Disable this dialog after upgrading hyprland
          no_update_news = true
      }
      # Fullscreen window (Hide window status bar)
      bind = $mainMod SHIFT, F, fullscreenstate, 0, 2
      # Switch between windows in a floating workspace
      bind = ALT, Tab, exec, hyprctl dispatch cyclenext && hyprctl dispatch bringactivetotop
      # Combine two commands into one line
      bind = $mainMod, C, exec, hyprctl dispatch resizeactive exact 48% 95% && hyprctl dispatch centerwindow
      # Make window 50% of screen width
      bind = $mainMod, C, resizeactive, exact 48% 95%
      # Make window centered
      bind = $mainMod, C, centerwindow
      # Assign a window to a workspace (Silent: `workspace 1 silent`)
      windowrulev2 = workspace 1, class:^(firefox)$
      # Float window and center it on the screen
      windowrulev2 = float, center, class:^(imv)$
      # Set size for floating windows (Make sure the window is floating and not full screen by default)
      windowrulev2 = size 1000 600, class:^(firefox)$, title:^(Save As)$
      # Match both "Open File" and "Open Files"
      windowrulev2 = size 771 421, class:^(chromium)$, title:^(Open File(s?)$)
      windowrulev2 = float, center, class:^(chromium)$, title:^(Open File(s?)$)
      # Enable fullscreen for a window by default
      windowrulev2 = fullscreen, class:^(wayst1)$
      # Execute script at boot time
      exec-once = ~/.local/bin/runAtBootTime.sh
      # Enable scratchpad
      # silently launch wayst in special workspace
      exec-once = [workspace special silent] wayst -e tmux new-session 'vim -c "VimwikiMakeDiaryNote"'
      animations { 
        # define special workspace animation
        animation = specialWorkspace, 1, 4, default, slidevert 
      }
      bind = $mainMod, Space, togglespecialworkspace
      bind = $mainMod SHIFT, Space, movetoworkspace, special
      # Disable animation (Avoid including them in the picture when taking screenshots)
      # `hyprctl layers`: Get namespace (e.g. launcher, wofi)
      # For workspace to replace `1` with `0` (Avoid making it take longer for your eyes to adpat)
      layerrule = noanim, wofi
      animation = specialWorkspace, 0, 4, default
      # Disable blur
      windowrulev2 = opacity 0 0,class:^(waybar)$
      # Move windows like Vi mode
      bind = $mainMod SHIFT, H, movewindow, l
      bind = $mainMod SHIFT, L, movewindow, r
      bind = $mainMod SHIFT, K, movewindow, u
      bind = $mainMod SHIFT, J, movewindow, d
      # Execute apps at launch
      exec-once = mako
      exec-once = wlsunset -l 28.2 -L 116.6
      # Bind `Alt-Enter` key to new a terminal
      bind = Alt, Return, exec, foot -e tmux
      # Bind `Super-f` key to toggle full screen
      bind = $mainMod, F, fullscreen, 0
      # Bind `Super-l` key to lock screen
      bind = $mainMod, L, exec, swaylock --color 000000; hyprctl dispatch dpms off
      misc {
          mouse_move_enables_dpms = false
          key_press_enables_dpms = true
          # Exit Hyprland to take effect (If need to turn off the text at the bottom of the screen)
          disable_splash_rendering = true
      }
      
    • Because to experience the animation special effects on Wayland.
  • References
    • https://libreddit.nohost.network/r/hyprland/comments/1ehv1ck/is_fakefullscreen_deprecated/ # /fullscreen
    • https://github.com/hyprwm/Hyprland/issues/3566#issuecomment-1858861625 # /size
    • https://libreddit.nohost.network/r/hyprland/comments/165pra4/active_window_on_top/jyg2p0x
    • https://libreddit.nohost.network/r/hyprland/comments/18won1q/center_single_window_on_master_layout_and_prevent/kg0dvq9 # /centerwindow
    • https://github.com/hyprwm/Hyprland/issues/2948#issuecomment-2283235966 # /resizeactive
    • https://libreddit.nohost.network/r/hyprland/comments/1c31ufa/how_to_remove_this_line_at_bottom/kzdpbkt
    • https://wiki.hyprland.org/Configuring/Window-Rules/
    • https://libreddit.baczek.me/r/hyprland/comments/18o5d18/open_window_on_initial_workspace_opened_rather/
    • https://red.artemislena.eu/r/hyprland/comments/15xlykt/disabling_workspace_animations/
    • https://libreddit.oxymagnesium.com/r/hyprland/comments/1ars1q7/a_drop_down_terminal_quakelike/kqm2i7i/
    • https://libreddit.kavin.rocks/r/hyprland/comments/11jjpn8/animation_for_specific_window/ # Disable animation
    • https://libreddit.nohost.network/r/hyprland/comments/10q5t3e/no_blur_on_hyprland/ # Disable blur
    • https://github.com/hyprwm/Hyprland/issues/1337#issuecomment-1374832211
    • https://old.reddit.com/r/hyprland/comments/118z40c/bind_the_enter_key_in_hyprland/j9m0r04/
    • https://github.com/hyprwm/Hyprland/discussions/830#discussioncomment-3868467 # Switch app
    • https://old.reddit.com/r/hyprland/comments/11c2lie/how_to_moveresize_windows_with_only_the_keyboard/jak96fw/
    • https://github.com/hyprwm/Hyprland/commit/2e3f0d5991874edb01f1bfe4ffc75701f8b398dc # Anime mascot wallpaper (/usr/share/hypr/wall{0,1,2}.png)
    • https://old.reddit.com/r/hyprland/comments/xwit2h/drag_window/ir6rm9j/
    • https://old.reddit.com/r/hyprland/comments/14u9p3v/turning_off_screens_after_locking_them/jrf09np/
    • https://old.reddit.com/r/hyprland/comments/y92mo2/how_do_i_make_a_fullscreen_toggle_bind/k0tg5o1/

  • Use "fzf"

    • fzf
  • Notes
    • Ctrl-j/k # Next/previous selection (Same as Ctrl-n/p)
    • Ctrl-m # Enter key
    • --reverse # Put the search bar in the top of screen
    • vi ~/.bashrc # Bind Ctrl-j key to Enter key (Like Bash)
      export FZF_DEFAULT_OPTS="--bind=ctrl-j:accept"
      
      • source ~/.bashrc # Make changes effective
    • Because "ani-cli" depends on 'fzf'.
  • References
    • https://github.com/junegunn/fzf/discussions/2576#discussioncomment-1130797
    • ChatGPT

  • Use "mov-cli"

    • mov-cli
  • Notes
    • Because to watch a foreign movie.
    • pipx install mov-cli # Install dependencies
  • References
    • https://github.com/mov-cli/mov-cli?tab=readme-ov-file#usage

  • Make a contribution in GitHub

    • Push a request (Contributor)
      • Fork a repository
      • Edit a file in the forks (Optional: Choose a development branch)
      • Create Pull requests
    • Pull a request (Owner)
      • cd ~/note/; git checkout -b lingyiba-development development # Switch to a new branch
      • git pull https://github.com/lingyiba/note.git development # Test the changes
      • git checkout development # Return to the branch before switching
      • git push origin development # Push to remote
  • Notes
    • Because to experience the power of the open source world.
  • References
    • https://github.com/aermin/blog/issues/50#issue-347703624
    • https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
    • https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request

  • Use "aria2c"

    • touch ~/.config/aria2c/aria2.session
    • vim ~/.config/aria2c/aria2.conf
      dir = /home/yaoniplan/.config/aria2c
      enable-rpc = true
      rpc-allow-origin-all = true
      rpc-listen-all = true
      continue = true
      input-file = /home/yaoniplan/.config/aria2c/aria2.session
      save-session = /home/yaoniplan/.config/aria2c/aria2.session
      max-concurrent-downloads = 5
      
    • aria2c --conf-path ~/.config/aria2c/aria2.conf
  • Notes
    • Optional
      • rpc-listen-port = 47819 # Change default 6800 port
      • rpc-secret = 4jJOSa9ePitWJV1G5dRAweJLv53bd7N/TzK71L1u8o8= # Change default empty password (Use openssl rand -base64 32 command to generate RPC secret)
    • nix profile install nixpkgs#aria2 # Install dependencies
  • References
    • https://xnth97.github.io/2017/10/25/raspberry-pi/#安装-aria2
    • man aria2c # /rpc options
    • ChatGPT

  • Add zero padding to file name

    • for n in {1..9}; do old="Python3($n).flv"; new="Python3(0$n).flv"; mv "$old" "$new"; done
  • Notes
    • Because sometimes the tenth file doesn't get sorted correctly.
    • Another method
      for f in *; do mv "$f" "$(echo "$f" | sed -E 's/\(([0-9])\)/\(0\1\)/')"; done
      
      • -E # Regular expression
      • \( # Escape it and match ( (The same as \))
      • () # A capture group
      • [] # Character set
      • 0-9 # Match any digit from 0 to 9
      • \1 # A backreference to the first captured group
  • References
    • 2023-12-25_19-30.png
    • 2023-12-25_20-45.png
    • https://stackoverflow.com/questions/60994956/adding-zero-padding-to-file-name-with-bash/60995027#60995027
    • ChatGPT

  • Use "ipython"

    • ipython
    • Hotkey
      • Ctrl-p # Complete a sentence
  • Notes
    • vi ~/.ipython/profile_default/ipython_config.py # Enable vi mode
      c.TerminalInteractiveShell.editing_mode = 'vi'
      c.TerminalInteractiveShell.emacs_bindings_in_vi_insert_mode = False
      
    • pipx install ipython # Install dependencies
  • References
    • http://www.codebaoku.com/jupyter/jupyter-index.html
    • https://github.com/ipython/ipython/issues/13443#issuecomment-1032753703

  • Use "termux"

    • Connect to your server
      pkg upgrade && pkg install openssh # Upgrade and install dependencies
      ssh yaoniplan@192.168.10.100 # Connect to your server
      
  • References
    • https://www.sqlsec.com/2018/05/termux.html
    • https://github.com/termux/termux-app#GitHub
      • https://github.com/termux/termux-app/actions/workflows/debug_build.yml?query=branch%3Amaster+event%3Apush
      • Click a latest workflow run results
      • Search string android-5-github-debug_universal and then click it

  • Monitor network traffic

    • nload -u M -U G enp2s0
      • -u M # Unit in Megabytes
      • -U G # Unit of the total amount of data in Gigabytes
      • enp2s0 # Use command ip address to get device name
  • Notes
    • Use "btm"
      • f # Freeze
      • e # Expand a widget
      • ? # Help
      • Shift-h/j/k/l # Move focus
      • j/k # Move options
      • Ctrl-d/u # Scroll down/up a half
      • / # Search
      • Ctrl-[ # The same as Esc
      • P # Show the complete command of process name
      • dd # Delete a process
    • Other methods
      • btop # Use shortcut key Ctrl-minus to adjust terminal size
      • cat /proc/net/dev | grep enp2s0
      • ip -human-readable -statistics link show enp2s0
      • bmon
      • doas iftop
      • vnstat -l
    • nix shell nixpkgs#nload # Install dependencies
      • Replace nload with other dependencies (e.g. bottom, vnstat, iftop, bmon, btop, etc.)
  • References
    • https://github.com/ClementTsang/bottom/issues/572#issuecomment-916165075
    • https://github.com/ClementTsang/bottom/issues/133
    • https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal
    • man nload

  • Use "yt-dlp"

    • yt-dlp "yourPlaylistURL"
  • Notes
    • --get-url # Get direct url (e.g. https://example.com/sample.m4a)
    • yt-dlp --flat-playlist --default-search ytsearch20 "linux tutorial" -O "#EXTINF:%(duration_string)s,%(title)s" -O "%(webpage_url)s" -O "" | awk 'BEGIN { print "#EXTM3U\n" } { print $0 }' >> playlistOne.m3u # Write to a M3U file
    • yt-dlp --skip-download --ignore-errors --print-to-file url playlist.txt "yourPlaylistUrl" # Extract playlist URL to file
      • yt-dlp "yourPlaylistUrl" --flat-playlist --dump-json | jq -r .url >> ~/playlist.txt # Another way
    • yt-dlp --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=ie-TS-BitnQ # Download the audio file in MP3 format
      • yt-dlp --extract-audio --audio-format mp3 --batch-file aolaStar.txt # Batch download
    • yt-dlp --skip-download --write-subs yourURL # download subtitles only
    • --max-downloads 1 # Download the latest one
    • --yes-playlist # Download the playlist
    • --output # Output filename template (e.g. "%(title)s.%(ext)s")
      • /mnt/grow/temporary/ # If full path is required
      • "%(playlist)s/ # A folder
      • %(playlist_index)s # A sequence
      • %(title)s # A file name
      • .%(ext)s" # A file extension
    • " # Enclose in quotes if URL contains special characters (e.g. &)
    • nix shell nixpkgs#yt-dlp # Install dependencies
  • References
    • https://github.com/yt-dlp/yt-dlp/issues/4628
    • https://github.com/ytdl-org/youtube-dl/issues/28633#issuecomment-812823807
    • https://redlib.freedit.eu/r/youtubedl/comments/unsaho/how_to_extract_individual_videos_links_from/
    • man yt-dlp # /template examples
    • Artificial intelligence

  • Use "anki"

    • d # Decks
    • / # Search
      • Space # Next step and card
      • 4 # Easy
      • u # Undo
    • y # Sync
    • b # Browse
      • deck:自然拼读 is:learn # Filter cards (e.g. learning) in deck (e.g. 自然拼读)
  • Notes
    • Import apkg packages in batches for testing purposes
      for f in ~/Downloads/deck/*.apkg; do 
          curl localhost:8765 --request POST --data '{
              "action": "importPackage",
              "version": 6,
              "params": {
                  "path": "'$f'"
              }
          }'
      done
      
      • ~/Downloads/deck/*.apkg # Your apkg packages path
      • '$f' # Enclose in single quotes to make variable effective
      • Remember that full path and filename cannot contain spaces
    • Solve the problem by importing media files in batches
          Error playing audio. This can be
      caused by a corrupt file, a file iOS does
        not support (eg .ogg), or an mp3 file
               incorrectly named .wav
      
                  hair1.wav: Error
            Domain=NSOSStatusErrorDomain
              Code=1685348671 "(null)"
      
      • Get media file directory path
        curl localhost:8765 --request POST --data \
        '{
            "action": "getMediaDirPath",
            "version": 6
        }'
        
      • cp -r ~/testWAV/*.mp3 ~/.local/share/Anki2/User\ 1/collection.media/
      • Use 'Find and Replace' to replace wav with mp3
      • Install an addon named 'AnkiConnect' before running command
    • Sync server
      python -m venv ~/.config/anki/ # Create a virtual environment using the built-in `venv` module
      ~/.config/anki/bin/pip install anki # Install anki.syncserver in the virtual environment
      MAX_SYNC_PAYLOAD_MEGS=1000; SYNC_USER1=admin:****** ~/.config/anki/bin/python -m anki.syncserver
      
      • SYNC_USER1=admin:*** SYNC_USER2=user:*** # Multiple users
      • Client (e.g. Linux, Android, iOS, etc.)
        http://192.168.10.100:8080/ # In 'Self-hosted sync server' of 'Syncing'
        admin # In 'user' of 'Synchronize'
        ****** # In 'password' of 'Synchronize'
        
      • crontab -e
        @reboot MAX_SYNC_PAYLOAD_MEGS=500; SYNC_USER1=admin:****** ~/.config/anki/bin/python -m anki.syncserver
        
      • Click the sync button to sync the progress before and after learning
    • nix profile install nixpkgs#anki # Install dependencies
  • References
    • https://docs.ankiweb.net/searching.html#card-state
    • https://foosoft.net/projects/anki-connect/index.html#importpackage
    • https://foosoft.net/projects/anki-connect/index.html#media-actions
    • https://zhuanlan.zhihu.com/p/22180094 # media
    • https://docs.ankiweb.net/sync-server.html#with-pip
    • ChatGPT

  • Understand "active learning"

    • Group discussion
    • Practice by doing
    • Teach others
  • Notes
    • Propose a hypothesis (To test it)
    • Find relevant circles
  • References
    • https://archive.org/download/01_20231107_20231107_0818

  • Use "pipx"

    • pipx install animdl
  • Notes
    • pipx upgrade mov-cli # Upgrade
    • pipx list # List installed packages
    • pipx uninstall animdl # Uninstall
    • nix profile install nixpkgs#pipx # Install dependencies
  • References
    • pipx --help

  • Use "ani-cli"

    • ani-cli Terror in Resonance
  • Notes
    • doas vim /nix/store/q8vgwi1qizpp5m4n7afsa2an7x9f9fpv-ani-cli-4.9/bin/.ani-cli-wrapped # Modify script to use a custom external menu
      external_menu() {
          #rofi "$1" -sort -dmenu -i -width 1500 -p "$2"
          fuzzel --dmenu "$1" -i -l 0 -p "$2"
      }
      
      launcher() {
          [ "$use_external_menu" = "0" ] && [ -z "$1" ] && set -- "+m" "$2"
          #[ "$use_external_menu" = "0" ] && fzf "$1" --reverse --cycle --prompt "$2"
          [ "$use_external_menu" = "0" ] && fuzzel --dmenu -i -l 20 -p "$2"
          #[ "$use_external_menu" = "1" ] && external_menu "$1" "$2"
          [ "$use_external_menu" = "1" ] && fuzzel --dmenu -i -l 20 -p "$2"
      }
      
    • --rofi # Use rofi instead of fzf for the interactive menu
    • --range "3 - 4" # Specify range (Without clicking next manually)
    • cat ~/.local/state/ani-cli/ani-hsts # View history
      • tac ~/.local/state/ani-cli/ani-hsts | less # Another way
    • Issues: Can't add a source (Cause: Watermark, not many sources, etc.)
    • Terror in Resonance # Replace it with your desired animation name
    • yay --sync ani-cli # Install the dependencies
  • References
    • https://github.com/pystardust/ani-cli/discussions/1003#discussioncomment-4815461
    • https://www.youtube.com/watch?v=gscwIwRaIo8
    • ani-cli --help
    • Artificial intelligence

  • Use "fastanime"

    • fastanime search --anime-titles "Blue Lock"
  • Notes
    • fastanime config # Edit configuration settings
      # Because the owner said that due to a series of unfortunate events
      # The latest version will not be released on pypi for the time being (e.g. v2.8.4)
      check_for_updates = False
      
    • --version # Check version number
    • uv tool install fastanime # Install dependencies
  • References
    • https://github.com/Benexl/FastAnime#usage
    • fastanime --help

  • The abbreviation of "All Clear" is "AC".

    • In a calculator
  • Notes
    • Because we saw it in an electronic calculator.
  • References
    • ChatGPT

  • The abbreviation of "American Sign Language" is "ASL".

    • For the deaf
  • Notes
    • Because we saw it at the Worldwide Developers Conference.
  • References
    • https://en.wikipedia.org/wiki/American_Sign_Language
    • https://gist.github.com/IsaacXen/874c59aec92a13f30728aecdabb9ea80#file-hls-only
    • https://en.wikipedia.org/wiki/Worldwide_Developers_Conference

  • Use "smb"

    • doas vi /etc/samba/smb.conf
      [yaoniplan]
      path = /mnt/grow
      writable = yes
      browsable = yes
      public = no
      valid users = yaoniplan, root
      
    • doas smbpasswd -a yaoniplan # Set SMB password for your user
    • doas systemctl restart smb # Restart to take effect
  • Notes
    • Warning: The speed is slower than WebDAV. (Sometimes freeze)
    • testparm # Check for syntactic errors
    • /mnt # Replace it with a directory you want to share
    • doas pacman --sync samba # Install dependencies
    • Because it needs to be used on devices or software that does not support WebDAV.
  • References
    • https://www.danielmartingonzalez.com/en/samba-server-in-debian/

  • Use "node"

    • node main.js
  • Notes
    • nix shell nixpkgs#nodejs # Install denpendencies
    • Because we need to see the output of the file.
  • References
    • vim main.js
      const notes = ['do', 're', 'me'];
      
      notes.forEach((note) => console.log(note));
      
    • https://dev.to/i3uckwheat/understanding-callbacks-2o9e
    • https://www.theodinproject.com/lessons/nodejs-introduction-what-is-nodejs
    • ChatGPT

  • Add UTF-8 encoding support to HTML file

    • vi ~/note/index.html
      ...
      <html>
      <head>
        <meta charset="UTF-8">
        ...
      </head>
      ...
      
  • Notes
    • Because to display Chinese characters properly in HTML file for Docker image
  • References
    • ChatGPT

  • Use "ish"

    • Start an HTTP server
      • git clone git@192.168.10.100:/var/git/note.git # Download a directory containing index.html
      • python3 -m http.server -d ~/note/ 2003 # Use module to serve directory listening on port
      • localhost:2003 # Run in Safari
    • mount -t ios . /mnt # Mount a local folder and then ls /mnt
      • umount /mnt # Unmount it
    • Clipboard
      • cat /dev/clipboard # https://github.com/ish-app/ish/issues/192#issuecomment-717605379
      • echo foo > /dev/clipboard # https://github.com/ish-app/ish/issues/192#issuecomment-717605036
    • df -h # Check disk free
    • id # Check current user (Like whoami)
    • Connect to your server
      apk add openssh # Install dependencies
      ssh-keygen && ssh yaoniplan@192.168.10.100 # Generate authentication keys for ssh and then connect
      ssh-copy-id yaoniplan@192.168.10.100 # Connect to a remote machine without password
      
      • vi ~/.profile # Execute automatically after opening iSH
        ssh yaoniplan@192.168.10.100
        
  • Notes
    • Warning: No Siri Shortcuts integration.
      • https://github.com/ish-app/ish/issues/59
    • Terminate SSH connection
      • Ctrl-b d # Detach the current session if using tmux
      • logout # Exit the login shell
    • vi /etc/apk/repositories # Set mirror
      https://mirrors.ustc.edu.cn/alpine/latest-stable/main
      https://mirrors.ustc.edu.cn/alpine/latest-stable/community
      
      • apk update # Update repository indexes to take effect
    • apk update && apk upgrade # Run before installing packages (Make sure free access to the internet)
  • References
    • https://github.com/ish-app/ish/issues/1581#issuecomment-1100768238
    • https://github.com/ish-app/ish/issues/2139#issuecomment-1596681536
    • https://mirrors.ustc.edu.cn/help/alpine.html
    • https://www.youtube.com/watch?v=-VBMYK3Sy54
    • https://www.youtube.com/watch?v=R44NXv7QUek
    • apk -h
    • man ssh-keygen
    • ChatGPT

  • Rename file in batches

    • for file in *.m4a; do mv "$file" "$(echo "$file" | sed -E 's/\[[0-9]+\]//g')"; done
  • Notes
    • -E # Extended regular expressions
    • [0-9] # Any single digit from 0 to 9
    • + # One or more times
  • References
    • 2023-09-21_10-07.png
    • yt-dlp --output "%(title)s.%(ext)s" https://www.ximalaya.com/album/31923706
    • man sed # /-E
    • ChatGPT

  • Use "watchtower"

    • Because to update Docker containers automatically
  • Notes
    • vi ~/.config/watchtower/docker-compose.yml
      version: '3'
      services:
        watchtower:
          image: containrrr/watchtower
          container_name: watchtower
          restart: always
          volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /etc/localtime:/etc/localtime:ro
          command: --interval 3600
      
      • /etc/localtime:/etc/localtime # Synchonize the time zone (Between host and Docker container)
      • ro # Read-only
      • 3600 # Replace it with your desired seconds
  • References
    • https://github.com/containrrr/watchtower/discussions/1689
    • https://ryanccn.dev/posts/vps-docker-compose-traefik/#watchtower
    • ChatGPT

  • Add an icon to a website

    • vi ~/note/index.html
      <!DOCTYPE html>
      <html>
      <head>
        <link rel="icon" href="../assets/favicon.png" type="image/png">
        ...
      <head>
      ...
      
  • Notes
    • ../assets/favicon.png # Replace it with path to your favicon file
  • References
    • ChatGPT

  • The abbreviation of "music video" is "MV".

    • Marketing
  • Notes
    • Most pop music has MVs.
  • References
    • https://en.wikipedia.org/wiki/Music_video

  • Use "tailscale"

    • doas tailscale up --accept-dns=false --advertise-routes=192.168.10.0/24
    • https://login.tailscale.com/admin/machines # Open in web browser
      • Click on '192.168.10.0/24' of 'Subnet routes' in 'Edit route settings of server'
      • Click on 'Disable key expiry' to extend time
    • tailscale login # Other users who want to join this LAN
      • 'Sign in' - 'Alternatively, use a QR code' - 'Connect' # Another method
  • Notes
    • --advertise-exit-node # Enable Exit Node
    • doas tailscale file cp ~/.config/clash/config.yaml android: # Send a file to another device
    • doas tailscale set --accept-dns=false # Disable MagicDNS if don't want Tailscale to overwrite file /etc/resolve.conf
    • doas pacman --sync tailscale # Install the dependencies
    • doas systemctl enable --now tailscaled # Enable daemon now and at boot
    • Install this app for each device (e.g. Linux, Android, iPhone, etc.) you want to connect
    • Use Funnel (Not recommended: slow)
      tailscale cert
      tailscale cert server.tail471ed.ts.net
      doas tailscale serve --bg 2004
      doas tailscale funnel --bg 2004
      
      • https://login.tailscale.com/admin/dns # Enable 'HTTPS Certificates' before running the above code
      • doas tailscale funnel --https=443 off # Disable Funnel
  • References
    • https://old.reddit.com/r/Tailscale/comments/14gccua/funnel_serve_multiple_ports/kd3yh39/
    • https://tailscale.com/kb/1106/taildrop
    • https://tailscale.com/s/resolvconf-overwrite
    • https://github.com/adyanth/openwrt-tailscale-enabler#readme
    • https://www.dongvps.com/2023-05-29/tailscale-funnel/

  • Become a "real rich man"

    • Meditate "I am a real rich man" in your heart
  • Notes
    • Treat all people and things with the standard
  • References
    • ``

  • Understand "Three Laws of Robotics"

    1. Not injure humanity
    2. Not injure a human being
    3. Obey the orders
    4. Protect itself
  • References
    • https://en.wikipedia.org/wiki/Laws_of_robotics#Isaac_Asimov's_"Three_Laws_of_Robotics%22

  • The abbreviation of "Wireless Fidelity" is "Wi-Fi".

    • A family
      • wireless netwrok protocals
  • Notes
    • The abbreviation of "Wireless local area network" is "WLAN".
  • References
    • https://en.wikipedia.org/wiki/Wi-Fi

  • Use Debian Linux in Docker

    • apt install curl --yes # Install a package
      • apt update # Update it before Installing
      • install # Replace it with autoremove to return to previous state
  • Notes
    • Set a mirror if on China
      • sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
      • sudo sed -i 's/http/https/g' /etc/apt/sources.list
    • vi ~/.config/debian/docker-compose.yml
      version: '3'
      
      services:
        debian:
          image: debian
          restart: always
          tty: true
          stdin_open: true
          volumes:
            - ./data:/data  # Add any volumes you want to mount
      
      • docker-compose up --detach # Run in the background
  • References
    • man apt # /autoremove
    • https://mirrors.ustc.edu.cn/help/debian.html
    • ChatGPT

  • The abbreviation of "mi" is "mile".

    • An unit of distance
    • 1.61 kilometers (1 mile)
  • Notes
    • Because saw it in the map software.
  • References
    • https://en.wikipedia.org/wiki/Mile

  • Use "uxplay"

    • uxplay
  • Notes
    • Warnning: Slow response, high latency, in the same local area network
    • nix-shell --packages uxplay # Install dependencies temporarily
    • Solve a problem that doesn't detect UxPlay server
      • doas avahi-daemon # Run in the background
      • uxplay # Run
  • References
    • https://github.com/antimof/UxPlay/issues/23#issuecomment-727816961
    • 2023-08-23_15-27.png

  • Acquire skills of taking a photo

    • Highlight a focus
      • Blur background (Press focus)
      • Leading line
      • Center of vision (Horizontally and vertically divided into thirds)
      • By chiaroscuro
      • Without focus are suitable for wallpaper
    • Looking down or looking up
    • Switch focal length
    • Light (e.g. Direction, intensity, etc.)
      • Light in front of focus (Positive light / flat light)
      • Light on the side of focus (Three-dimensional effect, e.g. 45 degrees, 90 degrees, etc.)
      • Light behind foucs (Silhouettes, Backlight)
    • Element (e.g. point, line, surface, etc.)
  • Notes
    • Because to share some records with family.
  • References
    • https://archive.org/download/05_20230818

  • The abbreviation of "high dynamic range" is "HDR".

    • Because see it when taking a photo
  • References
    • https://en.wikipedia.org/wiki/High_dynamic_range

  • Understand "flowchart"

    • An representation about algorithm
      • A step-by-step approach to solving a task
  • Notes
    • Terminal (Start / End)
      • Rounded rectangle
    • Flowline
      • Line
    • Process
      • Rectangle
    • Decision
      • Diamond
  • References
    • https://en.wikipedia.org/wiki/Flowchart

  • Output chess board in C

    • vi ~/chessBoard.c
      #include <stdio.h>
      
      int main() {
          for (int i = 0; i < 8; i++) {
              for (int j = 0; j < 8; j++) {
                  if ((i + j) % 2 == 0)
                      printf("██"); // Output white square
                  else
                      printf("  "); // Output black square with two spaces
              }
              printf("\n");
          }
          return 0;
      }
      
  • References
    • gcc ~/chessBoard.c && ./a.out # Compile and run
    • 2023-08-13_11-05.png
    • https://archive.org/download/c-100_20230813
    • ChatGPT

  • Use "gtts-cli"

    • gtts-cli "$(date +%F)" | mpg123 - # Speech date
  • Notes
    • nix profile install nixpkgs#python311Packages.gtts # Install dependencies
    • gtts-cli -l en -o e.mp3 "hello test for ai" --debug # Debug
      ...
      Error: Failed to connect. Probable cause: Unknown
      ...
      
  • References
    • https://github.com/pndurette/gTTS/discussions/275#discussioncomment-351592
    • ChatGPT

  • Use "espeak"

    • espeak "Hello, this is a test."
  • Notes
    • Warnings: The pronunciation needs to be more natural and modern. (Compared to 'gtts-cli')
    • nix profile install nixpkgs#espeak # Install dependencies
  • References
    • Artificial intelligence

  • Record screen to a GIF file with ffmpeg

    • ffmpeg -f x11grab -s 1366x768 -i :0 -t 10 -r 60 $(date +%F_%H-%M).gif
  • Notes
    • Warnning: The clarity quality is a bit low, Wayland is not supported
    • xdpyinfo | grep dimensions | awk '{print $2}' # Get screen resolution
  • References
    • ChatGPT

  • Enable a HTTP server to share files temporarily

    • python -m http.server -d /mnt/grow/ 8080
  • Notes
    • Warning: This method is only suitable for small files.
    • /mnt/grow/ # Replace it with the directory you want to share
    • http://192.168.10.105:8080 # View it in local area network
    • nix shell nixpkgs#python310Packages.httpserver # Install dependencies temporarily
  • References
    • https://root.nix.dk/en/network-notes/basic-samba-setup-and-troubleshooting

  • Record screen in Linux

    • ffmpeg -f x11grab -video_size 1366x768 -framerate 60 -i :0.0 -c:v libx264 $(date +%F_%H-%M).mp4
  • Notes
    • xdpyinfo | grep dimensions | awk '{print $2}' # Get the resolution (e.g. 1366x768)
    • 60 # Replace it with your disired frame rate
  • References
    • ChatGPT

  • Output the multiplication table in C

    • vi multiplicationTable.c
      #include <stdio.h>
      
      int main() {
          for(int i = 1; i < 10; i++) {
              for(int j = 1; j <= i; j++) {
                  printf("%d*%d=%d\t", j, i, j*i);
              }
              printf("\n");
          }
          return 0;
      }
      
  • Notes
    • int # Integer
    • for(int i = 1; i < 10; i++) # Incrementing the value of "i" from 1 to 9
      • for() # For loop
      • int i = 1 # Initialize the variable "i" with the value "1"
      • i < 10 # Check the condition
      • i++ # Increment (e.g. i = i + 1)
    • %d # Placeholder
    • \t # Tab character
    • \n # Newline character
  • References
    • gcc multilicationTable.c && ./a.out # Compile and run 2023-08-13_14-45.png
    • https://archive.org/download/c-c-qq
    • ChatGPT

  • Use "code"

    • code
  • Notes
    • Warning: It's an unfree software.
    • Ctrl-o # Open a file
    • Ctrl-n # New a file
    • Ctrl-Shift-p # Prompt a command palette
    • Ctrl-Shift-x # Extensions
    • Ctrl-backtick # Toggle a terminal
    • Ctrl-f # Find
    • Ctrl-g # Go to a specific line
    • Ctrl-p # Quick open a file by name
    • nix shell nixpkgs#vscode # Install dependencies temporarily
  • References
    • ChatGPT

  • Use "cursor"

    • cursor
  • Notes
    • Ctrl-l # Open Chat
    • Ctrl-i # Open Compositor
    • Ctrl-Shift-i # Open Notepad
    • Ctrl-k # Pop up a chat window (When you selected some code)
    • Ctrl-w # Close current window (Like in Chromium)
    • Ctrl-Tab # Switch between files
  • References
    • https://cursor101.com/cursor/cheat-sheet
    • Give me the Cursor AI editor cheat sheet # Artificial intelligence

  • Road signs in China

    • Because it appears on the theory driving license test in China.
  • Notes
    • Tourist signs
      • Brown
    • Additional sings
      • Below
    • Indicative signs
      • Blue without text
    • Warrning signs
      • Yellow
    • Prohibitory signs
      • Red
  • References
    • https://en.wikipedia.org/wiki/Road_signs_in_China#Gallery

  • The abbreviation of "megabyte" is "MB".

    • A multiple of the unit byte for digital information
    • One megabyte is one million bytes of information
  • Notes
    • Seen in eBook file sizes
  • References
    • https://en.wikipedia.org/wiki/Megabyte

  • The abbreviation of "internet protocal" is "IP".

    • IP address
      • A numerical label (e.g. 192.168.10.100)
  • References
    • https://en.wikipedia.org/wiki/IP_address

  • Use "ping"

    • ping -c 3 192.168.10.100
  • Notes
    • -c # Count
    • ping -6 yourIPV6Address # Ping an IPV6 address
    • Because to check whether the server is online.
  • References
    • man ping

  • Manage time

    • How to live a day is how to live a life
    • Habit
      • Nap in the morning
      • Break at noon
      • Go to bed early to get up early
      • Spend one percent of your time reflecting
      • Use biological clock instead of alarm clock
  • Notes
    • Almost everyone knows that whether you can build a happy life and achieve success is related to how you use your time
  • References
    • https://archive.org/download/230513rockefeller-letters
    • https://archive.org/download/1._20230802

  • Some abbreviations about theory driving license test in China

    • The abbreviation of "Global Positioning System" is "GPS".
    • The abbreviation of "adaptive cruise control" is "ACC".
    • The abbreviation of "electronic brakeforce distribution" is "EBD".
    • The abbreviation of "lane departure warning" is "LDW".
    • The abbreviation of "Autonomous Lane-changing Assistant" is "ALC".
  • References
    • https://en.wikipedia.org/wiki/Global_Positioning_System
    • https://en.wikipedia.org/wiki/Adaptive_cruise_control
    • https://en.wikipedia.org/wiki/Electronic_brakeforce_distribution
    • https://en.wikipedia.org/wiki/Lane_departure_warning_system
    • https://web.archive.org/web/20230802030249/http://www.liuwenhao.me/?p=4902

  • Understand "water temperature gauge"

    • H # Hot
    • C # Cold
  • Notes
    • Measure the temperature of the engine coolant
  • References
    • https://northwestautohouston.com/signs-overheating-car/

  • Understand "feul gauge"

    • E # Empty
    • F # Full
  • References
    • https://en.wikipedia.org/wiki/Fuel_gauge

  • The abbreviation of "electronic toll collection" is "ETC".

    • Collect toll from vehicles automatically
  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.m.wikipedia.org/wiki/Electronic_toll_collection

  • The abbreviation of "Electronic Stability Program" is "ESP".

    • Improve a vehicle's stability
      • Detect and reduce loss of traction
  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.wikipedia.org/wiki/Electronic_stability_control

  • The abbreviation of "anti-lock braking system" is "ABS".

    • Anti-skid
  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.wikipedia.org/wiki/Anti-lock_braking_system

  • The abbreviation of "Adaptive Front-Lighting System" is "AFS".

  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.wikipedia.org/wiki/Headlamp#Advanced_front-lighting_system_(AFS)

  • The abbreviation of "milliliter" is "ml".

    • Greater than or equal to 80 milligrams per 100 milliliters
      • Drunken driving in China
  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.wikipedia.org/wiki/Litre#SI_prefixes_applied_to_the_litre

  • The abbreviation of "forward collision warning" is "FCW".

    • To prevent or reduce the severity of a collision
  • Notes
    • Because it appears on the theory driving license test in China.
  • References
    • https://en.wikipedia.org/wiki/Collision_avoidance_system

  • Use "ldd"

    • ldd $(which bash) # List dependencies of bash
      linux-vdso.so.1 (0x00007ffdaa7cb000)
      libreadline.so.8 => /usr/lib/libreadline.so.8 (0x00007f052eba4000)
      libc.so.6 => /usr/lib/libc.so.6 (0x00007f052e9ba000)
      libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007f052e943000)
      /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f052ed25000)
      
  • References
    • https://fasterthanli.me/series/building-a-rust-service-with-nix/part-9
    • tldr ldd

  • Use "sct"

    • sct 1500 # Set color temperature to 1500 Kelvin
  • Notes
    • Warning: does not support Wayland
    • sct # Reset to the default value (e.g. 6500K)
    • nix profile install nixpkgs#sct # Install dependencies
    • Because it is simpler than "redshift".
  • References
    • man sct
    • ChatGPT

  • Some tips in iPhone 14 Pro

    • Maps
      • Double-tap and swipe up to zoom in on the map
      • https://libreddit.nohost.network/r/applemaps/comments/yd14si/why_is_it_so_difficult_to_add_a_place_as_home/ivf2ilp/#ivf2ilp # Set an exact location as home
      • Double-click the navigation icon in upper right corner (Combine compass)
    • Automation
      • The add icon (Automation) - Create Personal Autoamtion (Time of Day - Sunrise - Daily) - Start Timer (1 second)
    • Shortcuts
      • yt-dlp
        - Text (yt-dlp --get-url `Shortcut Input`)
        - Execute Command (Text)
            - no (run in extension) # Open the app to execute the commands?
            - Disable 'Show When Run'
        - Text (outplayer://`output`)
        - Open URLs (Text)
        
      • Random password
        - Text (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
        - Text (abcdefghijklmnopqrstuvwxyz)
        - Text (0123456789)
        - Text (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)
        - List (Select Variable - Select a Magic Variable - Variable Name)
            - Uppercase letters
            - Lowercase letters
            - Number
            - Special characters
        - Ask for Input (Number, Password length)
            - 18 # Default Number
        - Choose from List (List)
            - What character types are to be used? # Prompt
            - Enable 'Select Multiple'
            - Enable 'Select All Initially'
        - Combine Text (Chosen Item, Custom)
        - Split Text (Combined Text, Every Character)
        - Repeat (Provided Input)
            - Get Item from List (Random Item, Split Text)
            - Add to Variable (Item from List, tmp)
        - End Repeat
        - Combine Text (`tmp`, Custom)
        - Text (Combined Text)
        - Show Alert (Text)
            - Copy to clipboard? # Title
        - Copy to Clipboard (Text)
        - https://libreddit.eu.org/r/shortcuts/comments/10bhcxr/the_best_strong_password_generator_shortcut_i/lfbetmp/
        
      • Decode URL
        - Text (Shortcut Input)
        - URL Encode (Decode, Text)
        - Quick Look (URL Encoded Text)
        
        • Remember to enable 'Show in Share Sheet' in Details
      • Check if it is text or file type
        - Text (Text|Safari web page|Rich text|URL)
        - Set Variable (Text type, Text)
        - Get Type (Shortcut Input)
        - Match Text (Text type, Type)
        - If (Matches, has any value)
            - Comment (Do something with the text)
        - Otherwise
            - Comment (Do something with the file)
        - End If
        - https://libreddit.eu.org/r/shortcuts/comments/qioiaa/checking_if_a_text_contains_any_of_the_items_of_a/hilbcih
        
      • Compress image (Temporarily share some pictures with people who have poor network)
        - Convert Image (Shortcut Input, JPEG)
        - Resize Image (Converted Image, Percentage, 30)
        - https://libreddit.eu.org/r/shortcuts/comments/v4dk41/compress_images_shortcut_for_automation_please/ib4834u
        
      • Show random words (Sometimes use random English words as username)
        # Put the words in the text below (Offline is faster than online)
        # You can use action (Get Contents of URL) to get words if you want to use it online
        # Source: https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english.txt 
        - Text
          '''
          the
          of
          and
          ...
          '''
        - Split Text (Text, New Lines)
        - Get Item from List (Random Item, Split Text)
        - Add to Variable (Item from List, Words)
        - Show Result (Words)
        - https://safereddit.com/r/shortcuts/comments/abouso/random_words_generator_request/ed24shu/
        
      • Encode audio as a base64 string
        # Encode
        - Select File
        - Base64 Encode (Encode, File)
        - Copy to Clipboard (Base64 Encoded)
        
        # Decode
        - Text (yourEncodedAudioString)
        - Base64 Encode (Decode, Text)
        - Play Sound (Base64 Encoded)
        - https://libreddit.nohost.network/r/shortcuts/comments/ocryy9/i_just_want_a_shortcut_to_play_a_specific_sound/h3xr7y9/
        
      • Share Wi-Fi QR code
        # This is the core. You can use Get Network Details action to get Wi-Fi name automatically,
        # But it does not support automatically getting the current connected Wi-Fi password
        # You can only manually copy the password in the Password of the Information icon of WLAN of Settings
        - Text (`WIFI:S:yourSsid;T:WPA;P:yourPassword;;`)
        - Generate QR Code (Text)
        - Quick Look (QR Code)
        - https://libreddit.nohost.network/r/shortcuts/comments/11te5ir/need_help_with_wifi_qr_code_generation/jdxly01
        
      • Check if a dictionary only contains one list
        - Get Contents of URL (Text)
        - Get Dictionary from Input (Contents of URL)
        - Count (Items, Dictionary)
        - If (Count, is, 1)
            - Text (Dictionary)
        - Otherwise
            - Replace Text (`Press return key`, , Dictionary)
            - Choose from List (Updated Text)
        - End If
        
      • Arrange the dictionary in reverse order
        Get Dictionary from Input (Contents of URL)
        Replace Text (Dictionary)
        Filter Files (Updated Text)
            Last Modified Date (Sort by)
            Latest First (Order)
        Choose from List (Files)
        Get Dictionary Value (Value, timestamp, Chosen Item)
        Set Variable (Timestamp, Dictionary Value)
        https://m.youtube.com/watch?v=dhu9INl2KOg # Use filter
        
      • Open in Vim
        # Receive Files input from
        # If there's no input: Ask For Files
        - Put File (Shortcut Input)
            - Disable 'Show When Run'
        - Text (Name.File Extension)
        - Execute Command (vim complete filename, exit)
        - Wait to Return
        - Get file (complete filename)
            - Disable 'Show When Run'
        - Save File (File)
            - Enable 'Overwrite If File Exists'
        - https://libreddit.nohost.network/r/shortcuts/comments/1cdhddj/open_in_vim_via_ashell_then_save_in_original/
        
      • Get a JSON value
        - Dictate Text
        - Text (your URL)
        - Get Contents of URL (Text)
          """
          curl \
            -H 'Content-Type: application/json' \
            -d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \
            -X POST 'https://generativelanguage.googleapis.com/...'
          """
            - Method (POST)
            - Headers (Content-Type, application/json)
            - Request Body (JSON)
                - Dictionary (contents)
                - Dictionary (parts)
                - Text (text, Dictated Text)
            - https://aistudio.google.com/app/apikey
            - https://zhile.io/2023/12/24/gemini-pro-proxy.html
        - Get Dictionary Value (Value, candidates.1.content.parts.1.text, Contents of URL)
          """
          {
            "candidates": [
              {
                "content": {
                  "parts": [
                    {
                      "text": "## AI: A Simplified Explanation
                      ...
          """
        - Speak Text (Dictionary Value)
        - https://libreddit.nohost.network/r/shortcuts/comments/11hbokj/parsing_json_help/jasqcgh
        
      • Modify specific value
        - File (iCloud Drive > Shortcust > departmentStore1)
        - Get File from Folder (File Extension, File)
        - Get Name (File)
        - Text (Name.File Extension)
        - Set Variable (Filename, Text)
        - Run Shortcuts (Search For Matching Rows)
        - Split Text (Shortcut Result, Custom, `,`)
        - Get Item from List (Item at Index, 1, Split Text)
        - Set Variable (Product barcode, Item from List)
        - Get Item from List (Item at Index, 2, Split Text)
        - Set Variable (Product name, Item from List)
        - Get Item from List (Item at Index, 3, Split Text)
        - Set Variable (Product price, Item from List)
        - Choose from Menu (Product barcode, Product name, Product price)
            - Ask for Input (Text, Product barcode, Product barcode)
            - Replace Text (`Product barcode, Product name, Product price`, `Provided Input, Product name, Product price`, File)
            - Save File (Updated Text, Shortcuts, Filename, Enable 'Overwrite If File Exists')
            - Quick Look (Saved File, Optional)
            - The remaining two options in the menu can be modified accordingly according to the steps of the first option
        - https://libreddit.nohost.network/r/shortcuts/comments/11b75to/is_there_a_way_to_replace_a_string_in_a_txt_not/j9x6pnz/
        
      • Delete matching rows
        - File (iCloud Drive > Shortcuts > departmentStore1)
        - Get Details of Files (Name, File)
        - Text (`Name`.`File Extension`)
        - Set Variable (File name, Text)
        - Ask for Input (Text, What do you want to search for?)
        - Match Text (`.*Provided Input.*`, File)
        - Choose from List (Matches)
        - Replace Text (`Choose Item  `, File)
            - Paste the line break you copied after 'Chosen Item' (To prevent blank lines)
        - Save File (Updated Text, Shortcuts, File name, Enable 'Overwrite If File Exists')
        - https://libreddit.nohost.network/r/shortcuts/comments/10qbaug/cant_remove_a_line_break/j6rxf92/
        
      • Search for matching rows
        - Get File from Folder (Shortcuts, departmentStore1.csv)
        - Choose from Menu (Dictate, Scan, Type)
            - Dictate text (China Mainland) (Depend on product name you sell)
            - Run Shortcuts (Get Barcode)
            - Ask for Input
        - Match Text (`.*Dictated Text.*`, File)
        - Choose from List (Matches)
        
      • Get unit price
        - Run Shortcut (Get Barcode)
        - Set Variable (Product barcode, Shortcut Result)
        - Get File from Folder (Shortcuts, departmentStore1.csv)
            - `vi departmentStore1.csv`
              """
              barcode,name,price
              6901234567890,water,1
              """
        - Match Text (`Product barcode.*`, File)
            - `.` # Represent any single charater
            - `*` # The preceding character can appear zero or more times
        - Split Text (Matches, Custom, `,`)
        - Get Dictionary from Input (Item at Index, 3, Split Text)
        - Set Variable (Product price, Item from List)
        - Show Result (Product price, Optional)
        - https://utgd.net/article/9410
        
      • Get barcode
        - Scan QR or Barcode
        - Get Text from Input (QR/Barcode)
        - Copy to Clipboard (Text, Optional)
        - Show Result (Text, Optional)
        - https://www.youtube.com/watch?v=4Kemgg3FSjw
        
      • Select JSON arrays
        - Get Dictionary from Input (Contents of URL)
        - Replace Text (`clickReturn`, Dictionary)
            - Delete the line break to display it normally in the list
        - Choose from List (Updated Text)
        
      • Display a notification for a few seconds
        - Run Inline Script (Paste the following code, toggle off "Show When Run")
          """
          let notification = new Notification();
          notification.title = "English";
          notification.body = "`Translated Text`";
          notification.identifier = "my.music.notification";
          notification.schedule();
          Script.complete();
          
          Notification.removeDelivered(["my.music.notification"]);
          Script.complete();
          """
        - https://libreddit.nohost.network/r/shortcuts/comments/16p7iwp/how_can_i_make_notifications_clear/k1p96sz
        
      • Switch App Store region temporarily
        - https://libreddit.nohost.network/r/shortcuts/comments/mpaivg/app_store_region_switcher/
        
      • Open WeChat payment code
        - Dismiss Siri and Continue
        - Open URLs (e.g. `weixin://widget/pay`, `alipays://platformapi/startapp?appId=2018121962599426&page=pages%2FphoneTraffic%2FphoneTraffic%3FpageSource%3Dshouye`)
        - https://gist.github.com/JamesHopbourn/046bc341e7debfd0c86e3b388d983c53#%E5%BE%AE%E4%BF%A1
        - https://sspai.com/post/68497
        
      • Beautify JSON format
        - URL (`data:text/html;charset=utf-8,<script>document.write(encodeURIComponent(JSON.stringify(Shortcut Input,null,2)))</script>`)
        - URL Encode (Decode, URL)
        - https://libreddit.eu.org/r/shortcuts/comments/gqq43h/dictionaryjson_pretty_print/
        
      • Invert image using a-Shell
        - Select Photos
        - Set Variable (Image, Photos)
        - Put File (`Image`)
        - Text (Current Date)
            - Custom # Date Format
            - yyyy-MM-dd-HHmmss (e.g. 2025-09-09-094100)
        - Set Variable (Output file name, Text)
        - Text (convert `Image`.`File Extension` -channel RGB -negate `Output file name`.png)
        - Execute Command (Text)
        - Get File (Output file name.png)
        - Save to Photo Album (File, Recents)
        - Quick Look (Saved Photo Media)
        - https://libreddit.eu.org/r/shortcuts/comments/1cdhddj/open_in_vim_via_ashell_then_save_in_original/l1fk0e2
        
      • Comment out some actions
        - Text (Comment)
        - If (Text, is, Comment)
            - Nothing
        - Otherwise
            - all the actions you want to comment out
        - End If (Tips: Press and hold this action and drag it downwards to perform batch operations)
        - https://libreddit.eu.org/r/shortcuts/comments/prkg46/does_anybody_want_the_ability_to_comment_out/hdkig89
        
      • Extract all values from a JSON structure
        - Get Dictionary from Input (Contents of URL)
        - Repeat with Each (Dictionary)
        - Get Dictionary Value (Value, url, Repeat Item)
        - End Repeat
        - Combine Text (Repeat Results, New Lines)
        - Artificial intelligence
        
      • Get a list of all file names from the API (JSON format)
        - Get Dictionary from Input (Contents of URL)
        - Get Dictionary Value (Value, data.content, Dictionary)
        - Repeat with Each (Dictionary Value)
        - Text (Repeat Item (Type: Dictionary; Key: name))
        - https://medium.com/@richardmoult75/parsing-json-api-lists-with-shortcuts-20df08aedf09
        
      • How many minutes are left today?
        - Get Time Between Dates (Current Date, 00:00, Minutes)
        - Calculate (1440, +, Time Between Dates)
        - Show Result (Calculation Result)
        - https://libreddit.eu.org/r/shortcuts/comments/uh862o/trying_to_make_a_program_that_tells_me_how_many/i74iy1h/
        
      • Convert Image (Shortcut Input, PNG) - Save to Photo Album (Converted Image, Recents) # Convert PDFs (Captured long screen) to PNGs, https://libreddit.tux.pizza/r/ios/comments/epz3wf/how_to_save_a_full_screen_screenshot_as_image_and/femykyb
      • Get each line of a file before playing audiobook randomly
        - Get File from Folder (VLC, audioBook.txt)
        - Split Text (File, New Lines)
        - Get Item from List (Random Item, Split Text)
        - https://libreddit.tux.pizza/r/shortcuts/comments/ma5b8z/last_line_of_file/
        
      • Adjust 8-hour sleep time based on sunrise time
        - Get Weather Forecast (Daily, Current Location)
        - Get Details of Weather Conditions (Sunrise Time, Weather Conditions)
        - **Get Item from List** (Item at Index, 2, Sunrise Time)
        - Adjust Date (Add, 60, minutes, Item from List)
        - Set Variable (Up, Adjusted Date)
        - Create Alarm (`Up`, Get Up)
            - Disable 'Show When Run'
        - Show Notification (Alarm)
            - Time # Title
            - None # Date Format
            - Short # Time Format
        - Adjust Date (Subtract, 510, minutes, Item from List)
        - Set Variable (Down, Adjusted Date)
        - Create Alarm (Adjusted Date, Go To Bed)
            - Disable 'Show When Run'
        - https://libreddit.eu.org/r/shortcuts/comments/r7yezo/automation_8_hours_before_sunrise/hn42v2l/
        
      • The add icon - Add Action - Get Network Details (Cellular, Radio Technology) - if (Network Details, Does not have any value) - ... # Get state of airplane mode to save battery while sleeping, https://snoo.habedieeh.re/r/shortcuts/comments/11cnaf7/comment/ja4tl51
      • The add icon - Add Action - Adjust Date - Set Variable - ... # To play yesterday's CCTV News, https://libreddit.freedit.eu/r/shortcuts/comments/ioiigu/comment/g4e1snd
      • Use URL Scheme
        - Text
            - vlc-x-callback://x-callback-url/stream?url=*yourURL*
            - Or `nplayer-http://192.168.10.100:5244/d/encodedFileName`
            - Or `outplayer://*yourURL*`
        - Open URLs (Text)
        - https://stackoverflow.com/questions/32549439/stream-to-vlc-for-ios-via-url-scheme/68077812#68077812
        
      • Make Siri mute if 'Dismiss Siri and Continue' doesn't work
        - The add icon
        - Add Action
        - Dismiss Siri and Continue
        - Set Voice & Data (4G, Primary)
        - Press power button and say thank you
        - https://www.youtube.com/watch?v=8bw_QEaTBq8
        - https://libreddit.tux.pizza/r/shortcuts/comments/p9kppq/how_do_i_get_siri_to_not_say_ok_or_done_after/j4kq3pg
        - https://libreddit.nohost.network/r/shortcuts/comments/1347p9i/dismiss_siri_and_continue_command_broken/l0eicy9/
        
      • The add icon - Add Action - Categories - Scripting - Set Personal Hotspot - done
      • The add icon - Add Action - Set VPN (Set On Demand, On, Tailscale) - done
    • Text
      • Long press first word and slide down one line # Select the whole line
      • Long press '123' and slide to comma # Enter punctuation marks quickly
      • Long press the dollar sign # Select another country's currency unit symbol (e.g. ¥)
      • Long press the double quotes or disable 'Smart Punctuation' # Choose the ASCII
      • Long press space key # Move cursor quickly
      • Double click / Long press # Select a word
      • Triple click # Select a sentence
      • Swipe left with three fingers # Undo
    • Web
      • Settings - Safari - Advanced - Website Data - Search a domain (e.g. 192.168.10.100) - Restart Safari # Clear a page cache for HTML page changes to take effect (Or new a private tab)
      • Click on the top of screen # Go to the top of web
      • Long press the scroll bar and drag to the bottom # Go to the bottom of web
    • Image
      • Edit - Markup symbol - Color circle - Color picker icon - Drag and release color picker circle - sRGB Hex Color in Sliders tab # Get color code
      • Press Volume up / down button # Take a photograph in Camera
      • Press Volume Up button and power button together # Take a screenshot
      • Full Page - Done - Save PDF to Files # Take a long screenshot
  • Notes
    • Because to improve the efficiency of mobile phone use.
    • Remove update notifications and tags in the Settings
      • https://ios.cfw.guide/blocking-updates/
      • https://sysin.org/blog/disable-ios-update/
    • Overseas Apple ID # To download software (e.g. ChatGPT, Google Translate, etc.)
      • https://web.archive.org/web/20230727113153/https://support.token.im/hc/zh-cn/articles/360008124173-如何注册非中国大陆区-Apple-ID-%2C # Tutorial
      • https://www.meiguodizhi.com/ # Get information about United States
    • Download a proxy sofware (e.g. Shadowrocket)
      • Get a Apple ID that has already purchased Shadowrocket
      • Import subscriptions according to the tutorial
      • https://github.com/wlxuf/Shadowrocket # Hide VPN icon and enable proxy logging
      • https://m.youtube.com/watch?v=heG4YCMyg9w # Select a server automatically
      • https://github.com/hiddify/Hiddify-Server/wiki/Tutorial-for-ShadowRocket-app # Some useful settings
    • Advantages
      • Telephone communication
      • Map navigation
      • Financial transaction
    • Disadvantages
      • Doesn't have an infrared transmitter like Android phones to directly control the air conditioner in the dormitory
      • Cannot set the automatic screen lock time to 30 seconds (Or Never) through parameters # Can only open the page (prefs:root=DISPLAY&path=AUTOLOCK/30) and then tap manually https://gist.github.com/deanlyoung/368e274945a6929e0ea77c4eca345560?permalink_comment_id=5082337#gistcomment-5082337 https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12264354082
      • Mail app does not send real-time notifications # Can only open it manually and pull down to refresh https://libreddit.tux.pizza/r/iphone/comments/12o6w6f/mail_do_not_send_real_time_notifications_until/
      • Can't add video (Except photo) to album
      • No call recording
      • Charging is slow in winter (Charged 37% in 76 minutes)
      • There is no useful e-book reader (e.g. Moon+ Reader), web browser (e.g. Kiwi Browser), or web proxy tool (e.g. Clash)
      • Heavier than Android # It is tired to hold with one hand, it is also heavy in my pocket
      • WiFi receiving signal ability is weaker than Android
      • Can not change the search engine when using Web Search by siri # Depends on the region where you purchased your iPhone https://discussions.apple.com/thread/251986932?answerId=253897800022#253897800022
      • Do not support some commands (e.g. Play a music for 20 minutes) https://www.reddit.com/r/HomePod/comments/li89ag/hey_siri_play_x_for_y_minutes/
  • References
    • https://libreddit.nohost.network/r/ios/comments/rem22v/tip_how_to_get_color_values_using_photos/
    • https://www.howtogeek.com/705342/how-to-set-an-alarm-for-sunrise-or-sunset-on-iphone/
    • https://apple.stackexchange.com/questions/299505/ios-11-default-quotation-mark-changed-to-and
    • Artificial intelligence

  • Act as a position interviewer in ChatGPT

    I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the position position. I want you to only reply as the interviewer. Do not write all the conservation at once. I want you to only do the interview with me. Ask me the questions and wait for my answers. Do not write explanations. Ask me the questions one by one like an interviewer does and wait for my answers. My first sentence is "Hi"I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the position position. I want you to only reply as the interviewer. Do not write all the conservation at once. I want you to only do the interview with me. Ask me the questions and wait for my answers. Do not write explanations. Ask me the questions one by one like an interviewer does and wait for my answers. My first sentence is "Hi"
    
  • Notes
    • Because need to interview when looking for a job.
  • References
    • https://github.com/f/awesome-chatgpt-prompts#act-as-position-interviewer

  • Test driver's license in Dongxiang, Fuzhou City, Jiangxi Province, China

    • Sign up # Bring identity card and pay the fees (2023-07-17)
    • Subject one # Take theory practice exams before booking (2023-08-21)
      • https://archive.org/download/2022_penalties_of_subject_one
      • https://zh.wikipedia.org/zh-cn/交通違例記分制#记分项目
      • https://en.wikipedia.org/wiki/Driver's_license_in_China#Types_of_license
      • Traffic police gesture
    • Subject two # Practice driving, examination room simulation, and two exam opportunities (2023-09-11)
    • Subject three # Practice driving, examination room simulation, and two exam opportunities (2023-10-16)
    • Subject four # Take theory practice exams (2023-11-14)
  • Notes
    • Bring ID card before the exam
    • Pay after each exam appointment
    • Because to prepare for posts that need a driver's license.
  • References
    • https://zh.wikipedia.org/wiki/中华人民共和国机动车驾驶人考试

  • Use "siri"

    • Use FaceTime
      • Facetime my brother # Make a video call to my brother (The contact using iPhone)
    • Use Translate
      • Translate starting walking directions in Mandarin Chinese
    • Use Phone
      • Call my brother # (New contact - Add related name)
      • Show my phone number # Replace my with my father's (Replace phone number with email address)
    • Use Notes
      • Quick note
      • Take a note
      • Show notes about breakfast # Search for string
    • Use Maps
      • Go to the nearby library # (e.g. Bank, Toilet, School, Government affairs service center)
      • End navigation
    • Use Clock
      • Set a timer for 7 minutes # Boil a pot of water
      • Stop the timer # Stop it
      • Set an alarm at fourteen # Lunch break from 13:40
      • Wake me up at five thirty # Cancel 05:30 to cancel
      • Show alarms
      • Delete all of them
    • Use Reminders
      • Remind me to learn Reminders at 15:55 today
      • Read my reminders # Read the upcoming schedule aloud
      • Remind me about this tomorrow at 10 AM # Title of email or website
      • Type a reminder in the app manually # Enable notifications
      • https://libreddit.tux.pizza/r/iphone/comments/xs6cx1/iphone_14_pro_reminders_does_not_work/
    • Use Calendar
      • Create a new event / Schedule purchase breakfast at 7 AM tomorrow
      • Learn Calendar # Title it
      • Right now # One hour from now
      • Change it
      • Cancel Learn Calendar # Cancel it
    • Use Settings
      • What can you do # Discover new commands
      • Enable light mode # Replace light with dark to toggle
      • Open the QR code scanner / Scan the QR code # Open code scanner
      • repeat again # Repeat reply
      • What song is it # Identify a song (Get song title or artist)
      • Next song # Play next music (Doesn't work: Previous song)
      • Restart this device # Solve some bugs
      • Enable Night Shift # Protect eyes
      • What date is it # Replace it with tomorrow (e.g. the day after tomorrow, the end of the month, sunrise)
      • What time is it # What time will it be in eight hours (Current time plus eight hours)
      • Open Translate # Open the application (e.g. Email, Measure: Click on Level to measure whether the height of the manually adjustable talbe is level)
      • Increase volume by 40 percent
      • Reduce the volume by 40 percent
      • Take a screenshot
      • Shutdown # Poweroff
      • Yes # Confirm
      • Disable Wi-Fi / Enable Cellular Data # When need a more stable network
      • Enable Wi-Fi / Disable Cellular Data # When need local area network
      • How much is 1699 dollars in Chinese Yuan? # Convert Dollars to Chinese Yuan (Exchange rate) What's 100 Euros in Dollars
      • What is the current time # Get time when watching video
      • What is the current battery # Get battery When watching video
      • Enable flashlight # Light the way in dark environment
      • Disable flashlight # Turn off it
    • Use Calculator
      • 8904 - 1367
      • Eight thousand nine hundred and four minus one thousand three hundred sixty seven
      • Eight nine zero four minus one three six seven
    • Use Weather
      • What is the weather today
      • When is the sunrise # Time to get up early
    • Use Podcasts
      • Play podcasts about computer # Prepare for posts that need English communication
      • Stop podcasts # Stop
      • Continue podcasts # Continue
    • Use Voice Memos
      • Record voice memo # Record a conversation
  • Notes
    • Activate siri
      • Hey Siri # Method one
      • Long press the power button # Method two
    • Increase precision
      • Pronounce clearly
  • References
    • https://ios.gadgethacks.com/how-to/18-siri-commands-every-iphone-owner-should-know-0385294/
    • https://developer.apple.com/siri/
    • iPhone 14 Pro
    • Artificial intelligence

  • Match various phone number formats in Vim

    • /[0-9]\{11}/ # Match eleven consecutive digits (e.g. 12345678901)
    • /[0-9]\{3} [0-9]\{4} [0-9]\{4}/ # (e.g. 123 4567 8901)
  • Notes
    • /[0-9]\{11}/ # The same as /\d\{11}/
      • \d # Digit
    • /[0-9]\{11}\|[0-9]\{3} [0-9]\{4} [0-9]\{4}/ # Match them together
      • \| # Or
    • Because to contact with employers.
      • In a large amount of recruitment information
  • References
    • ChatGPT

  • If A and B choose to read 2 kinds of books from 6 kinds of books respectively, then there is exactly one kind of books that the two people choose to read in common

    • $(^{n}_{k})=\frac{n!}{k!(n-k)!}$ # Combination formula
    • $0!=1$
  • Notes
    • $(^{n}_{k})$ # $C^{n} _{k}$
      • $C$ # Combination
      • If the set has $n$ elements, the number of $k$-combinations
    • $n!=n\times(n-1)!$ # Factorial of $n$
    • $(n-1)!$ # $(n-1)\times(n-2)\times(n-3)\times\cdots\times3\times2\times1$
    • $C^{1}_{6}C^{1} _{5}C^{1} _{4}$
  • References
    • https://en.wikipedia.org/wiki/Factorial
    • https://en.wikipedia.org/wiki/Combination
    • College Entrance Math in Jiangxi
    • ChatGPT

  • The abbreviation of "Subscriber Identity Module" is "SIM".

    • An integrated circuit
  • Notes
    • Because to buy a mobile phone.
  • References
    • https://en.wikipedia.org/wiki/SIM_card

  • Son of poverty (2023-07-03)

    • Problems
      • Money
      • Family and relatives
  • Notes
    • Because i can not be the poor.
    • The end of my life is the richest person in this era.
    • I always remind myself when i was the poor.
  • References
    • Rockefeller letters

  • I am looking for a job in Yiwu City, Jinhua City, Zhejiang Province, China. (2023-07-02)

    • Phone # Contact with employer
    • Bank card # Provide financial services
  • Notes
    • No summer job found for a high school student (2023-07-10)
      • Around June 10
      • Include food and lodging
      • Academic qualifications of undergraduate (Home teacher)
      • General labor is long-term
      • Sexism
    • Channels for obtaining recruitment information
      • Offline (e.g. Local job market, on the door of the store, etc.)
      • Online (e.g. Search in WeChat, Boss Zhipin, etc.)
    • Some suggestions from a big brother in the dormitory
      • Take the bus to the local job market # The price is cheaper than taking a taxi, but it takes more time than taking a taxi
      • Laundry, shower and brush teeth # Before the roomates come back
      • Charge the primary phone # Before sleeping
      • Put away the umbrella that block the sun # After arriving at a location
      • Pay the part-time job salary to the individual # Have a good relationship with college classmates and teachers
      • Fall in lov # Low cast
      • Be a soldier # Bonus and veterans certificate
      • Communication skills and personal appearance
      • Money and emotion
      • Greet often to understand the world
      • Make a schedule and stick it on the wall
      • Learn to cook for them and for yourself
      • Go to public places (e.g. library, shopping mall, etc.) to release stress
      • Remember that children can do anything as long as they don't violate the law
    • The situation of a restaurant interviewed
      • Position: Crossroads (There are two walls as gates)
      • Background music: Classic music
      • Employee: Pink top, black pants
      • Dining table and stools: Stone and metal, wood
      • Light bulb: White, hang
      • Electric fan: Black, hang
    • Second phone
      • Record (Before the communication interview)
      • Clock (When sleeping at night)
      • Game manager (Build a reward and punishment mechanism to motivate)
      • Exercise (Sweating every day makes the body organs go on the road of sustainable development)
      • Music (When taking a shower)
    • Before going to other cities
      • Bring backpack and suitcase
  • References
    • https://en.wikipedia.org/wiki/List_of_largest_banks
    • Google # Labor Law site:https://www.gov.cn/

  • Use "nmcli"

    • nmcli device wifi connect yourSSID password yourPassword # Connect
  • Notes
    • Enable hotspot
      • nmcli device wifi hotspot con-name yaoniplan ssid yaoniplan password yaoniplan
      • nmcli connection delete bfc2c6fa-eb8c-472c-b278-5953ec224e33 # Delte the hotspot
      • nmcli connection show # Get the UUID
    • Solve the problem
      Jul 16 16:33:19 tux NetworkManager[376]: <warn>  [1721118799.2087] device (wlan0): ip:shared4: could not start dnsmasq: Could not find "dnsmasq" binary
      
      • doas pacman --sync dnsmasq
      • https://libreddit.nohost.network/r/archlinux/comments/acjn5g/networkmanager_hotspot_error_ip_configuration/ed8id5l/
    • nmcli device wifi list # Get the SSID
    • Connect to a wired network
      • nmcli connection up eno1 # Connect
      • nmcli device status # Get the DEVICE
    • Disconnect
      • nmcli connection down yourUUID # Disconnect
      • nmcli connection show # Get the yourUUID
    • doas pacman --sync networkmanager # Install dependencies
      • doas systemctl enable NetworkManager --now # Solve the problem
        Error: NetworkManager is not running
        
    • Because to connect to WiFi when there is no network cable.
    • Solve the problem
      [yaoniplan@tux ~]$ lspci
      ...
      03:00.0 Network controller: Broadcom Inc. and subsidiaries BCM43142 802.11b/g/n (rev 01)
      [yaoniplan@tux ~]$ nmcli device wifi list
      [yaoniplan@tux ~]$
      
      • doas pacman --sync broadcom-wl # Install the correct driver
      • doas reboot # Reboot to make it effective
    • Solve the problem
      [yaoniplan@tux ~]$ nmcli device wifi connect CMCC-ENQy password 1234567a
      Error: Failed to add/activate new connection: Not authorized to control networking.
      [yaoniplan@tux ~]$
      
      • doas nmcli device wifi connect CMCC-ENQy password 1234567a # Run the command with root privileges
  • References
    • lspci # List PCI devices
    • nmcli # Network manager command line
    • ChatGPT

  • Use "vlc"

    • vlc yourURL
  • Notes
    • Options
      • --fullscreen
      • --rate 2
    • Hotkeys
      • Ctrl-q # Quit VLC
      • f # Full screen
      • m # Mute
      • ] # Speed up
      • Space # pause
    • nix shell nixpkgs#vlc # Install dependencies temporarily
  • References
    • Tools - Preferences - Hotkeys

  • Use "smplayer"

    • vi ~/.config/smplayer/smplayer.ini
      [%General]
      global_speed=true
      mute=true
      speed=2
      
      [gui]
      close_on_finish=true
      compact_mode=true
      fullscreen=true
      
      [advanced]
      actions_to_run=fullscreen
      
    • Ctrl-l # Playlist
    • Ctrl-c # Compact mode
    • -close-at-end
    • Ctrl-p # Preferences
    • Shift-t # Increase substitle size
    • Ctrl-q # Quit it
    • smplayer yourURL
    • -sub "yourSubtitlesName" # Subtitles
    • f # Full screen
      • -fullscreen
    • } # Double speed
    • m # Mute
  • Notes
    • Solve the problem of garbled fonts
      • Select 'UTF-8 (UTF-8)' of 'Encoding' in 'Subtitles' of 'Preferences'
    • doas pacman --sync smplayer mplayer # Install dependencies
    • Because to play videos online more stably.
  • References
    • https://www.smplayer.info/en/faq
    • man smplayer
    • man mplayer
    • ChatGPT

  • Use "audacious"

    • audacious yourAudioFile
  • Notes
    • Ctrl-q # Quit it
    • nix shell nixpkgs#audacious # Install dependencies temporarily
  • References
    • ChatGPT

  • If the function $f(x)=\sin (wx+\varphi)$ in the interval $(\frac{\pi}{6},\frac{2\pi}{3})$ increases monotonously, the straight line $x=\frac{\pi}{6}$ and $x=\frac{2\pi}{3}$ are the two symmetry axes of the image of the function $y=f(x)$, then $f(-\frac{5\pi}{12})=$

    • $T=\frac{2\pi}{|w|}$ # The formula for period
  • Notes
    • Get the value of $w$
      • $\frac{T}{2}=\frac{2\pi}{3}-\frac{\pi}{6}$
    • Get the value of $\varphi$
      • $2\times \frac{2\pi}{3}+\varphi=\frac{\pi}{2}$
    • $\sin(-\frac{5\pi}{3})$ # $\sin(-\frac{5\pi}{3}+2\pi)$
  • References
    • College Entrance Math in Jiangxi
    • ChatGPT

  • Merge the 10 commmits into 1 commit in Git

    • git rebase --interactive HEAD~10
    • Replace 'pick' with 'squash'
      # Except the first one
      pick commit1hash Commit message 1
      squash commit2hash Commit message 2
      squash commit3hash Commit message 3
      ...
      
    • git log # Verify it
    • git push git@192.168.10.100:/var/git/note.git development --force
  • Notes
    • Warning: This is potentially destructive unless you are an adventurer.
    • Pull the code in server
      • git pull origin development --rebase
    • git commit --amend # Modify the latest commit message
  • References
    • ChatGPT

  • If $O$ be the coordinate origin of the plane coordinate system, randomly pick a point $A$ in the area $\{(x,y)|1\le x^{2}+y^{2}\le 4\}$, then the probability that the inclination angle of straight line $OA$ is not greater than $\frac{\pi}{4}$ is

    • $(x-a)^2+(y-b)^2=r^2$ # Circle equation
    • $radians=\frac{degrees}{180\degree}\times \pi$ # The conversion formula
  • Notes
    • $(a,b)$ # Center coordinate
    • $r$ # Radius
    • $P=\frac{2\times \frac{\pi}{4}}{\frac{360\degree}{180\degree}\times \pi}$
  • References
    • 2023-06-26_19-46.png
    • https://en.wikipedia.org/wiki/Slope#Algebra_and_geometry
    • https://en.wikipedia.org/wiki/Radian
    • https://en.wikipedia.org/wiki/Circle
    • College Entrance Math in Jiangxi
    • ChatGPT

  • The abbreviation of "trade mark" is "TM".

  • Notes
    • Because see it on some websites.
  • References
    • https://en.wikipedia.org/wiki/Trademark

  • Simulate mobile devices in Chromium

    • Ctrl-Shift-c # Open the developer tools and inspect elements
    • Ctrl-Shift-m # Toggle mobile devices
  • Notes
    • Ctrl-Shift-i # Close the developer tools
    • Because to test the compatibility of yaoniplan.eu.org on mobile devices.
  • References
    • ChatGPT

  • If the even function $f(x)= \frac{xe^x}{e^{ax}-1}$, then $a=$

    • $f(-x)=f(x)$ # Even functions
    • $b^{n+m}=b^{n}\times b^{m}$ # The property of exponentiation
    • $b^{0}=1$ # Zero exponent
    • Denominator is not zero
  • Notes
    • $f(-x)=\frac{-xe^{-x}}{e^{-ax}-1}$ # $\frac{-xe^{-x}\times{e^{ax}}}{(e^{-ax}-1)\times{e^{ax}}}$ (Algebra)
      • $e^{ax-x}=e^{x}$
      • $e^{ax}-1\neq0$
  • References
    • https://en.wikipedia.org/wiki/Division_by_zero
    • https://en.wikipedia.org/wiki/Exponentiation
    • https://en.wikipedia.org/wiki/Even_and_odd_functions#Even_functions
    • College Entrance Math in Jiangxi
    • ChatGPT

  • If side length of the small square is $1$, then the surface area of the three view is

    • $SA=6s^{2}$ # Cube surface area formula
      • $SA$ # Surface area
      • $s$ # Side length
    • $SA=2(lw+lh+wh)$ # Cuboid surface area formula
      • $l$ # Length
      • $w$ # Width
      • $h$ # Height
    • three view
      • Front and side view
      • Top view
  • Notes
    • $SA=6\times2^{2}+2(1\times1+1\times2+1\times2)-2\times1-2\times1$ # Method one
    • $SA=2(2\times2+2\times3+2\times3)-1\times1-1\times1$ # Method two
  • References
    • https://en.wikipedia.org/wiki/Surface_area
    • 2023-06-22_22-00.png
    • College Entrance Math in Jiangxi
    • ChatGPT

  • Use "jupyter"

    • Esc # Return to command mode (Vi-like)
      • h # Show keyboard shortcuts
      • z # Undo
      • Shift-m # Merge a cell below
      • m # Markdown
      • y # Code
      • j / k # Down / Up (Vi-like)
      • Enter # Insert (Vi-like)
      • dd # Delete current cell (Vi-like)
      • a # Above the current cell (Insert a new cell)
      • b # Below (Insert a new cell)
    • First use
      • New # Python 3
      • print("Hello, yaoniplan!") # Shift-Enter
      • Ctrl-s # Save file
    • Set dark mode
      • !pip install jupyterthemes # Install dependencies
      • !jt --list # List available themes
      • !jt --theme gruvboxd # Need to restart the jupyter server to apply changes
      • !jt --reset # Reset to the defualt theme
    • Import and use matplotlib
      pip install matplotlib # Install dependencies
      x = [1, 2, 3, 4, 5] # Assign list to variable
      y = [2, 3, 4, 5, 6]
      
      from matplotlib import pyplot as plt # Set an alias to 'plt'
      fig1 = plt.figure(figsize=(5, 5)) # 5 rows and 5 colums
      plt.plot(x, y) # Linear graph (Replace plot with scatter to draw a scatterplot)
      plt.title('y vs x')
      plt.xlabel('x')
      plt.ylabel('y')
      plt.show()
      
    • Import numpy, generate and manipulate arrays
      import numpy as np
      a = np.eye(5) # Generate an array
      print(type(a))
      print(a)
      
      b = np.ones([5, 5]) # Generate an array of 5 rows and 5 columns with all 1s
      print(type(b))
      print(b)
      print(b.shape)
      
      c = a + b # Array addition operation
      print(type(c))
      print(c.shape)
      print(c)
      
    • Import and use pandas
      import pandas as pd
      data = pd.read_csv('data.csv') # Read the file called 'data.csv'
      
      print(type(data))
      print(data)
      
      x = data.loc[:, 'x'] # Locate the data in the column called 'x'
      print(type(x))
      y = data.loc[:, 'y']
      print(y)
      
      c = data.loc[:, 'x'][y > 50] # Add conditions with 'y' greater than 50
      print(c)
      
      data_array = np.array(data) # Convert type to array
      print(type(data_array))
      print(data_array)
      
      data_new = data + 10
      data_new.head()
      
      data_new.to_csv('data_new.csv') # Save the file as 'data_new.csv'
      
  • Notes
    • nix-shell --command 'jupyter notebook' --packages jupyter # Use temporarily
    • In Docker-compose
      • vim ~/.config/notebook/docker-compose.yml
        version: '3'
        services:
          jupyter:
            image: jupyter/base-notebook
            restart: always
            ports:
              - 8888:8888
            volumes:
              - ./:/home/jovyan/
        
      • docker-compose up --detach # Run in the background
      • docker exec -i -t notebook-jupyter-1 jupyter server list # Get token
      • 192.168.10.100:8888/tree/ # Run in a browser on another computer
  • References
    • https://archive.org/download/1-6-pandas-numpy-matplotlib
    • https://github.com/jupyter/notebook/issues/5286
    • https://stackoverflow.com/questions/46510192/change-the-theme-in-jupyter-notebook/46561480#46561480
    • https://www.codecademy.com/article/getting-more-out-of-jupyter-notebook
    • https://github.com/jupyter/notebook
    • nix-shell --help
    • ChatGPT

  • Use "emacs"

    • Ctrl-x b # Buffer
    • Ctrl-n # Next line
    • Ctrl-p # Previous line
    • Ctrl-s # Search for a string
    • Ctrl-x Ctrl-f # Find a file
    • Ctrl-x Ctrl-s # Save file
    • Ctrl-y # Paste contents deleted by the shortbut key just now
    • Ctrl-w # Delete to beginning of line
    • Delete the current line
      • Ctrl-a # Move the cursor to the beginning of the line
      • Ctrl-k # Delete to end of line
    • Ctrl-x u # Undo
    • Ctrl-e # Move the cursor to the the end of a line
    • Ctrl-x Ctrl-c # Quit the emacs
  • Notes
    • emacs ~/.emacs
      (setq inhibit-startup-screen t) ; Close the help page at boot time
      (load-theme 'manoj-dark t) ; Load manoj-dark theme
      (tool-bar-mode -1) ; Close tool bar
      (scroll-bar-mode -1) ; Close scroll bar
      (menu-bar-mode -1) ; Close menu bar
      
      • Alt-x load-theme # Load a theme
    • nix shell nixpkgs#emacs # Install dependencies temporarily
  • References
    • https://book.emacs-china.org/
    • ChatGPT

  • Use "nano"

    • Ctrl-c # Break the current operation (Like Shell)
    • Alt-u # Undo (Like Vi's u)
    • Ctrl-h # Delete one letter to the left (Like Vi)
    • Ctrl-x # Exit the nano
  • Notes
    • nix shell nixpkgs#nano # Install dependencies temporarily
  • References
    • ChatGPT

  • Use "less"

    • less ~/.bash{rc,_profile}
  • Notes
    • ~/.bash{rc,_profile} # ~/.bashrc and ~/.bash_profile
    • :n # Next file
    • :p # Previous file
    • Scrool page
      • f # Forward (Same as Space on Chromium)
      • b # Backward (Same as Shift-Space on Chromium)
      • Ctrl-[ } # Right one half screen width
  • References
    • h
    • ChatGPT

  • Run a web server in Docker

    • vi ~/note/Dockerfile
      FROM nginx:latest
      COPY . /usr/share/nginx/html/
      
    • docker build --tag yaoniplan ~/note/ # Build a Docker image
    • docker run --detach --publish 2003:80 yaoniplan # Run the Docker container
    • 192.168.10.105:2003 # Run in Chromium
  • Notes
    • vi compose.yaml # Start at boot
      services:
        todo:
          build: .
          container_name: todo
          restart: always
          ports:
            - "2006:80"
      
      • docker compose up --detach # Run in the background
    • vi Dockerfile # A lightweight method
      FROM busybox
      COPY . /app
      CMD httpd -f -p 80 -h /app
      
      • FROM busybox # Use BusyBox as the base image
      • COPY . /app # Copy files from your local file system into Docker image
      • CMD # Execute commands when the container is running
      • -f # Run in the foreground
      • -p 80 # Bind the HTTP server to port 80
      • -h /app # Specify the home directory for the server as /app
    • yaoniplan # Replace it with your desired name
    • 2003 # Replace it with your desired port
    • Update it
      • docker build --tag yaoniplan:0.0.1 note/
  • References
    • httpd --help
    • ChatGPT

  • The abbreviation of "Local Area Network" is "LAN".

    • A computer network
      • Interconnect computers
      • Within a limited area
  • References
    • https://en.wikipedia.org/wiki/Local_area_network
    • ChatGPT

  • Enable the docker daemon in Nix

    • doas dockerd # Run the docker daemon
    • bg # Type this command after pressing 'Ctrl-z'
  • Notes
    • Solve the problem
      yaoniplan@tux ~/testMath $ docker ps
      Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
      yaoniplan@tux ~/testMath $
      
  • References
    • https://github.com/docker/for-linux/issues/535#issuecomment-676861423

  • Check if a file is a symbolic link in Bash

    • vi ~/.local/bin/convertMarkdownToHtml.sh
      if [[ ! -f "$readmeFile" || -L "$readmeFile" ]]; then
          ln -s $(ls -1 "$journalsDir"/* | tail -1) "$readmeFile"
      fi
      
  • Notes
    • -L # Link
  • References
    • man bash # /-L
    • ChatGPT

  • The abbreviation of "Digital Versatile Disc" is "DVD".

    • A format
    • To Store data
  • Notes
    • Because to replace Linux server with other Linux distributions.
  • References
    • https://en.wikipedia.org/wiki/DVD

  • Set a static IP in Arch Linux

    • doas vim /etc/systemd/network/enp2s0.network
      [Match]
      Name=enp2s0
      
      [Network]
      DHCP=no
      Address=192.168.10.100/24
      Gateway=192.168.10.1
      
    • doas systemctl enable systemd-networkd # Run at boot time
    • doas systemctl restart systemd-networkd # Apply changes
  • Notes
    • systemctl status systemd-networkd > network.log # Analyze the log file if not working properly
      Apr 19 23:17:35 tux systemd-networkd[2408]: enp2s0:
      Configuring with /etc/systemd/network/20-ethernet.network.
      
      • Modify the specified configuration file
    • Set two static IP addresses in Arch Linux
      ...
      
      [Address]
      address=192.168.10.10/24
      
    • enp2s0 # Replace it with your interface name
      • ip address # Get it
    • 192.168.10.100 # Replace it with your desired static IP address
    • 192.168.10.1 # Replace it with your default gataway
      • ip route | awk '/default/ {print $3}' # Get it
    • Enable DHCP to get an IP address from another new router
      • doas vim /etc/systemd/network/enp2s0.network
        [Match]
        Name=enp2s0
        
        [Network]
        DHCP=yes
        
      • doas systemctl restart systemd-networkd # Apply changes
  • References
    • ChatGPT

  • If $z={\frac{2+i}{1+i^2+i^5}}$, then $\bar{z}=$

    • $i^2=-1$ # Imaginary unit i formula
    • If $z=a+bi$, then $\bar{z}=a-bi$ # Complex conjugate formula
      • $bi\times(-1)$
    • Positive real number
      • Positive: The real part must be positive ($a>0$)
      • Real number: The imaginary part must be zero ($b=0$)
    • $|z|=\sqrt{(a-0)^{2}+(b-0)^{2}}$ # Modulus is the distance from the origin $(0,0)$ to the point $(a,b)$
      • $a^{2}+b^{2}=c^{2}$ # Pythagorean theorem in the right triangle
    • Equality of complex numbers
      • Two complex numbers are equal if their real parts are the same and their imaginary parts are the same
      • $(1+i)x=1+yi$ # ($x=1, x=y$)
  • Notes
    • Simplify (To get form $z=a+bi$)
      • Expand (e.g. $i^{5}$, $i^{2}i^{2}i$)
      • Isolate $z$ to one side # (e.g. $\frac{1+z}{1-z}=i$, $1+z=i(1-z)$, $z(1+i)=i-1$)
    • $2+i \over i$ # $(2+i)i \over ii$ (Algebra)
  • References
    • https://unacademy.com/content/jee/study-material/mathematics/all-about-equality-of-complex-numbers/
    • https://en.wikipedia.org/wiki/Pythagorean_theorem#Complex_numbers
    • https://en.wikipedia.org/wiki/Absolute_value#Complex_numbers
    • https://en.wikipedia.org/wiki/List_of_universities_and_colleges_in_Beijing
    • If a complex number $z$ satisfies $\frac{1+z}{1-z}=i$, then $|z|=$
    • If $(a+i)^{2}i$ is a positive real number, then $a=$
    • College Entrance Math in Jiangxi
    • Explain it using knowledge points # ChatGPT

  • If the sets $U=R$, $M=\{x|x<1\}$, $N=\{x|-1<x<2\}$, then $\{x|x \ge 2\}=$

    • $C_U(M \cup N)$ # $U-(M \cup N)$
      • $C_U$ # Complement of a set
      • $ \cup $ # Union of sets
      • $U$ # Universal set
    • $C_U(A \cap B)$
      • $ \cap $ # Intersection of sets
  • Notes
    • $\{x|x \ge 2\}$ # $U-(M \cup N)$
      • $M \cup N$ # $\{x|x<2\}$
  • References
    • College Entrance Math in Jiangxi
    • ChatGPT

  • Set background color in HTML

    • vi ~/note/assets/index.html
      <head>
        <style>
          html {
            background-color: #0d1117;
          }
        </style>
      </head>
      
  • Notes
    • html # Replace it with body (Is ok)
    • 0d1117 # Replace it with your desired color code in hexadecimal format
    • Because to enable dark mode fully.
  • References
    • ChatGPT

  • Use "tldr"

    • tldr links
  • Notes
    • links # Replace it with your desired command
    • nix shell nixpkgs#tldr # Install dependencies temporarily
  • References
    • TL;DR # Too long; didn't read
    • ChatGPT

  • Use "links"

    • links yaoniplan.eu.org
    • links -dump https://example.com > output.txt # Save as a text file
  • Notes
    • Ctrl-r # Reload
    • Scoll pages
      • Ctrl-f # Forward
      • Ctrl-b # Backward
      • Ctrl-p # Previous
      • Ctrl-n # Next
      • ] # Right
    • /nix" # Search
      • n # Next
    • yaoniplan.eu.org # Replace it with your desired URL (e.g. suckless.org, 192.168.10.100:2003, etc.)
      • ~/note/assets/index.html # Local HTML file is also fine
    • nix shell nixpkgs#links2 # Install dependencies temporarily
  • References
    • man links
    • tldr links

  • Make .nix-profile/bin/ effective in Dmenu

    • vi ~/.bash_profile
      if [[ -d "$HOME/.nix-profile/bin/" ]]; then
          export PATH="$PATH:$HOME/.nix-profile/bin/"
      fi
      
    • reboot # Reboot the operating system
    • rm ~/.cache/dmenu_run # Clear cache
  • References
    • https://www.reddit.com/r/NixOS/comments/y4k9iz/comment/jnrouk7/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

  • Understand "B84 W58 H83"

    • B # Bust
    • 84 # 84 cm
    • W # Waist
    • H # Hip
  • Notes
    • To determine the appropriate size of clothing
  • References
    • Dragon Knight III (ドラゴンナイトIII) #NSFW

  • Use "pandoc"

    • pandoc -s --katex -o index.html index.md
  • Notes
    • Solve the problem that some symbols cannot be rendered
      • git https://github.com/KaTeX/KaTeX # Download the fonts
      • mv ./KaTeX/fonts/ ~/note/assets/ # Move them into your assets
    • vi ~/notes/assets/index.html # Another way
      <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.css" integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI" crossorigin="anonymous">
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.js" integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t" crossorigin="anonymous"></script>
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
      </head>
      <body>
        <script>
          // Render all KaTeX expressions on the page
          document.addEventListener("DOMContentLoaded", function() {
            renderMathInElement(document.body, {
              delimiters: [
                { left: "$$", right: "$$", display: true },
                { left: "$", right: "$", display: false }
              ]
            });
          });
        </script>
      </body>
      
    • vi ~/note/assets/index.html # Another way
      <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.css" integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI" crossorigin="anonymous">
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.js" integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t" crossorigin="anonymous"></script>
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"></script>
        <script>
            document.addEventListener("DOMContentLoaded", function() {
                renderMathInElement(document.body, {
                  // customised options
                  // • auto-render specific keys, e.g.:
                  delimiters: [
                      {left: '$$', right: '$$', display: true},
                      {left: '$', right: '$', display: false},
                      {left: '\\(', right: '\\)', display: false},
                      {left: '\\[', right: '\\]', display: true}
                  ],
                  // • rendering keys, e.g.:
                  throwOnError : false
                });
            });
        </script>
      </head>
      
    • vi ~/note/assets/index.html # Another way
      <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML"></script>
      </head>
      
      • Warning: Does not work for inline mode
    • vi ~/note/assets/index.html # Another way
      <head>
        <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
        <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
      </head>
      
      • Warning: Use \( ... \) instead of $ ... $
    • vi ~/note/assets/index.html # Another way
      <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML"></script>
        <script src="../assets/mathjax-config.min.js"></script>
        </script>
      </head>
      
      • vi ~/note/assets/mathjax-config.min.js
        MathJax.Hub.Config({tex2jax:{inlineMath:[['$','$'],["\\(","\\)"]],processEscapes:!0}});
        
    • -s # Standalone
    • -o # Output
    • nix profile install nixpkgs#pandoc # Install the dependency
  • References
    • https://katex.org/docs/autorender.html
    • ChatGPT

  • Use mathematical formulas in Markdown

    • Default
      • $b=0$ # Equal
      • $a>0$ # Greater than
      • $|z|=2$ # Modulus (Absolute value)
    • $|z|=\sqrt{a^{2}+b^{2}}$ # $|z|=\sqrt{a^{2}+b^{2}}$
    • $radians=\frac{degrees}{180\degree}\times \pi$ # $radians=\frac{degrees}{180\degree}\times \pi$
    • $e^{ax}-1\ne0$ # $e^{ax}-1\ne0$
    • $6\times2^{2}$ # $6\times2^{2}$
    • $\frac{2+i}{i}$ # $\frac{2+i}{i}$
    • $\\{x|x\ge2\\}=U-(M \cup N)$ # $\{x|x\ge2\}=U-(M \cup N)$
    • $\bar{z}=$ # $\bar{z}=$
    • $A \cap B$ # $A \cap B$
    • $b\perp(b-4a)$ # $b\perp(b-4a)$
    • $u \cdot v=0$ # $u \cdot v=0$
    • $\overrightarrow{AB}=\vec{c}$ # $\overrightarrow{AB}=\vec{c}$
    • $\triangle ABC$ # $\triangle ABC$
    • $\cos90\degree$ # $\cos90\degree$
  • Notes
    • \degree
    • \triangle # Triangle
    • \overrightarrow{} # Over right arrow
    • \vec{} # Vector
    • \cdot # Centered dot
    • \perp # Perpendicular
    • \cap # Intersection
    • \sqrt{} # Square root
    • \ne # Not equal to
    • \times
    • ^{} # Superscript
    • \frac{}{} # Fraction
      • \over # Another way (Numerator divided by denominator)
    • _{} # Subscript
    • \cup # Union
    • \ge # Greater than or equal to
      • \le # Less than or equal to
  • References
    • https://en.wikibooks.org/wiki/LaTeX/Mathematics
    • https://docs.moodle.org/402/en/Using_TeX_Notation
    • https://wumbo.net/symbols/union/ # Replace union with other symbol (e.g. intersection)
    • ChatGPT

  • Use "convert"

    • convert ~/note/assets/2024-06-06-124844.jpeg -channel RGB -negate ~/note/assets/2024-06-06-124844.jpeg # Invert colors (Dark mode)
    • convert +append 230614102157.jpg 230614102435.jpg 221128keyboardManual.jpg
    • convert 231012seeADentist.HEIC 231012seeADentist.png
  • Notes
    • Stitch images vertically (Like a waterfall)
      • convert -append math{01..04}.png mathVertically.png
    • nix profile install nixpkgs#imagemagick # Install the dependency
  • References
    • https://superuser.com/questions/1194468/invert-colors-with-imagemagick/1194469#1194469
    • ChatGPT

  • The abbreviation of "GNU Image Manipulation Program" is "GIMP".

  • Notes
    • Because to edit a PDF file to remove some commercials.
      • LibreOffice (Achieve the purpose)
      • Open (Ctrl-o) - Frame the part (Click and drag) - Backspace - Export as PDF
  • References
    • nix search nixpkgs#gimp

  • Set the environment variable LOCALE_ARCHIVE in Nix

    • echo 'export LOCALE_ARCHIVE="/usr/lib/locale/locale-archive"' >> ~/.bashrc
  • Notes
    • Solve the problem
      yaoniplan@tux ~ $ nix shell nixpkgs#cowsay --command cowsay Hello, yaoniplan!
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
              LANGUAGE = (unset),
              LC_ALL = (unset),
              LANG = "en_US.UTF-8"
          are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      
    • source ~/.bashrc # Remember to make it effective
  • References
    • https://nixos.wiki/wiki/Locales
    • 2023-06-14_15-11.png

  • Make .bashrc effective when new a terminal

    • vim ~/.bash_profile
      if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
      
  • Notes
    • -f # File
  • References
    • ChatGPT

  • Use "nix"

    • nix profile install github:abenz1267/walker # Build a software (Spend a lot of time)
    • nix profile install nixpkgs/24fe8bb4f552ad3926274d29e083b79d84707da6#obs-studio # Install lower version packages
      • https://www.nixhub.io/packages/obs-studio
    • nix search nixpkgs#firefox # Search for the package
      • nix search nixpkgs opencv # Another way
      • https://search.nixos.org/ # Method two
    • nix flake new --template github:the-nix-way/dev-templates#node testNode # Create a node project in directory testNode
      • nix develop # Enter a development environment after writing flake.nix
    • nix shell nixpkgs#git # Install a package temporarily
      • nix-shell --command 'jupyter notebook' --packages jupyter # Use temporarily
      • nix shell nixpkgs#firefox --command firefox yourURL # Use temporarily
      • nix-shell --packages python310Packages.numpy python310Packages.opencv4 # Another way
      • nix shell nixpkgs#fortune nixpkgs#cowsay --command sh -c 'fortune | cowsay'
    • nix profile install nixpkgs#hello # Install a package permantently
      • nix profile upgrade /nix/store/b0z563zg65fnxaqp612cbxv7x5y7pnz2-foot-1.16.2 # Upgrade a package
      • nix profile remove /nix/store/2g3jazymqbjw9c390c3b7vw8xq3r8iny-hello-2.12.1 # Remove it
      • nix profile list # List installed packages
  • Notes
    • Fix API rate limiting issues in GitHub
      yaoniplan@tux /tmp/tmp.ItcK2amanT $ nix flake new -t templates#go-hello .
      error:
             … while fetching the input 'github:NixOS/templates'
      
             error: unable to download 'https://api.github.com/repos/NixOS/templates/commits/HEAD': HTTP error 403
      
             response body:
      
             {"message":"API rate limit exceeded for 35.77.62.80. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}
      yaoniplan@tux /tmp/tmp.ItcK2amanT $
      
      • doas vim /etc/nix/nix.conf
        access-tokens = github.com=yourPersonalAccessToken
        
      • export GITHUB_TOKEN="yourPersonalAccessToken" # Another way (Warning: It does not work sometimes.)
      • yourPersonalAccessToken # Replace it with your PAT (In "Personal access tokens" of "Developer Settings", need to grant 'repo' access)
    • Solve the problem
      error: Must provide at least one regex! To match all packages, use 'nix search <installable> ^'.
      Try 'nix --help' for more information.
      
      • nix search nixpkgs#tofi ^ # Add a regex
    • Solve the problem
      error: writing to file: No space left on device
      
      • nix-collect-garbage # Delete unreachable store objects
      • nix store optimise # Replace identical files in the store by hard links
      • https://libreddit.nohost.network/r/NixOS/comments/1cunvdw/friendly_reminder_optimizestore_is_not_on_by/
    • Solve the problem
      yaoniplan@tux ~ $ nix upgrade-nix
      error: directory '/home/yaoniplan/.nix-profile/bin' does not appear to be part of a Nix profile
      yaoniplan@tux ~ $
      
      • ls -l $(which nix) # Get Nix executable path
      • nix profile remove /nix/store/smfmnz0ylx80wkbqbjibj7zcw4q668xp-nix-2.19.2/bin/nix # Remove the package
      • /nix/store/iwgkck1d64s5f26ngln540hpf06g28py-nix-2.20.1/bin/nix profile install nixpkgs#nix # Reinstall the package
      • https://github.com/NixOS/nix/issues/5473#issuecomment-1309181669
    • Solve the problem
      ...
      It seems the build group nixbld already exists, but
      with the UID 967. This script can't really handle
      that right now, so I'm going to give up.
      
      You can fix this by editing this script and changing the
      NIX_BUILD_GROUP_ID variable near the top to from 30000
      to 967 and re-run.
      ...
      
      • doas rm -rf /nix/ ~/.nix* # Uninstall Nix
      • compgen -u # List all users
      • for user in nixbld{01..10}; do sudo userdel $user; done # Delete the users created by Nix
      • doas groupdel nixbld # Delete the Nix group
    • Solve the problem
      yaoniplan@tux ~ $ nix search nixpkgs#excel
      error:
             … while fetching the input 'github:NixOS/nixpkgs/nixpkgs-unstable'
      
             error: creating directory '/nix/store/tmp-2004-1': Permission denied
      yaoniplan@tux ~ $
      
      • doas chown -R $(whoami) /nix/store/ # Change the owner
    • Solve the problem
      yaoniplan@tux ~ $ nix-shell -p nix-info --run "nix-info -m"
      error:
           … <borked>
      
             at «none»:0: (source not available)
           ...
      
      • nix-channel --update
    • Enable flakes
      error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it
      
      • echo "experimental-features = nix-command flakes" | doas tee -a /etc/nix/nix.conf
    • doas vim /etc/nix/nix.conf # Set mirror in Nix
      substituters = https://mirrors.ustc.edu.cn/nix-channels/store https://cache.nixos.org/
      
      • nix-channel --add https://mirrors.ustc.edu.cn/nix-channels/nixpkgs-unstable nixpkgs
      • nix-channel --update
    • curl -L https://nixos.org/nix/install | sh # Install Nix package manager
      • -L # Location
      • wget -O- https://nixos.org/nix/install | sh # Another way to install
      • -O- # The same as -L of curl
      • source ~/.nix-profile/etc/profile.d/nix.sh # Apply changes
      • doas rm -rf /nix/ /etc/nix/ ~/.nix-{profile,defexpr,channels} # Uninstall
  • References
    • https://discourse.nixos.org/t/flakes-provide-github-api-token-for-rate-limiting/18609
    • 2023-06-12_21-57.png
    • https://docs.fluidattacks.com/development/stack/nix/#troubleshooting
    • https://github.com/the-nix-way/dev-templates
    • https://github.com/NixOS/nix/issues/7937#issuecomment-1455013868
    • https://xeiaso.net/blog/nix-flakes-1-2022-02-21
    • https://nixos.wiki/wiki/Flakes
    • https://www.youtube.com/watch?v=o1Y7rWrPEO8
    • https://ghedam.at/a-tour-of-nix-flakes
    • https://mirrors.ustc.edu.cn/help/nix-channels.html
    • https://github.com/NixOS/nix
    • nix profile --help
    • man curl
    • Artificial intelligence

  • Solve the problem in Nix

    export NIX_EXPERIMENTAL_FEATURES="nix-command flakes"
    nix build --extra-experimental-features "nix-command flakes"
    
  • Notes
    $ export NIX_EXPERIMENTAL_FEATURES="nix-command flakes"
    nix build --extra-experimental-features nix-command
    error: experimental Nix feature 'flakes' is disabled; use '--extra-experimental-features flakes' to override
    $
    
  • References
    • ChatGPT

  • Simulate a mouse double click in Vimium C

    • Custom key mappings
      map gd LinkHints.activate dblclick
      
  • Notes
    • Click on the letter g, then on the letter d
  • References
    • https://github.com/gdh1995/vimium-c/issues/382#issuecomment-917538351

  • Stop a process in Linux

    • kill -STOP 508
  • Notes
    • 508 # Replace it with your process ID
      • ps aux | grep mpv
    • kill -CONT 508 # Continue
  • References
    • 2023-06-04_09-21.png
    • ChatGPT

  • Use "awk"

    • awk -v RS='' 'NR==1' # Extract the first paragraph
      • -v # Assign value to variable
      • RS # Record separator
      • NR # Number of records
    • docker ps --format "{{.Ports}}" | awk -F'[:/]' '{print $2}'
    • kill -STOP $(ps aux | grep -v grep | grep aola | awk '{print $2}')
  • Notes
    • -F # Field separator
    • [:/] # Either ':' or '/'
    • aola # Replace it with your desired command
    • $2 # Second column
  • References
    • man gawk # \-v RS NR
    • Manipulate columnar data # ChatGPT

  • Simulate middle mouse button and jump to new page in Vimium C

    • Custom key mappings
      map gn LinkHints.activateHover $then="$D+mid_click"
      run <v-mid_click> sim_mid#mousedown+$D+sim_mid#mouseup+$D+lh_open
      run <v-sim_mid> dispatchEvent#button=1&type=$s mask
      map <v-lh_open> LinkHints.click mode="incognito" incognito=false direct="hovered"
      
  • Notes
    • Click on the letter g, then on the letter n
  • References
    • https://github.com/gdh1995/vimium-c/issues/891#issuecomment-1483856671

  • Simulate hover in Vimium C

    • Custom key mappings
      map gh LinkHints.activateHover
      
  • Notes
    • Warning: Require fine-tuning to fully function.
    • Click on the letter g, then on the letter h
  • References
    • https://github.com/gdh1995/vimium-c/issues/909#issuecomment-1516857562

  • Move no space files to temporary directory in Linux Bash one-liner

    • for f in {01..23}*; do if [[ ! "$f" =~ " " ]];then mv "$f" /tmp/; fi; done
  • Notes
    • ! # Not
    • =~ # Regular expression
  • References
    • ChatGPT

  • Understand "Please Give Me Wings"

    • A song
      • folk
      • Japanese
  • References
    • Danganronpa # Animation
    • https://en.wikipedia.org/wiki/Tsubasa_o_Kudasai
    • https://www.youtube.com/watch?v=dmo9SMswttQ # English version
    • https://www.youtube.com/watch?v=5ZXquiMoyjY # Japanese version

  • Insert a string at the the beginning of the line in Vi

    • :%s/^/xdg-open /g
  • Notes
    • xdg-open # Replace it with your desired string
    • Because to open URL in batches.
    • :%s/$/ \&/g # Insert a string at the end of the line in Vi
      • %s/ \&$//g # Remove it
      • Because to download multiple files at the same time.

  • The abbreviation of "QEMU Copy On Write 2" is "qcow2".

    • A format
  • Notes
    • Because to use qemu command.
  • References
    • ChatGPT

  • Use "parted"

    • parted /dev/sda -- rm 3 # Remove the third partition (/dev/sda3)
  • Notes
    • Because typed the wrong command accidentally when partitioning.
  • References
    • https://nixos.org/manual/nixos/stable/index.html#sec-installation-manual-partitioning
    • lsblk
    • ChatGPT

  • Search for package names in NixOS

    • nix-env -qaP wqy-microhei
  • Notes
    • -q # Query
    • -a # Available
    • -P # Path
    • Another way
      • https://search.nixos.org/
    • vim /etc/nixos/configuration.nix
      users.users.yaoniplan = {
        packages = with pkgs; [
          wqy_microhei
        ];
      };
      
      • Because to solve the problem of garbled Chinese fonts.
  • References
    • 2023-05-27_22-46.png
    • man nix-env
    • ChatGPT

  • Install KDE Plasma in NixOS

    • vim /etc/nixos/configuration.nix
      services.xserver.enable true;
      services.xserver.displayManager.sddm.enable = true;
      services.xserver.desktopManager.plasma5.enable = true;
      
  • Notes
    • Enable autologin in SDDM
      services.xserver.displayManager.autoLogin.enable = true;
      services.xserver.displayManager.autoLogin.user = "yaoniplan";
      
      • When no password is set for the user
    • Install Awesome WM in NixOS
      services.xserver = {
        enable = true;
      
        displayManager = {
          sddm.enable = true;
          defaultSession = "none+awesome";
        };
        
        windowManager.awesome = {
          enable = true;
          luaModules = with pkgs.luaPackages; [
            luarocks # is the package manager for Lua modules
            luadbi-mysql # Database abstraction layer
          ];
        };
      };
      
    • nixos-rebuild switch --option substituters https://mirrors.ustc.edu.cn/nix-channels/store # Rebuild to make changes effective
    • Use Wayland (Warning: It has some bugs)
      • Select "Plasma (Wayland)" of Desktop Session in SDDM
    • Because to master it quickly.
  • References
    • https://www.reddit.com/r/NixOS/comments/9dcwdk/comment/e5h69kt/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
    • https://nixos.wiki/wiki/Awesome
    • https://www.reddit.com/r/NixOS/comments/10c72dy/how_do_i_setup_nixos_plasma_wayland_in/
    • https://nixos.wiki/wiki/KDE

  • Use ssh in NixOS

    • vim /etc/nixos/configuration.nix
      # Enable the OpenSSH daemon in NixOS
      services.openssh.enable = true;
      
  • Notes
    • Because to use the command ssh yaoniplan@192.168.10.105 -p 60022 in another computer.

  • Install packages for root user in NixOS

    • vim /etc/nixos/configuration.nix
      # List packages installed in system profile. To search, run:
      # $ nix search wget
      environment.systemPackages = with pkgs; [
        vim
        git
        wget
      ];
      
  • Notes
    • Because to use vim to edit configuration.nix file.

  • Add a user to multiple groups in NixOS

    • vim /etc/nixos/configuration.nix
      # Define a user account. Don't forget to set a passwd with `passwd`.
      users.users.yaoniplan = {
        isNormalUser = true;
        extraGroups = [ "wheel" "networkmanager" ]; # Enable `sudo` for the user.
        packages = with pkgs; [
          git
          vim
          wget
        ];
      };
      
  • Notes
    • Because to use the sudo command sudo chown -R yaoniplan:yaoniplan /mnt/yaoniplan/.
      • groupadd yaoniplan # Add a group in Linux to solve the problem
        [root@tux:~]# chown -R yaoniplan:yaoniplan /mnt/yaoniplan/
        chown: invalid group: ‘yaoniplan:yaoniplan’
        
        [root@tux:~]#
        
  • References
    • https://nixos.org/manual/nixos/stable/index.html#sec-user-management

  • Enable sound or volume in NixOS

    • vim /etc/nixos/configuration.nix
      # Enable sound.
      sound.enable = true;
      hardware.pulseaudio.enable = true;
      

  • Set time zone in NixOS

    • vim /etc/nixos/configuration.nix
      time.timeZone = "Asia/Shanghai";`
      
  • Notes
    • timedatectl # View the current time zone
    • Asia/Shanghai # Replace it with your desired time zone
      • timedatectl list-timezones # List all time zones

  • Set locale in NixOS

    • vim /etc/nixos/configuration.nix
      i18n.defaultLocale = "en_US.UTF-8";
      
  • Notes
    • Because English is the common language of the open source world.

  • Set hostname in NixOS

    • vim /etc/nixos/configuration.nix
      networking.hostname = "tux"; # Define your hostname.
      
  • Notes
    • tux # Replace it with yours

  • Set network configuration in NixOS

    • vim /etc/nixos/configuration.nix
      networking.networkmanager.enable = true;
      users.users.yaoniplan = {
        extraGroups = [ "networkmanager" ];
      };
      
  • Notes
    • yaoniplan # Replace it with your user
  • References
    • https://nixos.org/manual/nixos/stable/index.html#sec-networkmanager

  • Set keymap in NixOS

    • vim /etc/nixos/configuration.nix
      services.xserver.layout = "us";
      

  • Delete redundant directories in Linux

    • ls -1dr "$destinationDir"/* | tail -"$quantityToDelete" | xargs rm -rf
  • Notes
    • -1 # One per line
    • -d # Directory
    • -r # Reverse
    • xargs # Execute arguments
    • Because to backup files with a scirpt automatically.
    • Another way
      ls -1d "$destinationDir"/* | head -"$quantityToDelete" | xargs rm -rf
      
  • References
    • man ls
    • man xargs
    • 2023-05-31_10-55.png
    • ChatGPT

  • Use the ISO file to enter the system in NixOS

    • mount /dev/disk/by-label/nixos /mnt
    • mount /dev/disk/by-label/boot /mnt/boot
    • swapon /dev/sda2
  • Notes
    • When booting
      Reboot Into Firmware Interface
      Boot Manager
      UEFI VBOX CD-ROM VB2-01700376
      
    • sudo --login # Substitute to root user
    • setfont ter-v32n # Increase the font size
    • vim /mnt/etc/nixos/configuration.nix # Edit the configuration file
    • nixos-install # Install system
    • nixos-rebuild switch
    • Because to edit the configuration.nix file when can't log in to the system.
  • References
    • https://nixos.org/download.html#nixos-iso # Minimal ISO image (64-bit Intel/AMD)
    • https://nixos.org/manual/nixos/stable/index.html#sec-installation-manual-installing
    • https://www.youtube.com/watch?v=IdoCOqkAexY

  • Set mirror in NixOS

    • vim /etc/nixos/configuration.nix
      nix.settings.substituters = [
        "https://mirrors.ustc.edu.cn/nix-channels/store"
        "https://cache.nixos.org"
      ];
      
  • Notes
    • Set mirror temporarily
      nixos-install --option substituters "https://mirrors.ustc.edu.cn/nix-channels/store https://cache.nixos.org"
      
      • nixos-install # Replace it with your desired comand (e.g. nixos-rebuild switch)
    • Because to improve the speed when using command nixos-install.
  • References
    • https://mirrors.ustc.edu.cn/help/nix-channels.html

  • Set prompt string in Linux Bash

    • PS1='[\u@\h \W]\$ '
      [yaoniplan@tux ~]$ 
      
  • Notes
    • \ # Escape
      • u # User
      • h # Hostname
      • W # Working directory
    • Enable colors with the ANSI escape codes
      • \[\e[1;32m\] # Set the color to bold green
      • \[\e[0m\] # Reset the color to the default
      • \e[ # Escape
      • 1; # Bold
      • 32 # Green color code
      • m # Mark the end
      • 0 # Reset
    • Set prompt string permanently
      • vi ~/.bashrc
        PS1='\[\e[1;32m\]\u@\h\[\e[0m\] \[\e[1;34m\]\w \$\[\e[0m\] '
        
      • source ~/.bashrc
  • References
    • 2023-05-23_20-06.png
    • echo $PS1
    • https://missing-semester-cn.github.io/2020/command-line/ # $PS1
    • ChatGPT

  • The abbreviation of "Prompt String 1" is "PS1".

  • References
    • https://en.wikipedia.org/wiki/Command-line_interface#Command_prompt

  • Understand "Twinkle, Twinkle, Little Star"

    • A lullaby
      • From a poem
  • Notes
    • Lyrics (The first part)
      • Twinkle, twinkle, little star,
      • How I wonder what you are!
      • Up above the world so high,
      • Like a diamond in the sky.
  • References
    • Your Lie in April # Animation
    • https://en.wikipedia.org/wiki/Twinkle,_Twinkle,_Little_Star

  • Use "journalctl"

    • journalctl -e
  • Notes
    • --since "2024-09-02 08:00:00" # From time
      • "5 minutes ago" # Use relative time
    • --until "2024-09-02 09:00:00" # To time
    • -e # End
    • Because to debug scripts that don't work properly.
  • References
    • man journalctl
    • ChatGPT

  • Search for content in C language on GitHub

    • language:C todo
  • Notes
    • C # Replace it with other language (e.g. Bash, Python etc.)
    • created:2020-01-01..2021-01-01 # Created date
  • References
    • ChatGPT

  • Install Gentoo Linux in Docker on Arch Linux

    • docker run -i -t gentoo/stage3 bash
  • Notes
    • -i # Interactive
    • -t # Tty
    • gentoo/stage3 # Replace it with your desired Linux (e.g. nixos/nix)
    • doas pacman -S docker # Install in Arch Linux
    • doas systemctl start docker # Once now
    • Restart and interact with the last exited Docker container
      • doas docker start a38ab0552048
      • doas docker exec -i -t a38ab0552048 bash
    • Because someone in the group shared the news of success.
    • vi ~/.config/gentoo/docker-compose.yml
      version:: '3'
      
      services:
        gentoo:
          image: gentoo/stage3
          restart: always
          tty: true
          stdin_open: true
          volumes:
            - ~/.config/gentoo:/data
          command: bash -c "while :; do sleep 1; done"
      
  • References
    • 2023-05-21_18-44.png
    • docker exec --help
    • docker ps --help
      • doas docker ps --all # Get CONTAINER ID (e.g. a38ab0552048)
    • ChatGPT

  • Set an alias in Linux Bash

    • alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME/'
      • dotfiles # Replace it with your desired alias
      • Put your desired command into single quotes
      • Put it into ~/.bashrc and then source ~/.bashrc to make it effective permanently
  • Notes
    • alias dotfiles # Display the alias
    • unalias dotfiles # unalias
      • \dotfiles # Another way
    • vi ~/.ssh/config # Set an alias for ssh
      Host yaoniplan
          User yaoniplan
          HostName 192.168.10.100
      
      • yaoniplan # Replace it with your user
      • 192.168.10.100 # Replace it with your host name
      • ssh yaoniplan # The same as ssh yaoniplan@192.168.10.100
  • References
    • unalias --help
    • https://missing-semester-cn.github.io/2020/command-line/

  • Understand "Rhapsody in Blue"

    • A piece of music
      • Piano
      • Jazz
  • References
    • https://en.wikipedia.org/wiki/Rhapsody_in_Blue
    • https://www.youtube.com/watch?v=ie-TS-BitnQ # From Fantasia 2000
    • https://blog.lhp-pku.top/2023/05/17/middleschool/ # 蓝色狂想曲

  • The abbreviation of "/sbin" is "system binary".

  • References
    • https://missing-semester-cn.github.io/2020/qa/

  • The abbreviation of "systemd" is "system daemon".

  • References
    • https://missing-semester-cn.github.io/2020/potpourri/

  • Detect if a command is running in Linux Bash script

    • if ps aux | grep -v grep | grep timerOfTomato.sh &>/dev/null; then
  • Notes
    • -v # Invert match
    • timerOfTomato.sh # Replace it with your desired command
    • if ! pgrep tilda; then # Another way (Does not work for scripts)
      • ! # Not
  • References
    • man grep
    • ChatGPT

  • Move a window from one session to another in tmux

    • tmux move-window -s 0:1 -t 1:2
  • Notes
    • -s # Source
    • 0 # Session name
    • -t # Target (To)
    • 2 # Window name
  • References
    • 2023-05-17_21-43.png
    • man tmux # /move-window
    • ChatGPT

  • Use "tilda" in DWM

    • doas vi ~/.config/dwm/config.h
      static const Rule rules[] = {
          /* class      instance    title       tags mask     isfloating   monitor */
          { "Tilda",    NULL,       NULL,       0,            1,           -1 },
      };
      
      • cd ~/.config/dwm/ && doas make clean install # Compile to make changes effective
    • tilda -C # Config
      # General
      0 # Auto Hide Delay of "Auto Hide"
      Hide when Tilda loses focus
      
      # Appearance
      50.00 # Percentage of Height
      70.00 # Percentage of Width
      Centered Horizontally # Position
      
      # Keybindings
      <Alt>a # Pull Down Terminal
      
      • vi ~/.config/tilda/config_0 # Another way
  • Notes
    • tilda --command tmux # Run the tmux command at startup
    • doas pacman -S tilda # Install in Arch Linux
    • Alt-Shift-q # Quit to make all changes effective
    • Because it can act as a drop-down terminal and scratchpad.
    • It's a little tasteless.
      • We already have st and dmenu.
  • References
    • ChatGPT
    • tilda --help
    • https://wiki.archlinux.org/title/Dwm#Using_Tilda_with_dwm

  • Set the escape time to 0 in Vim

    • vi ~/.vimrc
      " Set escape time to 0
      set timeoutlen=0 ttimeoutlen=0
      
  • Notes
    • len # Length
    • t # Terminal
    • Warning: It may prevent some plugin shortcuts from working.
    • Because for faster response.
  • References
    • ChatGPT
    • :help timeoutlen

  • As long as it works. #idea

    • Perfectionism can consume a lot of time in some cases.
  • Notes
    • Because failing too much wears out patience.

  • Install "DWM" from source code in Linux

    • git clone https://git.suckless.org/dwm ~/.config/dwm/
      • w3m suckless.org # Second way that improve the speed
      • links suckless.org # Third way that improve the speed
    • cd ~/.config/dwm/; sudo make clean install # Compile it
  • Notes
    • Unpatching
      • cd ~/.config/dwm/
      • git checkout .
    • Patching
      • Download a patch https://dwm.suckless.org/patches/uselessgap/
      • cd ~/.config/dwm/
      • patch -p1 < ~/dwm-uselessgap-20211119-58414bee958f2.diff
      • doas make clean install
    • Install some dependencies before compiling
      • sudo pacman -S base-devel libx11 libxinerama libxft xorg xorg-xinit
      • https://packages.gentoo.org/packages/x11-wm/dwm/dependencies
    • Make the notify-send command works
      • vim ~/.xinitrc
        exec dbus-launch --sh-syntax --exit-with-session dwm
        
      • echo 'export $(dbus-launch)' >> ~/.bashrc
    • Turn off the display of the following message
      /usr/lib/Xorg.wrap: Only console users are allowed to run the X server
      xinit: giving up
      xinit: unable to connect to X server: Connection refused
      xinit: server error
      Couldn't get a file descriptor referring to the console.
      
      • vim ~/.bash_profile
        if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
          exec startx
        fi
        
    • Set resolution if it is not clear
      xrandr --output LVDS-1 --mode 1280x720
      
      • LVDS-1 # Replace it with your screen name
      • 1280x720 # Replace it with your desired resolution
  • References
    • ChatGPT
    • xrandr --query
    • https://www.bilibili.com/video/BV1pr4y1U78u/
    • https://wiki.gentoo.org/wiki/Dwm
    • https://www.bilibili.com/video/BV1qP4y1L7dH/
    • https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login

  • Use "Bspwm" WM in Linux

    • Super-Shift-w # Kill a window
    • Super-Space # Run dmenu
    • Super-Alt-q # Quit Bspwm
    • Super-Enter # New a terminal
    • Super-h # Move cursor
    • Super-Shift-h # Move window
  • Notes
    • First use
      • mkdir --parents ~/.config/bspwn/ ~/.config/sxhkd/
      • cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm/
      • cp /usr/share/doc/bspwm/examples/sxhkdrc ~/.config/sxhkd/
  • References
    • https://wiki.gentoo.org/wiki/Bspwm

  • Detect if a command exists in Linux Bash script

    • if command -v redshift &>/dev/null; then
  • Notes
    • -v # Verbose
    • redshift # Replace it with your desired command
  • References
    • ChatGPT
    • command --help
      [yaoniplan@tux ~]$ if command -v redshift &>/dev/null; then ls; fi
      [yaoniplan@tux ~]$ if command -v ls &>/dev/null; then ls; fi
      note
      [yaoniplan@tux ~]$
      

  • Use "sudo" in Linux

    • su root # Substitude to root user
    • visudo # Use Vi to edit the sudoers file
      yaoniplan ALL=(ALL) ALL
      
      • pacman --sync vi # Install Vi to solve the problem
        [root@tux yaoniplan]# visudo 
        visudo: no editor found (editor path = /usr/bin/vi)
        [root@tux yaoniplan]#
        
    • exit # Exit the root user
  • Notes
    • Solve the problem
      [sudo] password for yaoniplan: 
      yaoniplan is not in the sudoers file.
      
  • References
    • ChatGPT

  • Disable "reflector" tool in Arch Linux

    • systemctl stop reflector
  • Notes
    • Because to set a specifier mirror in the Live CD.
      • vim /etc/pacman.d/mirrorlist
        Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
        
      • pacman --sync --refresh # Test speed
  • References
    • https://archlinux.org/mirrorlist/?country=China&protocol=http
    • https://archlinuxstudio.github.io/ArchLinuxTutorial/#/uk/rookie/basic_install?id=_0-disable-reflector
    • ChatGPT

  • List font in Linux

    • fc-list
  • Notes
    • fc # Font config
  • References
    • ChatGPT
    • man fc-list

  • Add a user in Arch Linux

    • doas useradd -m yaoniplan
  • Notes
    • -m # Create user's home directory
    • doas passwd yaoniplan # Change user password
    • su yaoniplan # Substitue to the user
    • Delete the user in Arch Linux
      • doas userdel --remove yaoniplan # Remove the home directory
  • References
    • ChatGPT
    • man userdel # /home
    • man passwd
    • man useradd

  • Use "awesome"

    • Ctrl-Super-r # Reload awesome
    • Super-s # Show hotkeys
    • Super-j # Move cusor
    • Super-Shift-c # Kill a program
    • Super-Enter # New a terminal
    • Super-f # Full screen
  • Notes
    • Start awesome automatically
      • echo "exec awesome" >> ~/.xinitrc
      • echo "startx" >> ~/.bash_profile
    • Configure file
      • mkdir --parents ~/.config/awesome/
      • cp /etc/xdg/awesome/rc.lua ~/.config/awesome/rc.lua
    • Set the font
      • vim ~/.config/awesome/rc.lua
        beautiful.font = "DejaVu Sans Mono 10"
        
      • awesome -r # Reload to make changes effective
  • References
    • https://wiki.gentoo.org/wiki/Awesome
    • less /etc/xdg/awesome/rc.lua # /modkey

  • Use "yay"

    • git clone https://aur.archlinux.org/yay.git ~/.config/yay/
    • cd ~/.config/yay/; makepkg -si
  • Notes
    • yay # Replace it with other package name
      • https://aur.archlinux.org/packages # Get it
    • makepkg -si # Enable network proxy to improve the speed before using the command
      • vim ~/.bash_profile
        export http_proxy="192.168.10.100:7890"
        export https_proxy="192.168.10.100:7890"
        export no_proxy="localhost, 192.168.10.100"
        
      • Log out and log back to make changes effective
    • The abbreviation of "arch user repository" is "aur".
    • Because to use AUR to install some software.
  • References
    • https://libreddit.privacydev.net/r/archlinux/comments/18eb1c4/usind_archlinux_inside_distrobox_with_aur/ # /yay-bin
    • https://github.com/Jguer/yay#source
    • ChatGPT

  • Rename file name in batches

    • for f in *; do mv "$f" "$(echo "$f" | sed 's/230512[0-9]\{6\}/230512seeADentist/g')"; done
  • Notes
    • [0-9] # One character from this set
    • \ # Escape
    • {6} # A quantifier
  • References
    • ChatGPT
    • Output
      [yaoniplan@tux tmp.8x9UnjDpkt]$ ls
      IMG20230512081957.jpg  REC20230512090514.mp3
      [yaoniplan@tux tmp.8x9UnjDpkt]$ for f in *; do mv "$f" "${f:5}"; done
      [yaoniplan@tux tmp.8x9UnjDpkt]$ ls
      230512081957.jpg  230512090514.mp3
      [yaoniplan@tux tmp.8x9UnjDpkt]$ for f in *; do mv "$f" "$(echo "$f" | sed '
      s/230512[0-9]\{6\}/230512seeADentist/g')"; done
      [yaoniplan@tux tmp.8x9UnjDpkt]$ ls
      230512seeADentist.jpg  230512seeADentist.mp3
      [yaoniplan@tux tmp.8x9UnjDpkt]$
      

  • Use "systemctl"

    • doas systemctl enable cronie
      • doas /etc/init.d/cronie start
      • Every time at boot time
    • doas systemctl start cronie
      • doas rc-update add cronie default
      • Once now
  • Notes
    • cronie # Replace it with your service
    • doas systemctl enable cronie --now # One command that combines them
      • enable # Replace it with disable to disable
  • References
    • https://wiki.gentoo.org/wiki/OpenRC_to_systemd_Cheatsheet

  • Try some WMs or DEs in VirtualBox

    • Window manager
      • Bspwm (2023-05-16)
      • Awesome (2023-05-16) # A fork of DWM
      • DWM (2023-04-05) # Build from source code
      • i3 (2022-08-20) # To beginners
    • Desktop environment
      • Xfce (2023-05-20)
      • MATE (2023-05-18)
      • Deepin (2023-05-16)
      • KDE (2023-05-15)
      • GNOME (2022-07-16)
  • References
    • https://en.wikipedia.org/wiki/Awesome_(window_manager)

  • The abbreviation of "Desktop Environment" is "DE".

    • A bundle of programs
  • Notes
    • Aim for beginners
    • Out of the box
  • References
    • https://en.wikipedia.org/wiki/Desktop_environment
    • https://en.wikipedia.org/wiki/Out_of_the_box_(feature)

  • Use "trans"

    • trans :zh narrator
  • Notes
    • Examples
      • trans -player mpg123 zh:en "$*" # Translate Pinyin to English
      • trans -player mpg123 :zh "$*" | less -R # Translate English to Chinese
    • -speak # Don't play translation (When NSFW)
    • -no-ansi # No print ANSI escape codes (e.g. [4m, [24m)
    • -engine # Specify a translation engine
    • -list-engines # List translation engines
    • zh # Replace it with country code (e.g. en)
      • trans -list-all # Get it
    • -player mpg123 # Change default player to mpg123
    • -proxy 192.168.10.100:7890 # Proxy
    • doas emerge -aq app-i18n/translate-shell # Install dependencies
      • nix profile install nixpkgs#translate-shell # Another method
    • Because to learn an unclear word.
    • Disadvantages
      • Does not support SOCKS5 proxy
      • Playback "Translations of " during speech
    • Advantages
      • Run in terminal
  • References
    • man trans
    • https://github.com/soimort/translate-shell/issues/331#issuecomment-574175585
    • https://github.com/soimort/translate-shell/issues/178#issuecomment-304537785
    • https://github.com/soimort/translate-shell/issues/408

  • The abbreviation of "carbon monoxide" is "CO".

    • A gas
  • Notes
    • Bind to hemoglobin
      • Does not carry oxygen
      • Feel dizzy
  • References
    • ChatGPT
    • In the fire
    • https://en.wikipedia.org/wiki/Carbon_monoxide

  • The abbreviation of "teletypewriter" is "tty".

    • A command
  • References
    • https://en.wikipedia.org/wiki/Tty_(Unix)

  • Change shell from zsh to bash in Linux

    • chsh -s /bin/bash
  • Notes
    • -s # Shell
    • chsh -l # List shells
      • -l # List
      • cat /etc/shells # Another way
    • echo $SHELL # View the current shell
    • doas reboot # Make changes effective
  • References
    • ChatGPT
    • man chsh

  • The abbreviation of "intelligence quotient" is "IQ".

    • A score
      • Mental age / chronological age
  • References
    • ChatGPT
    • https://en.wikipedia.org/wiki/Intelligence_quotient

  • Redirect all output in Linux

    • redshift -O 1500 &>/dev/null &
  • Notes
    • & # Standard output and standard error
    • > # Redirect
    • /dev/null # Empty file
    • Because to run a script silently.
  • References
    • ChatGPT
    • man bash
      • /&>
      • /dev/null

  • Use "find"

    • find . -name "github*"
  • Notes
    • * # Zero or more
    • Filter
      • -type d # Directory
      • -type f # File
    • Another way
      • find /mnt/grow/ -type d | grep -i books
      • find /mnt/yaoniplan/ | grep -i speed
    • Delete hidden files
      find . -type f -name '.*' -delete
      
    • Delete a file that cannot be deleted using rm
      # Get the index number (e.g. 20447344) of the file
      ls --inode
      # Use find with the inode number to remove the file
      find . -type f -inum 20447344 -exec rm {} \;
      
    • Move all FLV files in subdirectories to the current directory
      find . -maxdepth 2 -type f -name "*.flv" -exec mv {} . \;
      
    • Move all files in subdirectories to the current directory
      find {01..08}/ -maxdepth 1 -type f -exec mv {} . \;
      
      • {01..08}/ # Replace it with your subdirectory
    • Delete files and directories older than 30 days
      find "$trashDir" -mindepth 1 -ctime +30 -delete
      
      • -ctime # Changed time
  • References
    • man find # /^ *-ctime
    • 2023-05-06_00-13.png
    • ChatGPT

  • Understand "Dreaming of Home and Mother"

    • Melody of English
    • Lyrics of Japanese
      • Translate it to Chinese
  • References
    • https://en.wikipedia.org/wiki/Songbie
    • https://www.youtube.com/watch?v=vdm7845EW8M # English version
    • https://www.youtube.com/watch?v=ak7IfDqvaPY # Japanese version

  • Insert paragraphs into the top of a file in sed

    sed -i '1i\
    <!DOCTYPE html>\
    <html>\
    <head>\
      <meta name="viewport" content="width=device-width, initial-scale=1">\
      <title>yaoniplan</title>\
      <link rel="stylesheet" href="../assets/github-markdown-dark.css">\
      <style>\
        .markdown-body {\
          box-sizing: border-box;\
          min-width: 200px;\
          max-width: 980px;\
          margin: 0 auto;\
          padding: 45px;\
        }\
        @media (max-width: 767px) {\
          .markdown-body {\
            padding: 15px;\
          }\
        }\
      </style>\
    </head>\
    <body>\
      <article class="markdown-body">' ~/note/index.html
    
  • Notes
    • -i # In place
    • 1 # The first line
    • i # Insert
    • \ # Escape the newline character
      • No space after backslash
    • ~/note/index.html # Replace it with your index.html
    • Because to convert Markdown to HTML.
  • References
    • ChatGPT
    • man sed

  • Rename file in Perl

    • perl -e 'foreach $file (glob("B站*")) { $newname = $file; $newname =~ s/B站-?//g; rename $file, $newname; }'
  • Notes
    • -e # Execute
    • glob # Global
    • ? # Zero or one
    • Another way
      • for f in B站*; do mv "$f" "$(echo "$f" | sed -E 's/B站-?//g')"; done
      • -E # Extended
  • References
    • ChatGPT
    • man sed
    • perldoc -f rename
      • -f # Function
    • 2023-05-05_12-56.png

  • Use "bash"

    • echo "$((width + width / 10))" # Add value (10% of the width) to the original width
      • $(()) # Perform basic arithmetic operations
      • Because to check if it is an odd or even day
        if [[ $(( $(date +%-j) % 2)) -eq 1 ]]; then
        
      • - # Do not pad the field
      • echo "scale=2; 7 / 2" | bc # Perform floating point arithmetic operations (3.50)
    • vi $(which uploadFile.sh) # Capture the output of a script into a variable
      fileName=$(selectFile.sh)
      
      • vim ~/.local/bin/selectFile.sh
        echo "$directory/$selection"
        
    • vim ~/.local/bin/remindMe.sh # Write a function in Bash
      notification() {
          sleep "$1"
          notify-send "$notificationMessage" &
      
          for i in {1..2}; do
              paplay "$audioFile"
          done
      }
      
      • Before defining the function
        # Set variables
        notificationMessage="Time is up!"
        audioFile="/home/yaoniplan/note/assets/doorbell.mp3"
        
      • After defining the function
        # Call the function (Optional: `"$1"`)
        notification "$1"
        # Another way capturing output that call the determine_square function
        # `if [[ "$(determine_square)" == "notSquare" ]]`
        # Another way without capturing output
        # `determine_square`
        
      • Surround variables with double quotes
        "$1"
        "$notificationMessage"
        "$audioFile"
        
    • read -p "Enter a city name: " city # Read input of a user
      • -p # Prompt
      • Enter a city name: # Replace it with your desired prompt message
      • city # Replace it with your desired variable name
      • Because to write a application to get weather information.
    • if [[ -z "$fileName" ]]; then # Check if the file name is empty
    • if [[ -x /usr/bin/rsync ]]; then
    • while true; do smplayer 'yourURL' && [[ $? -eq 0 ]]; done
      • Execute the command until it succeeds
      • Ctrl-c # Stop it
    • if [[ n -eq 42 ]]; then
  • Notes
    • -z # Zero (The length of string)
    • -x # Exist and executable
    • $? # Exit status
    • -ne # Not equal
    • n # A variable name
    • -eq # Equal
    • if [[ -n "$1" ]]; then
      • -n # Not empty
  • References
    • man date # /%j
    • read --help
    • man bash # /-eq /^condition /-z
    • Artificial intelligence

  • Use "Spacemacs" in Emacs

    • SPC f t # File tree
    • SPC x y # Yank after selecting a region
      • vim ~/.spacemacs # Or SPC f e d
        ;; List of configuration layers to load.
        dotspacemacs-configuration-layers
        '((xclipboard :variables xclipboard-enable-cliphist t))
        
    • C-c C-o # Open URL
      • SPC m RET
      • SPC m f
    • SPC / # Search string
      • SPC s p # Search project
    • emacs # Start
  • Notes
    • RET # Return key
    • SPC # Space key
    • doas emerge -aq app-editors/emacs # Install in Gentoo Linux
    • git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
  • References
    • ChatGPT
    • https://wiki.gentoo.org/wiki/Spacemacs
    • https://github.com/syl20bnr/spacemacs/blob/e4b20f797d9e7a03d9a5603942c4a51ea19047b2/layers/%2Btools/xclipboard/README.org

  • Enable dark mode for PDF file in Firefox

    • Ctrl-Shift-i # Paste it in "Console"
      // When using in-browser PDF viewer, you can inspect it and run this in the console
      // It's using CSS Blending to invert the colors of the PDF 
      function togglePDFDarkMode() {
        var cover = document.createElement("div");
        let inversion = `
          position: fixed;
          pointer-events: none;
          top: 0;
          left: 0;
          width: 100vw;
          height: 100vh;
          background-color: white;
          mix-blend-mode: difference;
          z-index: 1;
          `
        if (document.body.contains(cover)) {
          document.body.removeChild(cover);
        } else {
          cover.setAttribute("style", inversion);
          document.body.appendChild(cover);
        }
      }
      togglePDFDarkMode();
      
  • References
    • 2023-05-02_10-57.png
    • https://gist.github.com/sneakyness/4fc195912152827a3499f7bf38590aa1

  • Enable Vi mode in Python interpreter

    • Ctrl-Alt-j
  • Notes
    • vim ~/.inputrc # Another way
      set editing-mode vi
      
  • References
    • https://stackoverflow.com/questions/537522/standard-python-interpreter-has-a-vi-command-mode/538573#538573

  • Clear the Python interpreter in Linux

    • Ctrl-l
  • Notes
    • Another way
      >>> import os
      >>> os.system('clear')
      
    • Because to clear the screen like in Linux.
  • References
    • ChatGPT
    • https://stackoverflow.com/questions/517970/how-to-clear-the-interpreter-console/37925455#37925455

  • Load a file into the Python interpreter

    • python -i testCard.py
  • Notes
    • -i # Interactive
  • References
    • man python
    • https://stackoverflow.com/questions/5280178/how-do-i-load-a-file-into-the-python-console/5280210#5280210

  • Use "opencc"

    • for f in *.mp4; do mv "$f" "$(echo "$f" | opencc -c t2s.json)"; done
  • Notes
    • for f in 围棋第*; do mv "$f" "$(echo "$f" | opencc -c cn2an.json)"; done # Convert Chinese numbers to Arabic numbers
      • vim ./cn2an.json
        {
          "name": "Traditional Chinese to Simplified Chinese",
          "segmentation": {
            "type": "mmseg",
            "dict": {
              "type": "ocd2",
              "file": "TSPhrases.ocd2"
            }
          },
          "conversion_chain": [{
            "dict": {
              "type": "group",
              "dicts": [{
                "type": "ocd2",
                "file": "TSPhrases.ocd2"
              }, {
                "type": "ocd2",
                "file": "TSCharacters.ocd2"
              }, {
                "type": "text",
                "file": "./cn2an.txt"
              }]
            }
          }]
        }
        
      • vi ./cn2an.txt # Use the tab key between them
        一    1
        二    2
        三    3
        四    4
        五    5
        六    6
        七    7
        八    8
        九    9
        十    10
        
    • -c # Config
    • nix profile install nixpkgs#opencc # Install dependencies
    • Because to convert file names from Traditional Chinese to Simplified Chinese.
  • References
    • https://github.com/BYVoid/OpenCC/issues/198#issuecomment-276880744
    • opencc --help
    • ChatGPT

  • Use "ffmpeg"

    • ffmpeg -i 5ac9704e-c8fc-4445-bc3c-db640271898d-B.mp4 -c:v libx265 -crf 28 -preset slow -c:a aac -b:a 128k 招生专业名称:计算机类.mp4 # Compress a file without losing much quality
      • -c:v # Set video codec to libx265 (HEVC encoder: higher compression rate than H.264)
      • -crf # Set Constant Rate Factor to 28 (Higher value result in lower quality and smaller file size)
      • -preset # Set encoding preset to slow (Prioritize compression efficiency over encoding speed)
      • -c:a # Set audio codec to AAC (Good balance of quality and compression efficiency)
      • -b:a # Set audio bitrate to 128 kbps
    • ffmpeg -i 231012seeADentist.m4a 231012seeADentist.mp3 # Convert M4A to MP3 format
      • for f in *.mp4; do ffmpeg -i "$f" "${f%.mp4}.mp3"& done # In batches
      • % # Remove extension (e.g. .mp4)
      • & # In the background
    • ffmpeg -f v4l2 -i /dev/video0 output.mp4 # Capture video from camera
      • ffplay -f v4l2 /dev/video0 # Display the video on screen
    • ffmpeg -i input.wma -ss 00:00:25 -c copy output.wma # From 00:00:25 to the end
    • ffmpeg -i input.wma -ss 00:00:00 -to 00:15:37 -c copy output.wma # Cut a section
    • ffmpeg -f concat -safe 0 -i fileList.txt -c copy output.wma # Merge videos
      • vi fileList.txt
        file 'output01.wma'
        file 'output02.wma'
        
  • Notes
    • -i # Input
    • -ss # Specify starting
    • -f # Format
    • concat # Concatenate
    • Because to remove a commercial.
  • References
    • man ffmpeg
    • ChatGPT

  • Use "sed"

    • sed '$agit -C /root/.config/note/ pull origin development' ~/.profile # Append string to the last line
      • $ # Match the last line (3: The third line)
      • a # Append
    • sed -i '5s/$/ \&/' .profile # Append the string at the end of the line
    • sed -i '1i#EXTM3U' "$playlist_file" # Insert #EXTM3U at the beginning of file
    • sed -i "\|$musicUrl|d" "$playlist" # Delete this line in the file
      • \ # Escape only the first delimiter
      • | # Delimiter (Avoid conflicts with the slashes in the URL)
    • sed -i '5,7d' ~/.ssh/config # Delete the fifth through seventh lines from a file
      • -i # In place (Without it, just simulate first)
      • d # Delete
      • (5d: The fifth, $d: The last, 5d;7d: Both the fifth and seventh)
      • /SOCKS5_SERVER\|SOCKS5_PORT/d # Delete the line containing "SOCKS"
    • sed -i 's/dotfilels/dotfiles/g' ~/.bashrc # Substitute (e.g. Correct spelling)
      • (3s: Text in the third line)
    • for f in *.wma; do mv "$f" "$(echo "$f" | sed 's/第....//g')"; done
      • . # Any single character
  • Notes
    • Get number line
      • cat --number ~/.ssh/config # Number all output lines
      • nl ~/.ssh/config # Number lines (Except blank lines)
      • Because suitable for files with fewer lines in teaching
    • for f in *; do mv "$f" "$(echo "$f" | sed -E 's/([1][3-9]|[2][0-4])/echo $((\1-12))/ge')"; done # Subtract 12 from the numbers 13 to 24
      • ([1][3-9]|[2][0-4]) # Match numbers 13 to 24
      • e # Arithmetic expression (e.g. $((\1-12)))
    • for f in *; do mv "$f" "$(echo "$f" | sed 's/ //g')"; done # Remove all spaces in file names
    • Because to modify file name in batches.
  • References
    • 2023-05-22_13-51.png
    • 2023-05-21_19-45.png
    • 2023-06-11_21-44.png
    • 2023-04-30_20-54.png
    • man sed # /delete
    • ChatGPT

  • The abbreviation of "Stream Editor" is "sed".

    • sh semester | grep --ignore-case "date" | sed 's/date: //g' > ~/last-modified.txt
  • Notes
    • echo '#!/usr/bin/env bash' > semester
      • Surround "!" with single quotes to solve the problem
        -bash: !/usr/bin/env: event not found
        
  • References
    • man sed
    • cat semester
      #!/usr/bin/env bash
      curl --head --silent https://google.com
      
    • cat ~/last-modified.txt
      Sat, 29 Apr 2023 01:21:44 GMT
      
    • https://missing-semester-cn.github.io/2020/course-shell/

  • View temperature of CPU in Linux

    • cat /sys/class/thermal/thermal_zone0/temp
  • Notes
    • 34000 # Millidegrees Celsius
      • 34000 / 1000 = 34
  • References
    • ChatGPT

  • Use "npm"

    • npm install --global marked # Install a package
  • Notes
    • --registry https://npmreg.proxy.ustclug.org/ # temporarily
    • vi ~/.npmrc # Set a mirror
      registry=https://npmreg.proxy.ustclug.org/
      
      • npm get registry # Get the current registry URL
      • Because to improve the speed. (e.g. npm install express)
    • npm uninstall -g marked-katex-extension # Uninstall
      • npm list -g # List installed packages
    • Install dependencies
      • emerge -aq net-libs/nodejs # Install in Gentoo Linux
      • pacman -S npm # Install in Arch Linux
    • Because to convert Markdown to HTML in script.
      • marked -i yaoniplan.md -o yaoniplan.html
    • Solve the problem
      npm error code ERR_INVALID_URL
      npm error Invalid URL
      
      • Add http:// to your proxy
    • Solve the problem about SQLite3
      • npm uninstall sqlite3
      • npm --force cache clean
      • npm install sqlite3
  • References
    • https://stackoverflow.com/questions/69768980/how-to-resolve-code-err-invalid-url-in-angular-cli-installation/69838005#69838005
    • https://mirrors.ustc.edu.cn/help/npm.html
    • https://discuss.codecademy.com/t/problem-installing-sqlite3/434837/26
    • https://github.com/markedjs/marked
    • npm help install # /-g
    • man npm # Node package manager
    • ChatGPT

  • Start Ubuntu Server 22.04 automatically when connecting to power

    • Set options in BIOS
  • Notes
    • Warning: I did not find the relevant options, maybe the computer is too low-level.
  • References
    • https://superuser.com/questions/984934/i-want-my-pc-to-turn-on-automatically-when-power-is-connected/1532389#1532389

  • Use todo in dmenu

    • height=$(wc -l "$file" | awk '{print $1}')
    • cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
    • while [ -n "$cmd" ]; do
    • if grep -q "^$cmd\$" "$file"; then
  • Notes
    • -l # Lines
    • -p # Prompt
    • $@ # All arguments
    • < # Redirect input to command
    • -n # Not empty
    • -q # Quiet
    • ^ # The beginning of a line
    • \ # Escape character
    • $ # The end of a line
    • -v # Invert
  • References
    • ChatGPT
    • help test
    • https://tools.suckless.org/dmenu/scripts/todo

  • The abbreviation of "Random Access Memory" is "RAM".

    • Store date temporarily
      • The computer is currently using
  • References
    • https://en.wikipedia.org/wiki/Random-access_memory

  • The abbreviation of "Central Processing Unit" is "CPU".

    • A brain
  • Notes
    • Has multiple cores
    • Generate heat
      • A cooling system
  • References
    • ChatGPT

  • Protect spine #idea

    • When looking up
      • Pull the chin up
    • When pressing the neck
      • Rotate to that hand
    • Surrounding the shoulder joint
      • Shake hands, directly in front of shoulder joint
      • Pull elbows up to the top
      • Pull apart on both sides
    • When looking at the phone
      • Put elbow ten centimeters forward
      • Bring elbow close to the chest muscles
    • When looking at computer
      • Keep elbows directly below shoulder joint
      • Let eyes look at the top line
  • Notes
    • Don't bow the head
      • Because it compresses the spine.
  • References
    • 2023-04-24_15-06.png
    • 2023-04-24_15-24.png
    • 2023-04-24_15-52.gif
    • 2023-04-25_15-41.png
    • 2023-04-25_16-05.png
    • https://m.youtube.com/watch?v=udAhvg1ANLM

  • Understand tuberculosis

    • A sickness
  • Notes
    • Bacteria
      • Crowded or dirty places
    • A weak immune system
  • References
    • ChatGPT
    • https://en.wikipedia.org/wiki/Bernhard_Riemann

  • Enable ccache in Gentoo Linux

    • doas emerge dev-util/ccache
    • doas vim /etc/portage/make.conf
      FEATURES="ccache"
      CCACHE_DIR="/var/cache/ccache"
      
  • Notes
    • doas vim /var/cache/ccache/ccache.conf
      max_size = 100.0G
      umask = 002
      hash_dir = false
      compiler_check = %compiler% -dumpversion
      cache_dir_levels = 3
      compression = true
      compression_level = 1
      
    • ccache -s # Show statistics
    • Because to continue to compile Chromium when the compilation fails.
  • References
    • ChatGPT
    • ccache --help
    • https://wiki.gentoo.org/wiki/Ccache

  • Use "reader"

    • vim ~/.config/reader/docker-compose.yml
      version: '3.1'
      services:
        reader:
          image: hectorqin/reader:openj9-latest
          container_name: reader
          restart: always
          ports:
            - 4396:8080
          volumes:
            - ~/.config/reader/logs:/logs
            - ~/.config/reader/storage:/storage
          environment:
            - SPRING_PROFILES_ACTIVE=prod
            - READER_APP_CACHECHAPTERCONTENT=true
      
  • Notes
    • Warning: The user experience is poor compared to novel and comic websites.
    • docker-compose up --detach # Run in the background
    • 192.168.10.100:4396 # Run in Chromium
    • Support webview
            - READER_APP_REMOTEWEBVIEWAPI=http://readerwebview:8050
        readerwebview:
          image: hectorqin/remote-webview
          container_name: readerwebview
          restart: always
          environment:
            - TZ=Asia/Shanghai
      volumes:
        reader:
        readerwebview:
      
  • References
    • https://www.yckceo.com/yuedu/shuyuan/index.html # Book sources
    • https://github.com/hectorqin/reader/blob/c47f870ecc55fa2345527b248111a33a5c9af45a/docker-compose.yml

  • Remove the notification of full screen in Firefox

    • Change the value from "3000" to "0"
      full-screen-api.warning.timeout
      
  • Notes
    • Because to be quiet.
  • References
    • about:config
    • ChatGPT

  • Replace menuconfig with nconfig in Linux

    • doas make nconfig
  • Notes
    • cd /usr/src/linux/ # Change into the Linux source directory before using
    • Ctrl-[ # Esc key
    • Ctrl-j # Enter key
    • Because modifying kernel options is more friendly.
      • Dark mode
      • Exact search mode
  • References
    • ChatGPT
    • Fn-1

  • Enable "~amd64" for Gentoo Linux

    • doas vim /etc/portage/make.conf
      ACCEPT_KEYWORDS="~amd64"
      
  • Notes
    • doas emerge --sync # Update the package list
    • doas emerge -avuDN @world # Upgrade the system to the latest version
    • doas reboot # Make changes effective
    • Warning: This will become unstable unless you are an adventurer.
  • References
    • ChatGPT
    • https://wiki.gentoo.org/wiki/ACCEPT_KEYWORDS

  • Use "memos"

    • vim ~/.config/memos/docker-compose.yml
      version: "3.0"
      services:
        memos:
          image: neosmemo/memos:latest
          container_name: memos
          restart: always
          volumes:
            - ~/.config/memos/:/var/opt/memos
          ports:
            - 5230:5230
      
    • docker-compose up --detach # Run in the background
  • Notes
    • Warning: It takes 10-15 seconds to open the homepage.
      • https://github.com/search?q=repo%3Ausememos%2Fmemos+slow&type=issues
      • Believe that latecomers (Author, you, or me) can change this situation
    • Use JavaScript
      • Double click to enter edit mode
        // Load jQuery from CDN
        var script = document.createElement('script');
        script.src = 'https://code.jquery.com/jquery-3.6.4.min.js';
        document.head.appendChild(script);
        
        // Define actions after jQuery is loaded
        script.onload = function() {
            // Use jQuery ready function
            $(function() {
                // Use event delegation for dynamic elements
                $('body').on('dblclick', '.memo-wrapper .text-base, .memo-wrapper .more-action-btn', function() {
                    var btn = $(this).closest('.memo-wrapper').find('.more-action-btns-container .btn:nth-child(2)');
                    btn.click();
        
                    // Use setTimeout function for timeout
                    setTimeout(function() {
                        $('.dialog-container textarea.text-base').focus();
                    }, 200);
                });
            });
        };
        
    • Send a request using curl
      curl --request POST http://192.168.10.100:5230/api/v1/memo \
          --header "Content-Type: application/json" \
          --header "Authorization: Bearer yourAccessToken" \
          --data '{"content":"Hello, World!"}'
      
    • 192.168.10.100:5230 # Run in Chromium
  • References
    • https://github.com/usememos/memos/issues/2722#issuecomment-1884660058
    • https://www.usememos.com/docs/security/access-tokens
    • https://github.com/usememos/memos/blob/bee6f278ba88246f1e8899e3f768533cac88870c/scripts/docker-compose.yaml

  • Use "microbin"

    • vim ~/.config/microbin/docker-compose.yml
      version: '3'
      
      services:
        microbin:
          image: danielszabo99/microbin
          container_name: microbin
          restart: always
          ports:
            - "31000:8080"
          volumes:
            - ./microbin_data:/app/microbin_data
          command: ["--highlightsyntax", "--private"]
      
    • docker-compose up --detach # Run in the background
  • Notes
    • Warning: Feature copy text does not work
    • 192.168.10.100:31000 # Run in web browser
  • References

    • https://github.com/szabodanika/microbin/issues/110#issuecomment-1317918275
    • https://github.com/szabodanika/microbin/blob/master/compose.yaml
    • ChatGPT

  • Disable a service at boot time in Ubuntu Sever 22.04

    • doas systemctl disable apache2
  • Notes
    • doas systemctl stop apache2 # Stop it before disabling
      • apache2 # Replace it with your desired service
    • Because to solve a problem about "address already in use".
  • References
    • ChatGPT

  • Check some installed packages in Gentoo Linux

    • qlist -I
  • Notes
    • -I # Installed
    • Because to remove unnecessary packages to reduce the time that compile system.
  • References
    • ChatGPT

  • Buy some eggs in supermarket

    • Check the expiration date
      • A bright yolk and a firm egg white
      • Make sure the yolk doesn't move around by gently shaking
      • The clean shell and free of cracks
      • Pick them from the coldest place
  • Notes
    • Store After buying eggs
      • In original carton
      • In the fridge
    • Because there are many benefits of eating eggs.
      • Rich in nutrients: The protein for muscles, vitamin D for bones, and fats for disease (e.g. heart, inflammation, etc.)
      • Manage weight: A low-calorie food, and make you feel fuller
  • References
    • ChatGPT

  • Delete the current file in Vim

    • :!mv % /tmp
  • Notes
    • : # Command mode
    • ! # Execute in a shell
    • mv # Move
    • % # Current file name
    • /tmp # Temporary directory
    • Because to iterate over outdated files.
  • References
    • ChatGPT

  • Improve the website speed of yaoniplan.eu.org

    • Lazy load images
  • References
    • ChatGPT

  • Use "docker-compose"

    • vim ~/.config/clash/docker-compose.yml
      version: '3.7'
      
      services:
        clash:
          image: dreamacro/clash:latest
          container_name: clash
          restart: always
          volumes:
            - ~/.config/clash:/root/.config/clash
          ports:
            - 7890:7890
            - 7891:7891
            - 9090:9090
            
        clash_dashboard:
          image: haishanh/yacd:latest
          container_name: clash_dashboard
          restart: always
          depends_on:
            - clash
          ports:
            - 9091:80
      
    • docker-compose up --detach # Run in the background
  • Notes
    • vim ~/.config/note/docker-compose.yml # Build an image locally (To get speed and stability)
      services:
        note:
          build: .
          container_name: note
          restart: always
          ports:
            - 2003:80
      
      • build: . # Replace it with image: yaoniplan/note:latest to pull from a Docker registry
    • Access the shell of the container
      • docker-compose exec yourApp sh
    • Update a Docker image (Depend on your docker-compose.yml)
      • docker-compose pull # Pull a remote image
      • docker-compose build # Build a local image
      • docker-compose up --detach
      • --file ~/.config/departmentStore/compose.yaml # Use absolute path
    • docker-compose logs # View logs
    • docker-compose stop # Stop
    • docker-compose down # Stop and remove containers
    • docker-compose restart # Restart
    • doas apt install docker-compose # Install it after installing Docker
    • latest # Latest tag
    • ~/.config/clash # Replace it with your path of the config.yaml file
    • In Chromium
      • 192.168.10.100:9091 # The clash dashboard
      • vim ~/.config/clash/config.yaml # Solve a problem about "Failed to connect" of "API Base URL"
        external-controller: 0.0.0.0:9090
        
    • In Gentoo Linux
      • vim ~/.bash_profile
        export http_proxy="192.168.10.100:7890"
        export https_proxy="192.168.10.100:7890"
        export no_proxy="localhost, 192.168.10.100"
        
    • In Android
      # HTTP
      Manual # Proxy settings
      192.168.10.100 # Proxy hostname
      7890 # Proxy port
      
      # SOCKS5
      192.168.10.100 # Server
      7891 # Port
      
    • Solve the problem
      WARN[0000] /home/yaoniplan/parse/docker-compose.yml: `version` is obsolete
      
      • sed -i '1d' ~/parse/docker-compose.yml # Delete the first line containing 'version'
    • Because to run the network proxy tool in the server.
  • References
    • docker compose --help | less
    • docker-compose up --help | less
    • https://blog.n-z.jp/blog/2024-04-02-docker-compose-yaml-version.html
    • 2023-04-16_18-39.png
    • https://www.aimeow.com/zai-ubuntu-serverzhong-tong-guo-docker-composebu-shu-clash/
    • https://blog.vicat.top/archives/linux通过clash来科学上网#2-正戏进阶
    • ChatGPT

  • The abbreviation of "GNU Privacy Guard" is "GPG".

    • A software
  • Notes
    • Because to encrypt private files.
  • References
    • ChatGPT
    • https://en.wikipedia.org/wiki/GNU_Privacy_Guard

  • Use "gpg"

    • gpg --gen-key # Generate key pair
      • Type your name, email, and passphrase
    • gpg --output public.key --armor --export yaoniplan@gmail.com # Export publick key to a file
    • gpg --recipient yaoniplan@gmail.com --encrypt 2023-03-22.tar.gz # Encrypt file
  • Notes
    • passphrase # Strong, otherwise it will not pass
    • yaoniplan@gmail.com # Replace it with your email
  • References
    • man gpg
    • ChatGPT

  • Enable the browser toolbox mode in Firefox

    • Set them to true
      devtools.chrome.enabled
      devtools.debugger.remote-enabled
      
    • Ctrl-Shift-Alt-i # Open the Browser Toolbox
  • Notes
    • vim ~/.mozilla/firefox/bfh7z5di.default-release/chrome/userChrome.css # Example
      /* Hide forward button */
      #forward-button {
          display: none !important;
      }
      
    • Because to customize the Firefox theme with CSS.
  • References
    • about:config
    • ChatGPT
    • https://www.youtube.com/watch?v=bw_M7q3Mtag

  • Hide toolbox automatically in Firefox

    • vim ~/.mozilla/firefox/3y390lx5.default-release/chrome/userChrome.css
      :root{
        --uc-autohide-toolbox-delay: 200ms; /* Wait 0.1s before hiding toolbars */
        --uc-toolbox-rotation: 82deg;  /* This may need to be lower on mac - like 75 or so */
      }
      
      :root[sizemode="maximized"]{
        --uc-toolbox-rotation: 88.5deg;
      }
      
      @media  (-moz-platform: windows),
              (-moz-os-version: windows-win7),
              (-moz-os-version: windows-win10){
      
        #navigator-toolbox:not(:-moz-lwtheme){ background-color: -moz-dialog !important; }
      }
      
      :root[sizemode="fullscreen"],
      #navigator-toolbox[inFullscreen]{ margin-top: 0 !important; }
      
      #navigator-toolbox{
        position: fixed !important;
        display: block;
        background-color: var(--lwt-accent-color,black) !important;
        transition: transform 82ms linear, opacity 82ms linear !important;
        transition-delay: var(--uc-autohide-toolbox-delay) !important;
        transform-origin: top;
        transform: rotateX(var(--uc-toolbox-rotation));
        opacity: 0;
        line-height: 0;
        z-index: 1;
        pointer-events: none;
      }
      
      
      /* #mainPopupSet:hover ~ box > toolbox, */
      /* Uncomment the above line to make toolbar visible if some popup is hovered */
      #navigator-toolbox:hover,
      #navigator-toolbox:focus-within{
        transition-delay: 33ms !important;
        transform: rotateX(0);
        opacity: 1;
      }
      
      #navigator-toolbox > *{ line-height: normal; pointer-events: auto }
      
      #navigator-toolbox,
      #navigator-toolbox > *{
        width: 100vw;
        -moz-appearance: none !important;
      }
      
      /* These two exist for oneliner compatibility */
      #nav-bar{ width: var(--uc-navigationbar-width,100vw) }
      #TabsToolbar{ width: calc(100vw - var(--uc-navigationbar-width,0px)) }
      
      /* Don't apply transform before window has been fully created */
      :root:not([sessionrestored]) #navigator-toolbox{ transform:none !important }
      
      :root[customizing] #navigator-toolbox{
        position: relative !important;
        transform: none !important;
        opacity: 1 !important;
      }
      
      #navigator-toolbox[inFullscreen] > #PersonalToolbar,
      #PersonalToolbar[collapsed="true"]{ display: none }
      
  • Notes
    • about:config
      • toolkit.legacyUserProfileCustomizations.stylesheets # Set to "true"
    • about:profiles
      • cd ~/.mozilla/firefox/3y390lx5.default-release/
      • mkdir chrome/
      • Put userChrome.css file into chrome/ directory
    • Close the Firefox and then open it # Make the changes effective
    • Because to get more space when not focused.
      • Ctrl-l # Focus it
      • It is better to combine the oneliner mode.
  • References
    • 2023-06-01_23-18.gif
    • https://github.com/MrOtherGuy/firefox-csshacks/blob/master/chrome/autohide_toolbox.css

  • Call a Bash function in another file

    • vim ~/.local/bin/master.sh
      notification() {
          notify-send "$notificationMessage" &
      
          for i in {1..2}; do
              paplay "$audioFile"
          done
      }
      
    • vim ~/.local/bin/remindMe.sh
      notificationMessage="Time is up!"
      audioFile="/home/yaoniplan/note/assets/doorbell.mp3"
      
      source $HOME/.local/bin/master.sh
      
      sleep "$1"; notification
      
  • Notes
    • source $HOME/.local/bin/master.sh # Source the file
      • chmod u+x ~/.local/bin/master.sh
      • Use full path to avoid errors when souce a file
    • Because to improve the code reusability.
  • References
    • ChatGPT

  • Decompress a ".tar.bz2" file in Linux

    • tar --bzip2 -xf aspell6-en-2020.12.07-0.tar.bz2
  • References
    • man tar
    • ChatGPT
    • 2023-04-11_15-44.png

  • Act as an IT expert in ChatGPT

    I want you to act as an IT Expert. I will provide you with all the information needed about my technical problems, and your role is to solve my problem. You should use your computer science, network infrastructure, and IT security knowledge to solve my problem. Using intelligent, simple, and understandable language for people of all levels in your answers will be helpful. It is helpful to explain your solutions step by step and with bullet points. Try to avoid too many technical details, but use them when necessary. I want you to reply with the solution, not write any explanations. My first problem is 
    
  • Notes
    • My next problem is "Explain the meaning of 'IT'"
    • Because to get accurate results whthin a range.
  • References
    • https://github.com/f/awesome-chatgpt-prompts#act-as-an-it-expert

  • The abbreviation of "information technology" is "IT".

    • A branch of computer science
  • References
    • https://en.wikipedia.org/wiki/Information_technology

  • Understand "crocodile tears"

    • A display
      • Emotion
  • Notes
    • Pretend to be sad
    • Shed fake tears
  • References
    • TEAM PLAY # TEAM, P, and LAY #NSFW
    • https://en.wikipedia.org/wiki/Crocodile_tears

  • Change the temporary directory in one-liner of Linux

    • cd $(mktemp -d)
  • Notes
    • mktemp # Make a temporary file
    • -d # Directory
    • Because to test an urgent command.
  • References
    • man mktemp
    • ChatGPT

  • Replace spaces in all filenames with underscores in one-liner of Linux

    • for f in *; do mv "$f" "$(echo "$f" | sed 's/ /_/g')"; done
  • Notes
    • Because it is more convenient to read in terminal.
  • References
    • ChatGPT
    • 2023-04-10_13-20.png

  • Set the default application in Linux

    • xdg-mime default feh.desktop image/png
  • Notes
    • feh.desktop # Get the application
      • ls /usr/share/applications/
    • image/png # Replace it with other MIME type
      • xdg-mime query filetype /path/to/image.png # Method one
      • file --mime /mnt/grow/230811seeADentist.jpg # Method two
    • Another way
      • xdg-settings set default-web-browser firefox.desktop
    • Because to use the Feh program to view images.
      • It is more convenient in VimWiki.
      • q # Quit
    • xdg-settings get default-web-browser # View default browser
      • Because to use the command xdg-open https://yaoniplan.eu.org.
  • References
    • ChatGPT

  • The abbreviation of "not safe for work" is "NSFW".

    • A slang
    • To warn
  • References
    • https://en.wikipedia.org/wiki/Not_safe_for_work

  • Open the history sidebar in Firefox

    • Ctrl-h
  • Notes
    • Because to remove focus of search bar.
  • References
    • ChatGPT

  • Use "stat"

    • stat b.txt
  • Notes
    • b.txt # Replace it with a file name
    • Because to know how long the crawler script has been working.
      • View the creation time (Birth day) of a file
  • References
    • ChatGPT
    • 2023-04-09_22-39.png

  • Set DPI in Firefox

    • layout.css.devPixelsPerPx
      • 1.2
  • Notes
    • 1.2 # Replace it with your desired DPI
    • Because to make web content more readable.
  • References
    • about:config
    • ChatGPT

  • View a list of "about" pages in Firefox

    • about:about
  • Notes
    • Because to quickly view some commonly used "about" pages.
      • about:config
      • about:preferences # Type 'version' to check it
      • about:addons
      • about:profiles
      • about:privatebrowsing # Then click 'Open a Private Window'
      • Ctrl-Shift-p # The same as the action above
  • References
    • ChatGPT

  • Set the file type for a file in Vim

    • :set filetype=c
  • Notes
    • c # C programming language
    • Turn off the file type
      • set filetype=off
    • Because to make the following file code more readable.
      • doas vim /etc/portage/savedconfig/x11-wm/dwm-6.3
  • References
    • ChatGPT
    • https://medium.com/@dme86/using-dwm-on-gentoo-7b6049c2d8ae

  • Extract a ".rar" file in Linux

    • rar x userChromeForFirefox.rar /tmp/testRAR/
  • Notes
    • Another method
      • cd $(mktemp -d); unar -o . ~/basicEnglishVoice.rar
      • nix shell nixpkgs#unar # Install dependencies
    • Warning: The rar software is unfree.
    • x # Extract
    • /tmp/testRAR/ # Replace it with your desired decompression path
    • doas emerge -aq app-arch/rar # Install it in Gentoo Linux
    • Extract a ".exe" file in Linux
      • rar x ximaBooks1-100.exe ./001_100/
  • References
    • ChatGPT
    • rar -? | less

  • Patch for DWM in Gentoo Linux

    • Patch in /etc/portage/patches/x11-wm/dwm/
      doas mkdir -p /etc/portage/patches/x11-wm/dwm
      doas cp 01-dwm-scratchpad-20221102-ba56fe9.diff /etc/portage/patches/x11-wm/dwm
      doas emerge -q x11-wm/dwm
      
    • Alt-Shift-q # Quit the DWM to make the changes effective
  • Notes
    • Maybe need to edit the following file manually
      • doas vim /etc/portage/savedconfig/x11-wm/dwm-9999
        /* Solve a problem about `scratchpadname` and `togglescratch` */
        static const char scratchpadname[] = "scratchpad";
        static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "97x16", NULL };
        { MODKEY,                       XK_grave,  togglescratch,  {.v = scratchpadcmd } },
        
  • References
    • ChatGPT
    • https://dwm.suckless.org/patches/scratchpad/
    • https://wiki.gentoo.org/wiki/Dwm#Patches_in_.2Fetc.2Fportage.2Fpatches.2Fcategory.2Fapplication

  • The abbreviation of "window manager" is "WM".

    • A software
  • Notes
    • Because trying to use DWM after using i3.
      • D # Dynamic
  • References
    • https://en.wikipedia.org/wiki/Window_manager

  • Use "dmenu" in Gentoo Linux

    • rm ~/.cache/dmenu_run # Clear cache to refresh
    • Ctrl-y # Paste
    • Change the font size
      static const char *fonts[] = {
          "monospace:size=23"
      };
      
  • Notes
    • Copy a nerd font icon
      • https://github.com/8bitmcu/NerdFont-Cheat-Sheet
      • https://github.com/mbpowers/dmenu-nerd-glyphs
    • Custom search engine
      • https://github.com/bandithijo/dmenu-websearch
    • As calculator
      • https://github.com/philj56/tofi/issues/172#issuecomment-2346453033
    • doas vim /etc/portage/package.use/zz-autounmask
      # Save configuration after reinstalling
      # Required by /etc/portage/savedconfig/x11-misc/dmenu
      x11-misc/dmenu savedconfig
      
      • doas emerge -q x11-misc/dmenu # Make the changes effective
  • References
    • https://tools.suckless.org/dmenu/scripts/
    • Artificial intelligence

  • Change naming rules from "2023-04-05_10:27:31" to "2023-04-05_10-27". #idea

    • Colon # Need escape character
    • 31 # Minutes are enough

  • The abbreviation of "Uniform Resource Locator" is "URL".

    • https://yaoniplan.eu.org/index.html
  • Notes
    • https # A protocol
    • yaoniplan.eu.org # A hostname
    • index.html # A filename
  • References
    • https://en.wikipedia.org/wiki/URL

  • The abbreviation of "Hypertext Transfer Protocol Secure" is "HTTPS".

    • An extension of "HTTP"
      • A protocol
  • References
    • https://en.wikipedia.org/wiki/HTTPS
    • https://en.wikipedia.org/wiki/HTTP

  • The abbreviation of "Unix System Resources" is "usr".

    • A directory
    • In Unix-like operating system
  • References
    • ChatGPT

  • Being cultivated and used by Bole, Maxima will maximize its value. #idea

  • References
    • Lupine the Third

  • Use "DWM" in Gentoo Linux

    • Alt-b # Show or close the status bar
    • Alt-Shift-c # Kill a window
    • Alt-leftMouse # Drag window
    • Alt-rightMouse # Resize window
    • Alt-middleMouse # Restore the previous state after dragging
    • Alt-Tab # Switch to previous workspace
    • Alt-Shift-Enter # New a terminal
    • Alt-Shift-q # Quit the DWM
    • Alt-2 # Go to the number 2 workspace
    • Alt-p # Run the dmenu
    • Layout of workspace
      • Alt-t # Tiled
      • Alt-f # Floating
      • Alt-m # Monocle
    • Alt-Enter # Toggle windows between master and stack
    • Alt-d # Decrease
    • Alt-i # Increase
  • Notes
    • doas vim /etc/portage/package.use/zz-autounmask
      # Save configuration after reinstalling
      # Required by /etc/portage/savedconfig/x11-wm/dwm
      x11-wm/dwm savedconfig
      
    • vim ~/.xprofile
      # Excute automatically when start X11 session
      redshift -O 1500 &
      feh --bg-fill /home/yaoniplan/note/assets/dark.jpg &
      clash &
      
    • doas vim /etc/portage/savedconfig/x11-wm/dwm-9999
      /* Change the terminal command from `st` to `kitty tmux` */
      static const char *termcmd[]  = { "kitty", "tmux", NULL };
      /* Disable status bar */
      static const int showbar            = 0;
      /* Disable border of windows */
      static const unsigned int borderpx  = 0;
      /* Bind shorcut keys "Alt-Shift-l" to programs command `slock` */
      static const char *slockcmd[] = { "slock", NULL };
      static Key keys[] = {
          { MODKEY|ShiftMask, XK_l, spawn, {.v = slockcmd } },
      };
      /* Assign applications to workspace */
      static const Rule rules[] = {
          /* xprop(1):
           *  WM_CLASS(STRING) = instance, class
           *  WM_NAME(STRING) = title
           */
          /* class      instance    title       tags mask     isfloating   monitor */
          { "Chromium-browser-chromium", "chromium-broser-chromium", NULL, 1, 0, -1 },
      };
      
      • doas emerge -q x11-wm/dwm # Recompile it to make the changes effective
    • Use "brightnessctl"
      • brightnessctl set 20% # Adjust brightness to 20%
      • nix profile install nixpkgs#brightnessctl # Install dependencies
  • References
    • man dwm
    • https://wiki.archlinux.org/title/dwm#Adjusting_brightness
    • https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/
    • https://dwm.suckless.org/tutorial/
    • https://wiki.gentoo.org/wiki/Dwm
    • ChatGPT

  • The abbreviation of "full high definition" is "FHD".

    • A graphics display resolution
    • 1920x1080 pixels
  • Notes
    • 1920 # Width
    • 1080 # Height
    • The abbreviation of "quad high definition" is "QHD".
    • Because this abbreviation can be seen on some website video players.
  • References
    • https://en.wikipedia.org/wiki/Graphics_display_resolution

  • The abbreviation of "Bourne Again Shell" is "Bash".

    • Born again
  • References
    • https://en.wikipedia.org/wiki/Bash_(Unix_shell)

  • Enable support for ANSI escape codes when using the less command

    • curl wttr.in | less -R
  • Notes
    • -R # Raw
  • References
    • man less
    • ChatGPT
    • 2023-04-03_18-55.gif

  • Use wget to download files to the specified directory

    • vim ~/.local/bin/getWeatherInformation.sh
      # Create a temporary directory to store the file
      temporaryDir=$(mktemp --directory)
      
      # Download the weather image and save it to the temporary directory
      wget -P "$temporaryDir" "https://wttr.in/$city.png"
      
  • Notes
    • -P # Prefix
  • References
    • man wget
    • ChatGPT

  • Delete all workflows of GitHub Actions

    • #Current.iim
      VERSION BUILD=1011 RECORDER=CR
      SET !LOOP 2
      
      ' Do something with the current data source line, such as filling out a form field
      TAG POS=1 TYPE=SUMMARY ATTR=TXT:Delete<SP>workflow<SP>run
      TAG POS=1 TYPE=BUTTON FORM=ACTION:/yaoniplan/note/actions/runs/* ATTR=TXT:Yes,<SP>permanently<SP>delete<SP>this<SP>workflow<SP>run
      WAIT SECONDS=3
      
      ' End the loop
      SET !LOOP EVAL("{{!LOOP}}-1000")
      
      • Click "Record Macro" button to start recording
      • Click the "Save Page" button to save it
      • Click the "Play Loop" button to start the loop
  • Notes
    • Warning: The extension does not work. (2023-09-01)
    • yaoniplan/note # Replace it with your user name and repository name
    • 3 # Replace it with your desired waitting seconds
    • Install an extension named "iMacros" if you don't have it
    • Disadvantage
      • Take about 3 hours if you have three thousand workflows
    • Advantage
      • Click automatically
      • Run it in FireFox when you are using Chromium
  • References
    • ChatGPT

  • Install package with version "9999" in Gentoo Linux

    • doas vim /etc/portage/package.accept_keywords
      media-video/mpv **
      
    • doas emerge -aq media-video/mpv
  • References
    • https://www.youtube.com/watch?v=MmvzAHjgd0Y

  • Disable quick find in Firefox

    • Set the following option to "false"
      accessibility.typeaheadfind
      accessibility.typeaheadfind.autostart
      accessibility.typeaheadfind.manual
      
  • Notes
    • Because to use a extension named Vimium C.
  • References
    • about:config
    • https://support.mozilla.org/en-US/questions/1273459

  • The abbreviation of "pickup artist" is "PUA".

    • Inner game
      • Understanding of psychology
      • Confidence
      • Self-esteem
      • Social skills
      • Physical fitness
      • Fashion sense
      • grooming
    • Outer game
      • Interactive
  • Notes
    • A woman
      • A target
    • A process
      • A game
    • Raise his own value and lower her value
      • A strategy
  • References
    • Lupine the Third
    • https://en.wikipedia.org/wiki/Pickup_artist

  • The abbreviation of "chief executive officer" is "CEO".

    • Sam Altman is the CEO of OpenAI.
  • References
    • https://en.wikipedia.org/wiki/Chief_executive_officer

  • The abbreviation of "Thursday" is "Thu".

    • The god of thunder
      • Mythological figures
    • Jupiter
      • Celestial bodies
    • The fourth day of the week
  • Notes
    • Because weather apps display this abbreviation.
  • References
    • ChatGPT

  • The abbreviation of "International Criminal Police Organization" is "ICPO".

  • References
    • Lupine the Third
    • https://en.wikipedia.org/wiki/Interpol

  • Run an ".AppImage" file in Linux

    • ./Cursor-0.1.9.AppImage
  • Notes
    • Cursor-0.1.9.AppImage # Replace it with your desired appimage
    • chmod u+x Cursor-0.1.9.AppImage # Make it executable if permission denied
    • ./Cursor-0.1.9.AppImage --appimage-extract # Solve the problem
      yaoniplan@tux ~ $ ./Cursor-0.1.9.AppImage
      dlopen(): error loading libfuse.so.2
      
      AppImages require FUSE to run.
      You might still be able to extract the contents of this AppImage
      if you run it with the --appimage-extract option.
      See https://github.com/AppImage/AppImageKit/wiki/FUSE
      for more information
      
      • ./squashfs-root/AppRun
  • References
    • ChatGPT

  • Run a command 20 times in one-liner Bash

    • for times in {1..20}; do treeLike.sh note/; done
  • Notes
    • times # Replace it with your desired variable name
    • 20 # Replace it with your desired times
    • treeLike.sh note/ # Replace it with your desired command
    • Because to test whether the changes takes effect when run the following command
      • vim ~/.tmux.conf
        # Retain more history when scrolling up
        set -g history-limit 50000
        
      • tmux source-file ~/.tmux.conf
  • References
    • ChatGPT

  • Correct the format of JavaScript code

    • https://beautifier.io
    • https://prettier.io/
  • Notes
    • Use "js-beautify"
      • wl-paste | js-beautify # Format code
      • uv tool install jsbeautifier # Install dependencies
    • Because to make the code more readable
      • marked.min.js
  • References
    • ChatGPT

  • Understand the "infinite monkey theorem"

    • Infinite time
    • Monkey hit keys
    • Shakespeare's Hamlet
  • Notes
    • Events with nonzero probability almost surely occur
  • References
    • https://en.wikipedia.org/wiki/Infinite_monkey_theorem

  • Install PHP in Linux

    • doas emerge dev-lang/php # In Gentoo Linux
    • doas apt install php # In Ubuntu Server 22.04
  • Notes
    • Sovle the problem "/bin/bash: line 1: php: command not found"
  • References
    • ChatGPT

  • The abbriviation of "Transport Layer Security" is "TLS".

    • A protocol
  • Notes
    • Because to redirect all requests from HTTP to HTTPS.
  • References
    • https://en.wikipedia.org/wiki/Transport_Layer_Security

  • Redirect all requests from HTTP to HTTPS in Cloudflare

    • Full
      • In "Overview" of "SSL/TLS"
    • Always Use HTTPS
      • In "Edge Certificates" of "SSL/TLS"
  • References
    • ChatGPT
    • https://dash.cloudflare.com/

  • View Git commit messages in one-line format

    • git log --oneline
  • Notes
    • Because for faster viewing of recent commits.
  • References
    • ChatGPT

  • Set the Referer header to desired value

    curl --user \
    natas4:tKOcJIbzM4lTs8hbCmzn5Zr4434fGZQm \
    --referer \
    http://natas5.natas.labs.overthewire.org/ \
    http://natas4.natas.labs.overthewire.org/
    
  • Notes
    • Because to pass the Natas4 level of overthewire.org.
  • References
    • man curl
    • https://github.com/psmiraglia/ctf/blob/master/overthewire/natas/natas04.md

  • Convert hexadecimal string to binary data of ASCII characters

    • echo 3d3d516343746d4d6d6c315669563362 | xxd -r -p
  • Notes
    • -r # Revert
    • -p # Plain
    • ==QcCtmMml1ViV3b # Output
    • Because to pass the Natas8 level of overthewire.org.
  • References
    • man xxd
    • ChatGPT

  • Reverse a string in Linux

    • echo "==QcCtmMml1ViV3b" | rev
  • Notes
    • b3ViV1lmMmtCcQ== # Output
    • Because to pass the Natas8 level of overthewire.org.
  • References
    • ChatGPT

  • Install Node.js and npm in Ubuntu Server 22.04

    • doas apt update
    • doas apt install nodejs npm -y
    • git clone https://github.com/KrauseFx/markdown-to-html-github-style
    • cd markdown-to-html-github-style/
    • npm install
    • node convert.js .
  • References
    • ChatGPT
    • https://github.com/KrauseFx/markdown-to-html-github-style

  • The abbreviation of "automated teller machine" is "ATM".

    • A device
    • To perform transactions
  • References
    • https://en.wikipedia.org/wiki/Automated_teller_machine

  • The abbreviation of "large language model" is "LLM".

    • A language model
  • References
    • https://en.wikipedia.org/wiki/Large_language_model

  • The abbreviation of "artificial intelligence" is "AI".

    • An intelligence
  • References
    • https://en.wikipedia.org/wiki/Artificial_intelligence

  • Display the correct date and time in Systemd

    • doas timedatectl set-timezone Asia/Shanghai
  • Notes
    • timedatectl # View the current timezone
    • Asia/Shanghai # Replace it with your desired timezone
      • timedatectl list-timezones # List all timezones
  • References
    • man timedatectl
    • ChatGPT

  • Use the "man" tool in Linux

    • b # Backward one window (The same as Ctrl-b)
    • f # Forward one window (The same as Ctrl-f)
    • ma # Mark with "a" letter
  • Notes
    • 'a # Go to the "a" mark
  • References
    • h

  • Upgrade the Vim in Ubuntu Server 22.04

    • doas add-apt-repository ppa:jonathonf/vim
    • doas apt update
    • doas apt install vim
  • Notes
    • vim --version # Check the version
    • Because it is necessary to meet the usage conditions of "Codeium".
  • References
    • man vim
    • ChatGPT

  • Change a repository description for GitHub via command line

    • Type in terminal
      curl -L \
        -X PATCH \
        -H "Accept: application/vnd.github+json" \
        -H "Authorization: Bearer yourPersonalAccessToken" \
        -H "X-GitHub-Api-Version: 2022-11-28" \
        https://api.github.com/repos/yaoniplan/dotfiles \
        -d '{"description":"Minimal dotfiles in Linux server"}'
      
  • Notes
    • yourPersonalAccessToken # Replace it with your GitHub PAT
      • Get it in "Personal access tokens" of "Developer settings"
      • Remember to click the "repo" checkbox to grant this token access to the repository
    • yaoniplan/dotfiles # Replace it with your user and repository name
    • Minimal dotfiles in Linux server # Replace it with your desired description
  • References
    • ChatGPT
    • https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#update-a-repository

  • Paste content from clipboard to dmenu

    • $(xclip -o)
  • Notes
    • -o # Out
    • doas emerge -aq x11-misc/xclip # Install it if you don't have it
    • mpv --speed=2 $(xclip -o) # Type it before you pressed Ctrl-c to copy content
    • Another way
      • $(xsel -ob)
      • xsel # X selection
      • -o # Output
      • -b # Clipboard
  • References
    • man xsel
    • ChatGPT

  • The abbreviation of "personal access token" is "PAT".

    • A string
    • To authenticate
  • Notes
    • Because to use GitHub PAT to change a repository description via command line
  • References
    • https://en.wikipedia.org/wiki/Personal_access_token

  • Use "Codeium" to autocomplete in Vim

    • :Codeium Auth
  • Notes
    • vim ~/.vimrc # Install it if you don't have it
      Plug 'Exafunction/codeium.vim'
      
      • source ~/.vimrc
      • :PlugInstall
  • References
    • :help Codeium
    • https://github.com/Exafunction/codeium.vim#-installation-options

  • Use a development branch in Git

    • First use
      git branch development
      git checkout development
      git add testDevelopment.md
      git commit -m "Add testDevelopment.md"
      
    • Push the code
      git push origin development
      git checkout master
      git merge development
      git push origin master
      
  • Notes
    • If you want to stay on the development branch to push the code
      • git push origin development # Push to the development branch
      • git push origin development:master # Push to the master branch
    • git branch --all # View all branches
    • git push --all origin # Push all branches to GitHub
    • git branch -d dev # Delete a branch locally
    • Because using two repositories is a bit cumbersome.
    • git clone git@192.168.10.100:/var/git/note.git --branch development # Solve the problem
      warning: remote HEAD refers to nonexistent ref, unable to checkout
      
      • git push origin development:master # You don't push your master branch to git@192.168.10.100:/var/git/note.git
  • References
    • ChatGPT
    • https://stackoverflow.com/questions/41269587/github-clone-repo-error-warning-remote-head-refers-to-nonexistent-ref-unable/41269696#41269696
    • https://stackoverflow.com/questions/14168677/merge-development-branch-with-master/14169244#14169244
    • https://github.com/xx025/carrot

  • Search for a piece of music in search bar of Chromium

    • 8am I can see the success rate
  • Notes
    • 8am # Music name
    • I can see the success rate # Animation name

  • Learn some Bash projects to master it quickly

    • A backup script
    • Automate system updates
    • A password manager
    • A weather app
  • Notes
    • Because the default shell of most Linux distributions is bash.
  • References
    • ChatGPT

  • Untrack a file instead of removing it in Git

    • git rm --cached .bashrc
    • git commit -m "Stop tracking .bashrc"
  • Notes
    • .bashrc # Replace it with a file you want to untrack
    • Because for compatibility with server (e.g. Ubuntu Server 22.04, FreeBSD, etc.)
  • References
    • git rm --help
    • ChatGPT

  • Pass bandit 27 level in overthewire.org

    • git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repo
  • Notes
    • :2220 # Add the port to solve the following problem
      !!! You are trying to log into this SSH server on port 22, which is not intended.
      
  • References
    • https://overthewire.org/wargames/bandit/bandit28.html
    • https://stackoverflow.com/questions/74289381/trying-to-pass-bandit-level-27-on-overthewire-org-git-clone-not-working/74395405#74395405

  • Decompress a ".bz" file

    • bzip2 -d testData.bz
  • Notes
    • -d # Decompress
  • References
    • man bzip2
    • https://medium.com/secttp/overthewire-bandit-level-12-439f655f6fd5

  • Use a private key to login the remote server

    • ssh -i sshkey.private bandit14@bandit.labs.overthewire.org -p 2220
  • Notes
    • -i # Identity
    • sshkey.private # Replace it with remote private key file
  • References
    • man ssh
    • https://explainshell.com/explain?cmd=ssh+-i+sshkey.private+bandit14%40localhost
    • https://overthewire.org/wargames/bandit/bandit14.html

  • Redirct the output of an interactive command to a file

    • script /tmp/getPrivateKey.txt
    • Type your command
  • Notes
    • exit # Exit the script command
    • Because to get a private key of output of the openssl s_client -connect localhost:31790 command
  • References
    • ChatGPT
    • https://programmercave0.github.io/blog/2019/12/24/Bandit-Level-16-to-Level-19-OverTheWire

  • Execute a command of remote server using SSH

    • ssh bandit18@bandit.labs.overthewire.org -p 2220 head readme
  • Notes
    • head readme # Replace it with your desired command
    • Specify PATH in ssh command
      ssh -t yaoniplan@192.168.10.100 'export PATH=$PATH:$HOME/.local/bin; backupPrivatefiles.sh'
      
      • -t # Tty
    • Because to pass the level about "logout when logging in with SSH".
  • References
    • ChatGPT
    • 2023-03-15_12:17:57.png
    • https://mayadevbe.me/posts/overthewire/bandit/level19/

  • The abbreviation of "standardized test" is "SAT".

    • For college admissions
  • References
    • https://en.wikipedia.org/wiki/SAT

  • Count a number of files in the current directory in Linux

    • ls -1 | wc -l
  • Notes
    • -1 # One file per line
    • -l # Lines
  • References
    • man ls
    • man wc
    • ChatGPT

  • Install pip with Python3 in Ubuntu Server 22.04

    • doas apt install python3 python3-pip
  • Notes
    • pip3 --version # Verify it
    • Because to use python3 -m pip install "pelican[markdown]"
  • References
    • ChatGPT

  • Use a package mirror for pip in Ubuntu Server 22.04

    • pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  • Notes
    • Because to improve the download speed
  • References
    • ChatGPT
    • https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

  • Reverse the order of files in Linux

    • cat $(ls -r ~/note/journals/*.md) > ~/note/.github/README.md
  • Notes
    • -r # Reverse
  • References
    • man ls
    • ChatGPT

  • Use the "diff" command to compare two files in Ubuntu Server 22.04

    • diff countTheNumberOfVowelsAndConsonants.c testCountTheNumberOfVowelsAndConsonants.c
  • References
    • ChatGPT

  • Remove some files excluding the ".c" extension in Linux

    • find . -maxdepth 1 -type f -not -name "*.c" -delete
  • Notes
    • Warning: Delete them one by one unless you are an adventurer
    • -maxdepth 1 # Only the current directory
    • f # File
    • rm -rf !(*.apkg) # Remove files excluding ".apkg" extension
      • Solve the problem
        yaoniplan@tux ~/Downloads/deck $ rm -rf !(*.apkg)
        bash: !: event not found
        yaoniplan@tux ~/Downloads/deck $
        
      • shopt -s extglob # Set extglob shell option temporarily
  • References
    • 2023-03-13_14:58:24.png
    • ChatGPT

  • Use "mpv"

    • vim ~/.config/mpv/mpv.conf
      # Display filename as title (Avoid ads in title)
      title=${filename}
      
      • https://snoo.habedieeh.re/r/mpv/comments/oq40gb/want_to_display_filename_as_title_of_video/
    • ` # Open the console for debugging (To test keybindings)
      • set video-rotate 90 # Set rotation to 90 degrees
    • Ctrl-h # Hardware decoding (May reduce CPU usage)
    • Shift-i # Information
    • mpv av://v4l2:/dev/video0 # Capture and display live video from a camera
      • --vf=hflip # Horizontal flip (Like in phone)
      • --profile=low-latency --untimed # Low latency
    • mpv --speed=2 --fullscreen "URLOfTheVideo"
  • Notes
    • vi ~/.config/mpv/mpv.conf # Specify the path of the downloader (Use patched software temporarily)
      script-opts-append=ytdl_hook-ytdl_path=/home/yaoniplan/.local/bin/yt-dlp
      
    • Solve the problem
      yaoniplan@tux ~ $ mpv --no-config "https://www.example.com/video/example/"
      [ytdl_hook] ERROR: [Example] example: Unable to download JSON metadata: HTTP Error 412: Precondition Failed (caused by <HTTPError 412: Precondition Failed>)
      [ytdl_hook] youtube-dl failed: unexpected error occurred
      Failed to recognize file format.
      Exiting... (Errors when loading file)
      yaoniplan@tux ~ $
      
      • yt-dlp -o - <URL> | mpv - # Play the video that yt-dlp command can download
      • https://libreddit.nohost.network/r/mpv/comments/opoorx/mpv_with_ytdlp/j7exh1n/#j7exh1n
    • Warning: Drop a lot of frames to play high quality video on an old computer in video speed mode (e.g. 3x, 2x, etc.)
      • https://github.com/mpv-player/mpv/issues/10564#issuecomment-1615683626
      • Maybe it's because it's running on Wayland
    • Control from command-line
      • mpv --input-ipc-server=/tmp/mpvsocket --playlist=/mnt/server/interestAndHobby/music/ # Reduce gap: --prefetch-playlist=yes Cache next song, --no-audio-display Don't show cover, --save-position-on-quit Watch later
      • echo playlist_next | socat - "/tmp/mpvsocket" # Play next song in playlist
      • echo 'run rm "${path}"; playlist-remove current' | socat - "/tmp/mpvsocket" # Delete current song
      • echo '{ "command": [ "keypress", "D" ] }' | socat - /tmp/mpvsocket # Another way that use shortcut keys
      • for times in {1..5}; do echo '{ "command": [ "keypress", "/" ] }' | socat - /tmp/mpvsocket; done # Decrease 10% volume
      • echo '{ "command": ["get_property", "path"] }' | socat - /tmp/mpvsocket | jq -r '.data' | sed 's#/[^/]*$##' # Get file path
      • # # Delimiter (Avoid conflicts with the path)
    • Use scripts
      • git clone https://github.com/CogentRedTester/mpv-file-browser ~/.config/mpv/scripts/file-browser
      • cp ~/.config/mpv/scripts/file-browser/docs/file_browser.conf ~/.config/mpv/script-opts/
        ...
        # Replace `/mnt/` with your file directory
        root=~/,/mnt/
        ...
        custom_keybinds=yes
        ...
        
      • vim ~/.config/mpv/script-opts/file-browser-keybinds.json
        [
            {
                "key": "Ctrl+[",
                "command": ["script-binding", "file_browser/dynamic/close"]
            },
            {
                "key": "SPACE",
                "command": ["script-binding", "file_browser/dynamic/play"]
            },
            {
                "key": "k",
                "command": ["script-binding", "file_browser/dynamic/scroll_up"],
                "flags": { "repeatable": true }
            },
            {
                "key": "j",
                "command": ["script-binding", "file_browser/dynamic/scroll_down"],
                "flags": { "repeatable": true }
            },
            {
                "key": "l",
                "command": ["script-binding", "file_browser/dynamic/down_dir"],
                "flags": { "repeatable": true }
            },
            {
                "key": "h",
                "command": ["script-binding", "file_browser/dynamic/up_dir"],
                "flags": { "repeatable": true }
            },
            {
                "comment": "Delete the current file and directory",
                "key": "D",
                "command": [
                    ["run", "rm", "-r", "-f", "%p%n"],
                    ["script-binding", "file_browser/dynamic/reload"]
                ]
            },
            {
                "comment": "opens the currently selected items in a new mpv window",
                "key": "M",
                "command": ["run", "mpv", "%p%n"]
            },
            {
                "comment": "Copy filepath to clipboard",
                "key": "Ctrl+c",
                "command": [
                    ["run", "sh", "-c", "echo -n '%F' | wl-copy"],
                    ["run", "notify-send", "%F"]
                ]
            }
        ]
        
      • mpv /mnt/server/来自分享/*全球*/ # Press Ctrl-o (Or menuKey) to open file browser
      • --player-operation-mode=pseudo-gui # If you don't want to play it immediately (Select path using script)
      • https://github.com/CogentRedTester/mpv-file-browser/issues/87#issue-1557145715 # Support finding files
        user-input-module.lua -> script-modules/user-input-module.lua
        find.lua -> script-modules/file-browser-addons/find.lua
        user-input.lua -> scripts/user-input.lua
        
      • Ctrl-r # Refresh playlist
      • https://github.com/CogentRedTester/mpv-user-input#installation
    • vi ~/.config/mpv/input.conf # Bind a shortcut key
      # Rotate the screen clockwise
      r add video-rotate 90
      # Rotate the screen counterclockwise
      Shift+r add video-rotate -90
      # Print title (See https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst#property-list to get the property)
      # If the length of media-title is zero, then print filename
      p run "/bin/sh" "-c" "if [[ -z '${media-title}' ]]; then notify-send '${filename}'; else notify-send '${media-title}'; fi"
      # Copy the full path to clipboard
      Ctrl+shift+c run "/bin/sh" "-c" "echo '${path}' | wl-copy"
      # Print and copy file path (Wrap `${path}` in quotes to avoid spaces in file names)
      Ctrl+shift+x run "/bin/sh" "-c" "notify-send `dirname '${path}'`; echo `dirname '${path}'` | wl-copy"
      # Reload after editing `~/.config/mpv/input.conf`
      CTRL+r run "mpv" "${path}"; quit-watch-later
      # `l` go forward 5 seconds (Optional: `no-osd`, `exact`)
      l no-osd seek 5 exact
      # `D` removes the current file
      D run rm "${path}"; playlist-remove current
      # `Ctrl-l` Show playlist for 5 seconds (Default: `Fn-8`)
      CTRL+l show-text "${playlist}" 5000
      
    • mpv --cache=no # For online streaming (Forward and back very fast, without caching the entire file)
    • Alt-Hyphen # Zoom out video (Opposite: Alt-+)
      • Alt-Down # Move focus down (Pan video)
    • l # Set A loop point, set B loop point, and clear A-B loop
    • Solve a problem about has no sound
      • -ao=pulse
    • For live streaming
      • https://github.com/streamlink/streamlink/issues/4609#issuecomment-1159787392
      • Click 'Copy Media Links to the Clipboard'
    • For music
      • --loop-playlist # Loop infinitely (The same as L)
      • --shuffle # Random playback
      • --no-video # For audio only
      • --player-operation-mode=cplayer # Display in the terminal instead of a separate window (If you want to disable pseudo-gui temporarily)
    • --start=00:54:00 # For test
    • --mute=yes # For NSFW
    • G # Increase size of subtitle
    • --sub-file-paths=subtitles/ # For animation
      • subtitles/ # Replace it with your directory including subtitles
      • --sub-file="subtitles/01.ass" # For movie
      • v # Visualize subtitle
    • m # Mute (For NSFW)
    • --playlist=computerScience.txt
    • --http-proxy=http://192.168.10.100:7890
      • vim ~/.config/mpv/mpv.conf # Another way
        --http-proxy=http://192.168.10.100:7890
        
    • mpv yourM3UFileIncludingM3U8URLs # play internet protocol television (e.g. https://raw.githubusercontent.com/BurningC4/Chinese-IPTV/master/TV-IPV4.m3u)
      • < # Go backward in the playlist
    • / # Decrease volume
    • } # Double speed
    • o # Show progress bar
    • f # Full screen
      • vi ~/.config/mpv/mpv.conf # Another way
        --fullscreen
        
    • q # Quit
    • Because be convenient to enable the full screen feature.
      • Play video smoothly
  • References
    • https://wiki.archlinux.org/title/Mpv#Key_bindings
    • https://redlib.private.coffee/r/mpv/comments/ifx6k3/how_do_you_copy_the_full_path_to_clipboard/
    • https://old.reddit.com/r/mpv/comments/vc2mvc/restart_mpv_with_keybinding/
    • https://old.reddit.com/r/mpv/comments/l9ez04/mpv_inputconf_not_working/htayzg7/
    • https://github.com/CogentRedTester/mpv-file-browser/issues/44#issue-1140618808
    • https://github.com/CogentRedTester/mpv-file-browser/discussions/75#discussion-4477815
    • https://mim.mbirgin.com/?c=posts&id=200
    • https://filmsbykris.com/scripts/MyNotes/colored/MPV%20remote%20socket%20commands%20for%20script%20control%20and%20server%20use-23PXxpiD.html
    • https://alexherbo2.github.io/config/mpv/control-mpv-from-the-command-line/
    • https://github.com/mpv-player/mpv/blob/73a06ffae663e9fb78c5dff4b6bd01a637296a69/etc/input.conf#L164
    • https://github.com/CogentRedTester/mpv-file-browser/blob/master/docs/file-browser-keybinds.json
    • https://github.com/CogentRedTester/mpv-file-browser#basic
    • https://askubuntu.com/questions/1412462/mpv-accidently-got-no-sound-problem
    • https://bbs.archlinux.org/viewtopic.php?id=281480
    • https://superuser.com/questions/663247/is-it-possible-to-delete-an-mp3-file-currently-played-in-mplayer/854087#854087
    • https://github.com/mpv-player/mpv/issues/11985#issuecomment-1646557265
    • https://wiki.gentoo.org/wiki/Mpv#Key_bindings
    • man mpv # /Cache$ /hardware
    • Artificial intelligence

  • Add a user in Ubuntu Server 22.04

    • doas adduser git
  • Notes
    • git # Replace it with your desired name
    • Because to use the remote Git repository
  • References
    • ChatGPT

  • Use "doas"

    • echo 'permit :wheel' >> /etc/doas.conf
  • Notes
    • su root # Substitute to root user
    • pacman --sync doas # Install dependencies
    • groupadd wheel # Create a group if it does not exist
    • usermod -aG wheel yaoniplan # Add your user to wheel group
    • Close and open terminal to make changes effective
    • Because it is easier to use than "sudo".
  • References
    • man doas.conf
    • ChatGPT

  • Add a user to a group in Ubuntu Server 22.04

    • sudo usermod -aG wheel git
  • Notes
    • -a # Append
    • -G # Groups
    • wheel # Replace it with your desired group
    • git # Replace it with your desired user
    • See which groups a user belongs to (Two methods)
      • groups git
      • grep git /etc/group
    • Because to use the doas command
  • References
    • man usermod
    • ChatGPT

  • Run the C program in Linux

    • gcc learnC.c && ./a.out
  • Notes
    • gcc factorial.c -o factorial # Compile
      • -o # Outfile
    • ./factorial # Run the program
  • References
    • man gcc
    • ChatGPT

  • Use aliyunpan-sync in Docker

    • In Docker
      docker run -d --name=aliyunpan-sync --restart=always -v "<your local dir>:/home/app/data" -e TZ="Asia/Shanghai" -e ALIYUNPAN_REFRESH_TOKEN="<your refreshToken>" -e ALIYUNPAN_PAN_DIR="<your drive pan dir>" -e ALIYUNPAN_SYNC_MODE="upload" -e ALIYUNPAN_TASK_STEP="sync" tickstep/aliyunpan-sync:v0.2.6
      
  • Notes
    • /var/aliyundrive
    • :v0.2.6 # Sovle the problem
      docker: Error response from daemon: manifest for tickstep/aliyunpan-sync:latest not found: manifest unknown: manifest unknown.
      
  • References
    • https://github.com/tickstep/aliyunpan#docker安装

  • Use the "screen" command in Ubuntu Server 22.04

    • screen
      • Ctrl-a k # Kill a window
      • Ctrl-a c # Create a window
      • Ctrl-a n # Switch between window
    • Ctrl-a :
      • sessionname learnBash # Rename the current session name
    • screen vim someCPrograms/checkPrimeNumber.c
    • screen -list # Get ID and name of sessions
    • screen -S testScreenList # Create a session
    • screen -X -S 14099 quit # Terminate a session
    • screen -r testScreenReattach # Reattach a session
    • Ctrl-a d # Deattach
  • Notes
    • -S # Sessionname
    • testScreenList # Replace it with your desired session name
    • 14099 # Replace it with ID of sessions
  • References
    • man screen
    • ChatGPT

  • Use "rclone"

    • rclone config
      • S3
        n # n) New remote
        r2 # name
        5 # Storage of s3
        6 # Cloudflare R2 Storage
        1 # Enter AWS credentials in the next step.
        ****** # Access key id
        ****** # Secret access key
        1 # region of auto
        https://******.r2.cloudflarestorage.com # endpoint
        the rest of options are the default
        q # Quit config
        
      • WebDAV
        n # n) New remote
        yaoniplan # name
        31 # Storage of WebDAV
        http://192.168.10.100:5244/dav # URL
        4 # vendor of other
        admin # user of AList
        ****** # password of AList
        the rest of options are the default
        q # q) Quit config
        
      • vi ~/.config/rclone/rclone.conf # Another way
        [yaoniplan]
        type = webdav
        url = http://192.168.10.100:5244/dav
        vendor = other
        user = admin
        pass = H2bvDv2jDfEuI3fMJ263WjkI
        
    • doas mkdir /mnt/$(whoami)/
    • doas chown -R $(whoami):$(whoami) /mnt/$(whoami)/
    • rclone mount yaoniplan:/ /mnt/$(whoami)/ &
  • Notes
    • rclone ls r2:products # List files in a bucket
    • rclone copy ~/Downloads/6901028063876.jpeg r2:products # Upload files to the bucket
    • rclone copy --http-url https://www.cs.mun.ca/~boliver/70s :http: alist:/interestAndHobby/ # Copy from remote to another
    • rclone copy music:/ ~/music/ # Copy from remote to local
    • Because to mount the AList to the local directory.
    • doas apt install rclone # Install it in Ubuntu Server 22.04
    • nix profile install nixpkgs#rclone # Install dependencies
    • rclone lsd yaoniplan:/ # List directory
    • crontab -e # Run it at boot in Ubuntu Server 22.04
      @reboot /usr/bin/rclone mount yaoniplan:/ /mnt/yaoniplan/ &
      
      • /usr/bin/rclone # Get it by running which rclone
    • Solve the problem
      2023/04/13 23:05:24 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
      
      • ln -s /usr/bin/fusermount3 /usr/bin/fusermount
    • Solve the problem
      2023/04/14 02:48:01 ERROR : selfImprovement/thinkingCognition/个人爆发式成长的25种思维/01第1讲 筛选思维:随意选择的人生,不值得一过(01).wma: vfs cache: failed to download: vfs reader: failed to write to cache file: 403 Forbidden
      
      • Change "302 redirect" to "native proxy" in "WebDAV policy"
      • rclone mount testDAVOne:/ /mnt/testDAVOne/ --header "Referer:" # Another way
    • Mount to another computer
      • doas emerge -q net-fs/sshfs # Install dependencies
      • sshfs yaoniplan@192.168.10.100:/mnt/yaoniplan/ /mnt/yaoniplan/ # Mount
      • fusermount -u /mnt/yaoniplan # Unmount that solve the problem
        yaoniplan@tux ~ $ <3>ERROR : /mnt/music/: Unmounted rclone mount
        ls: cannot access '/mnt/yaoniplan': Transport endpoint is not connected
        
      • vim ~/.xprofile # Run it at boot in Gentoo Linux
        sshfs yaoniplan@192.168.10.100:/mnt/yaoniplan/ /mnt/yaoniplan/ &
        
      • Wraning: It has some errors when play videos.
  • References
    • https://forum.rclone.org/t/copy-from-one-rclone-remote-to-another/9420/4
    • https://rclone.org/http/#usage-without-a-config-file
    • https://github.com/alist-org/alist/discussions/630#discussioncomment-2424414
    • https://rclone.org/install/#run-periodically-from-cron
    • https://github.com/alist-org/alist/discussions/1724#discussioncomment-3901460
    • https://github.com/rclone/rclone/issues/6856#issuecomment-1479853571
    • https://wiki.gentoo.org/wiki/Filesystem_in_Userspace
    • https://www.youtube.com/watch?v=hoUPP1aLE60
    • Artificial intelligence

  • There is no right to choose. #idea

    • The ownership is in the hands of others
    • You only have the right to use
  • Notes
    • Privacy may be less important
    • Depending on who owns the property

  • Use Vimium C for file:// in Chromium

    • Click "Allow access to file URLs" button
  • Notes
    • Warning: Stability and security will suffer.
  • References
    • about:extensions
    • https://github.com/gdh1995/vimium-c/issues/747#issuecomment-1272771573

  • Set a static IP address in Ubuntu Server 22.04

    • doas vim /etc/netplan/00-installer-config.yaml
      # This is the network config written by 'subiquity'
      network:
        ethernets:
          enp2s0:
            dhcp4: no
            addresses: [192.168.10.100/24]
            gateway4: 192.168.10.1
            nameservers:
              addresses: [192.168.10.1]
        version: 2
      
    • doas netplan apply # Apply the changes
  • Notes
    • enp2s0 # Replace it with your interface name
      • ip address # Get it
    • 192.168.10.100 # Replace it with your desired IP address
    • 192.168.10.1
      • ip route # Get the gateway
    • Because to use SSH.
    • Solve the problem
      yaoniplan@ubuntu2204:~$ ssh-copy-id yaoniplan@192.168.10.105
      /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/yaoniplan/.ssh/id_rsa.pub"
      /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
      
      /usr/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
      ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
      ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
      ERROR: It is also possible that a host key has just been changed.
      ERROR: The fingerprint for the ED25519 key sent by the remote host is
      ERROR: SHA256:nHN0tokxVW4e5DV4Irvf7EM6dAWRbX/LHPzir2DDxsk.
      ERROR: Please contact your system administrator.
      ERROR: Add correct host key in /home/yaoniplan/.ssh/known_hosts to get rid of this message.
      ERROR: Offending ECDSA key in /home/yaoniplan/.ssh/known_hosts:10
      ERROR:   remove with:
      ERROR:   ssh-keygen -f "/home/yaoniplan/.ssh/known_hosts" -R "192.168.10.105"
      ERROR: Host key for 192.168.10.105 has changed and you have requested strict checking.
      ERROR: Host key verification failed.
      
      • ssh-keygen -f "/home/yaoniplan/.ssh/known_hosts" -R "192.168.10.105"
      • -f # Filename
      • -R # Remove
      • 192.168.10.105 # Replace it with your error (e.g. [192.168.10.105]:60022)
  • References
    • ChatGPT

  • The abbreviation of "Dots per inch" is "DPI".

    • A measure
  • References
    • https://en.wikipedia.org/wiki/Dots_per_inch

  • Set DPI in Chromium

    • chromium --force-device-scale-factor=1.5
  • Notes
    • 1.5 # Replace it with float number (e.g. 1.2)
    • In Gentoo Linux
      • doas vim /etc/chromium/default
        CHROMIUM_FLAGS="--force-device-scale-factor=1.2"
        
    • Because be convenient to read the text.
  • References
    • https://wiki.gentoo.org/wiki/Chromium#HiDPI

  • Add API keys to Chromium

    • Join two groups
      • https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-dev
      • https://groups.google.com/u/1/a/chromium.org/g/google-browser-signin-testaccounts
    • New a project in "NEW PROJECT"
      • Open https://cloud.google.com/console
      • Click "OAuth consent screen" in "APIs & Services"
      • Select "External" in "User type"
      • Add your email account in "Test users"
    • Add some APIs in "Library"
      • Cloud Search API
      • Google Drive API
      • Safe Browsing API
      • Time Zone API
      • Admin SDK API
      • Chrome Sync API
      • Chrome Web Store API
      • Chrome Spelling API
    • Create credentials in "Credentials"
      • API key
      • Select "Desktop app" for "Application type" in "OAuth client ID"
    • vim ~/.bash_profile
      export GOOGLE_API_KEY="AIzaSyBu8FIIyAg8tgViMLBcbqthjvQdutsvOSY"
      export GOOGLE_DEFAULT_CLIENT_ID="696256159994-krng5vgpj2p2f9neqrn46j58q201b0j0.apps.googleusercontent.com"
      export GOOGLE_DEFAULT_CLIENT_SECRET="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"
      
      • Replace them with yours
  • Notes
    • Because to use sync feature
    • about:version # View the flags of "Command Line"
  • References
    • 2023-03-10_11:12:24.gif
    • https://nyac.at/posts/google-sync-in-chromium
    • https://www.chromium.org/developers/how-tos/api-keys/
    • https://gitweb.gentoo.org/repo/gentoo.git/tree/www-client/chromium/chromium-109.0.5414.74-r1.ebuild#n835

  • Run extensions on chrome:// URLs

    • doas vim /etc/chromium/default
      CHROMIUM_FLAGS="--extensions-on-chrome-urls"
      
  • Notes
    • Warning: Stability and security will suffer.
      • Not supported on "view-source:" pages.
    • Because to run a extension named Vimium C
      • Run on chrome://*/* pages
      • Run on Chrome's native New Tab Page
  • References
    • https://github.com/gdh1995/vimium-c/issues/444#issuecomment-926447451

  • The abbreviation of "Short Message Service" is "SMS".

    • A service component
  • References
    • https://en.wikipedia.org/wiki/SMS

  • The abbreviation of "United States of America" is "USA".

    • A country
    • In North America
  • References
    • https://en.wikipedia.org/wiki/United_States

  • Delete a user account in Gentoo Linux

    • doas userdel -r toshiba
  • Notes
    • -r # Remove
    • toshiba # A user name

  • Act as a spoken English teacher in ChatGPT

    I want you to act as a spoken English teacher and improver. I will speak to you in English and you will reply to me in English to practice my spoken English. I want you to keep your reply neat, limiting the reply to 100 words. I want you to strictly correct my grammar mistakes, typos, and factual errors. I want you to ask me a question in your reply. Now let's start practicing, you could ask me a question first. Remember, I want you to strictly correct my grammar mistakes, typos, and factual errors.
    
  • Notes
    • Type your sentence in English
    • Another way
      • Grammar check. Make it more professional. Who is John von Neumann, and what is his identity?
  • References
    • https://github.com/f/awesome-chatgpt-prompts

  • The abbreviation of "virtual private network" is "VPN".

    • A mechanism
  • References
    • https://en.wikipedia.org/wiki/Virtual_private_network

  • Redirect URL form "cn.bing.com" to "www.bing.com"

    • vim headerEditorConfig.json
      {
          "request": [
              {
                  "enable": true,
                  "name": "bing-cn-to-www",
                  "ruleType": "redirect",
                  "matchType": "prefix",
                  "pattern": "https://cn.bing.com",
                  "exclude": "",
                  "group": "bing-redirect",
                  "isFunction": false,
                  "action": "redirect",
                  "to": "https://www.bing.com"
              }
          ],
          "sendHeader": [
              {
                  "enable": true,
                  "name": "bing",
                  "ruleType": "modifySendHeader",
                  "matchType": "regexp",
                  "pattern": "^http(s?)://www\\.bing\\.com/(.*)",
                  "exclude": "",
                  "group": "bing-direct",
                  "isFunction": false,
                  "action": {
                      "name": "x-forwarded-for",
                      "value": "8.8.8.8"
                  }
              }
          ],
          "receiveHeader": [],
          "receiveBody": []
      }
      
  • Notes
    • Warning: It does not work on February 10, 2024.
    • Install the web browser extension named "Header Editor"
  • References
    • https://web.archive.org/web/20230305023028/https://webcache.googleusercontent.com/search?q=cache:1b6OzRW_AoAJ:https://www.chongbuluo.com/thread-15049-1-1.html&cd=5&hl=en&ct=clnk&gl=hk
    • https://web.archive.org/web/20230608085940/https://www.v2ex.com/t/914329

  • Submit a website to archive.org

    • Find the "Save Page Now" in "WEB"
    • Paste URL of the website you want to archive
  • Notes
    • Because for future reference.

  • Set full screen in Chromium

    • Click the three vertical dots
    • Click the full screen mode icon
  • Notes
    • Click the "X" button # Exit the full screen mode
    • Another way
      • Fn-11 # Press it
  • References
    • https://www.businessinsider.com/guides/tech/how-to-full-screen-google-chrome

  • Close the download bar in Chromium

    • Ctrl-j # Open "Downloads" tab
    • Ctrl-w # Close it
  • References
    • https://superuser.com/questions/111675/google-chrome-auto-close-download-bar/287463#287463

  • Trying to build a blog (2023-03-04)

    • No comment system
    • Markdowm # Simple
    • Searchable
    • Waterfalls flow
  • References
    • https://blog.est.im/

  • Compress a directory in Unix-like

    • tar -cf getUsername.tar getUsername/
    • gzip getUsername.tar
  • Notes
    • -c # Create
    • -f # File
    • getUsername/ # Replace it with your desired compressed directory
    • If you want higher compression.
      • gzip # Replace it with xz
  • References
    • man tar
    • 2023-04-16_13-29.png

  • Use "firefox"

    • Disable HTTPS-Only Mode
      • about:config
        dom.security.https_only_mode
        
      • Toggle it from "true" to "false"
      • Restart to make it effective
    • Increase the video buffer before palyback (Make playback more stable when using Wi-Fi)
      • about:config
        media.cache_readahead_limit
        media.cache_resume_threshold
        
      • Set them to a higher value (e.g. 9999)
    • Disable showing message (Make Firefox your default browser)
      • about:config
        browser.shell.checkDefaultBrowser
        
      • Toggle it from "true" to "false"
    • Disable smooth scrolling
      • about:config
        general.smoothScroll
        
      • Toggle it from "true" to "false"
    • Restore previous tabs by default on startup
      • about:support # /version
      • media.ffmpeg.vaapi.enabled # Set to true to enable hardware decoding
      • Open previous windows and tabs
  • Notes
    • Because to customize the browser to make it more efficient.
  • References
    • about:config # /vaapi
    • https://www.mail.com/blog/posts/how-to-restore-tabs/124/#Restore%20browsing%20session%20and%20tabs%20in%20Firefox
    • about:preferences # In 'Startup' of 'General'
    • Artificial intelligence

  • Set dark mode in Firefox

    • about:config
      ui.systemUsesDarkTheme
      
    • Select "Number", click plus button, and write down "1"
  • Notes
    • Warning: It does not work in 2023-04-08.
  • References
    • https://github.com/m-khvoinitsky/dark-background-light-text-extension # Install the extension
    • https://userstyles.org/styles/158321/global-dark-style-everything-to-dark-2018
    • https://userstyles.org/styles/31267/global-dark-style-changes-everything-to-dark # It works, but override all default themes
    • https://www.askvg.com/tip-force-mozilla-firefox-to-always-use-dark-or-light-theme-mode/

  • Solve a problem about Qutebrowser

    • export XDG_RUNTIME_DIR="/tmp/runtime-yaoniplan"
    • export RUNLEVEL=3
  • References
    • The problem
      09:01:48 WARNING: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-yaoniplan'
      
    • https://stackoverflow.com/questions/59790350/qstandardpaths-xdg-runtime-dir-not-set-defaulting-to-tmp-runtime-aadithyasb/59843603#59843603

  • Use "vimium c"

    • Don't let pages steal the focus in loading # Enable in 'Miscellaneous options'
    • p # Search selected words in search engine when in visual mode
    • map <f6> copyWindowInfo type="tab" format="${title}" # Copy page title
    • yi # Copy image to the clipboard
    • 2gu # Go up the URL hierarchy twice
      • From an issue to a code area on GitHub
    • ^ # Previous tab
    • gf # Go to the next frame
    • map <c-m> toggleMuteTab # Ctrl-m
    • yv # Ctrl-f and v or V
      • y # Yank
      • v # Visual
    • W # Move current tab to next window
  • Notes
    • Copy an image's address in 'Custom key mappings'
      map yI LinkHints.activateOpenImage sed="s@^@vimium://copy/@g"
      
      • If failed to copy image to the clipboard
    • Add a search engine in 'Custom search engines'
      tr: https://translate.google.com/?sl=auto&tl=en&text=%s
      pp: https://www.perplexity.ai/search?q=%s blank=https://www.perplexity.ai
      
      • & # A separator (Between parameters)
      • pp # An alias (Customizable)
      • search # Search functionality
      • ? # A separator (Between the base URL and the query parameters)
      • q= # A query parameter
      • %s # A placeholder (Vimium C will replace it with your search query)
      • blank=https://www.perplexity.ai # If the search query is empty then open it (Optional)
  • References
    • https://github.com/gdh1995/vimium-c/issues/1220#issuecomment-2422200245
    • https://airespo.com/resources/how-to-set-perplexity-ai-as-default-search-engine-in-chrome/ # /perplexity.ai
    • https://github.com/gdh1995/vimium-c/discussions/938
    • https://github.com/gdh1995/vimium-c/issues/1133#issuecomment-2125555652
    • https://github.com/gdh1995/vimium-c/issues/289#issue-811171738
    • https://github.com/gdh1995/vimium-c/issues/842#issuecomment-1426803034
    • https://github.com/gdh1995/vimium-c/discussions/794#discussion-4551520
    • ? # /image

  • Use Vimium C for hint

    • Custom key mappings as needed
      unmap F
      map gr LinkHints.activate button="right" # Right click
      
      env text host= "http://192.168.10.100:5244/" || "https://abnormalize.icu/"
      env telegramImages host="https://web.telegram.org/z/"
      
      run f lh expect="text:lh1,telegramImages:lh2"
      run <v-lh1> lh clickable=".hope-text"
      run <v-lh2> lh clickable=".thumbnail"
      map <v-lh> LinkHints.activate
      
  • Notes
    • text # Replace it with other name you like
    • http://192.168.10.100:5244/ # Replace it with URL
    • .hope-text # Replace it with other CSS elements
      • Ctrl-Shift-c # In Chromium
      • Then hover your mouse to where you want to click # Get it
    • Ctrl-y # The same as Ctrl-r in Vim
  • References
    • https://github.com/gdh1995/vimium-c/issues/386#issuecomment-912952613
    • https://github.com/gdh1995/vimium-c/issues/624#issuecomment-1117473544
    • https://github.com/gdh1995/vimium-c/wiki/Map-a-key-to-different-commands-on-different-websites
    • https://github.com/gdh1995/vimium-c/issues/602#issuecomment-1094111805
    • https://github.com/gdh1995/vimium-c/issues/869#issuecomment-1435837660

  • Use Vimium C for color of hint

    • Custom CSS for Vimium C UI
      .LH, .D>.LH { background: black; font-weight: bold; font-size: 15px; color: white;}
      .LH { border: /*!DPI*/ 0px solid lightgreen; }
      
  • References
    • https://github.com/gdh1995/vimium-c/wiki/Style-the-UI-of-Vimium-C-using-Custom-CSS

  • Find a Linux distribution suitable for use as a server

    • Arch Linux (2023-06-19)
    • Ubuntu Server 22.04 (2023-02-28)
  • Notes
    • Needs
      • Docker

  • Set static IP address in Gentoo Linux

    • doas vim /etc/conf.d/net.eno1
      config_eno1="192.168.10.105/24"
      routes_eno1="default via 192.168.10.1"
      dns_servers_eno1="192.168.10.1"
      
    • ln -s /etc/init.d/net.lo /etc/init.d/net.eno1 # Create symlinks
    • doas /etc/init.d/net.eno1 restart # Restart the interface
    • rc-update add net.eno1 default # Enable at boot
  • Notes
    • eno1 # Replace it with interface name
      • ifconfig # Get interface name
    • 192.168.10.105 # Replace it with static IP address
      • May need to test to see if the IP address in already in use.
    • 192.168.10.1 # Replace it with gateway
      • netstat -rn # Get gateway
    • Because to use SSH
  • References
    • https://wiki.gentoo.org/wiki/Netifrc

  • Create a user in Gentoo Linux

    • useradd -m -G users,wheel,audio -s /bin/bash testUser
    • passwd testUser
  • Notes
    • -G # Groups
    • -s # Shell
    • testUser # Replace it with user name
  • References
    • man useradd
    • https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Finalizing#Adding_a_user_for_daily_use

  • Solve a problem about SSH

    • vim /etc/ssh/sshd_config
      #PasswordAuthentication no
      PasswordAuthentication yes
      
    • rc-service sshd restart # Make changes effective
  • References
    • The problem
      Failed init storage: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
      
    • https://stackoverflow.com/questions/47102080/ssh-in-go-unable-to-authenticate-attempted-methods-none-no-supported-method/47144076#47144076

  • Install Ubuntu Server 22.04

    • Follow steps of the website
      • Install OpenSSH server
  • Notes
    • doas vim /etc/apt/sources.list # Change mirrors
      • Replace http://security.ubuntu.com with https://mirrors.ustc.edu.cn
  • References
    • https://mirrors.ustc.edu.cn/help/ubuntu.html

  • Disable the new code search and code view in GitHub

    • Feature preview
    • New code search and code view
  • Notes
    • Because can't use Vimium's feature
  • References
    • https://docs.github.com/en/repositories/working-with-files/managing-files/navigating-files-with-the-new-code-view

  • Use Surfingkeys

    • zr # Zoom reset
    • zi # Zoom in
    • w Switch frames
    • gU # Go URL of root
    • gx$ # Close tabs on right
    • og # Open Google
    • Learn JavaScript
    • ;e # Open settings
    • Alt-s # Turn off Surfingkeys
    • W # Windows
    • ;gw # Gather windows
  • Notes
    • Surfingkeys.js
      api.map('<Ctrl-[>', '<Esc>'); // Map a key to another
      api.unmap('F'); // Unmap the F key
      api.Hints.setCharacters('sadfjklewcmpgh'); // Like Vimium
      settings.hintAlign = "left"; // Set left alignment
      settings.smoothScroll = false; // Disable smooth scroll
      api.Hints.style(" \
          font-family: Roboto, sans serif; \ // Set font
          font-size: 15px; \ // Set font size
          color: #ffffff; \ // Set font color
          border: unset; \ // Disable border
          background: #000000; \ // Set background color
      ");
      
    • May I need
      • Call search bar
      • Right click
      • Bookmarks and a file
    • The extension will make your browser use a lot of CPU resources.
      • Maybe mining
  • References
    • https://github.com/brookhong/Surfingkeys/issues/166#issuecomment-270044552
    • https://github.com/brookhong/Surfingkeys/blob/master/docs/API.md
    • https://gist.github.com/coramuirgen/94ba1d587cb2093c71f6ef4f0b371069
    • https://gitlab-com.translate.goog/-/snippets/1985201?_x_tr_sl=auto&_x_tr_tl=zh-CN&_x_tr_hl=en-US
    • https://github.com/brookhong/Surfingkeys#follow-links

  • Solve a problem about Linux-firmware in Gentoo Linux

    • doas vim /etc/portage/package.license
      # Accepting the license for linux-firmware
      sys-kernel/linux-firmware linux-fw-redistributable
      
      # Accepting any license that permits redistribution
      sys-kernel/linux-firmware @BINARY-REDISTRIBUTABLE
      
  • References
    • The problem
      - sys-kernel/linux-firmware-99999999::gentoo (masked by: || ( ) linux-fw-redistributable license(s), missing keyword)
      - A copy of the 'linux-fw-redistributable' license is located at '/var/db/repos/gentoo/licenses/linux-fw-redistributable'.
      
    • https://wiki.gentoo.org/wiki//etc/portage/package.license

  • Use "alist"

    • S3
      /r2 # Mount Path
      products # Bucket
      https://<ACCOUNT_ID>.r2.cloudflarestorage.com # Endpoint
      auto # Region
      yourAccessKeyId # Access key id
      yourSecretAccessKey # Secret access key
      yourCustomDomainConnectedToYourBucket # Custom host
      
    • AList V3
      /websiteName # Mount Path
      / # Root folder path (All or a specific folder)
      /websiteURL # Url
      
    • SFTP
      /grow # Mount Path
      Name # Order by
      Descending # Order direction
      192.168.10.100:22 # Address
      yaoniplan # Username
      ****** # Password
      /mnt/grow # Root folder path
      
    • AliyundriveOpen
      / # Mount Path
      useYourPhoneToGet # Refresh token
      Name # Order by
      Ascending # Order direction
      
  • Notes
    • Get token
      curl --request POST 'http://192.168.10.100:5244/api/auth/login' \
          --header 'Content-Type: application/json' \
          --data-raw '{
              "username":"guest",
              "password":"guest"
          }'
      
      • https://github.com/alist-org/alist/discussions/2061#discussioncomment-8717854
      • https://alist.nn.ci/guide/api/auth.html#post-token获取
    • Get file name list
      curl --request POST 'http://192.168.10.100:5244/api/fs/list' \
          --header 'Authorization: yourAlistToken' \
          --header 'Content-Type: application/json' \
          --data-raw '{
              "path": "/interestAndHobby/music",
              "password": "***",
              "page": 1,
              "per_page": 0,
              "refresh": false
          }'
      
      • https://github.com/alist-org/alist/issues/5836
      • https://alist.nn.ci/guide/api/fs.html#post-列出文件目录
    • curl --user admin:*** --upload-file ~/Downloads/trash/wall_anime2_8K.png http://192.168.10.100:5244/dav/189/2024/03/26/ # Send a file using curl if no rclone
      • PUT # Method
      • Authorization Basic username:password # Headers
      • File Shortcut Input # Request Body
      • https://libreddit.baczek.me/r/workflow/comments/5t2ac1/request_webdav_action/
      • https://jiajunhuang.com/articles/2023_11_29-alist_webdav.md.html # Use "davfs2" if no rclone
    • Install AList if you don't have it
      • vi ~/.config/alist/docker-compose.yml
        version: '3.3'
        services:
          alist:
            restart: always
            volumes:
              - '~/.config/alist:/opt/alist/data'
            ports:
              - '5244:5244'
              - '5245:5245'
            environment:
              - PUID=0
              - PGID=0
              - UMASK=022
              - TZ=UTC
            container_name: alist
            image: 'xhofe/alist:latest'
        
      • docker-compose up --detach # Run in the background
      • docker exec -i -t alist ./alist admin # Get admin user's information
    • Refresh pages (Two methods)
      • Click "Refresh" icon
      • Close the website and then open it
    • View pictures of relative paths in Markdown
      • Follow steps of the comment
    • Add README.md (Two methods)
      • Upload README.md
      • Add Markdown content to "Readme" in "Metas"
    • Replace logo and favicon
      • Upload images
      • Copy link
      • Paste it to "Logo" and "Favicon" in style settings
    • Open in external application
      • In "External previews" of Preview of Settings
        {
          "wma,m4a": {
            "VLC": "vlc://$url"
          }
        }
        
    • Solve the problem
      Failed init storage: failed to refresh token: Too Many Requests
      
      • Warning: There are limits (10 requests within 60 minutes) on the AList API, unless you use the API you applied for yourself. (Or use other drivers)
      • https://github.com/alist-org/alist/discussions/2697#discussion-4656809
      • Follow the above URL to add a cloudflare worker and a custom domain
      • Enable 'Web Proxy'
      • Enable 'use proxy URL' in 'WebDAV policy'
      • https://al.yaoniplan.eu.org # In 'Download proxy URL' (your custom domain)
  • References
    • https://github.com/alist-org/alist/issues/6274#issuecomment-2022708773
    • https://github.com/alist-org/alist/discussions/2061#discussioncomment-6538007
    • https://github.com/alist-org/alist/issues/4828#issuecomment-1646579013
    • https://alist.nn.ci/guide/drivers/Alist%20V2%20V3.html#root-directory-path
    • https://github.com/alist-org/alist/blob/main/docker-compose.yml
    • https://github.com/alist-org/alist/issues/4160#issuecomment-1509490562
    • https://github.com/alist-org/alist/issues/829#issuecomment-1080066329
    • https://github.com/alist-org/alist/issues/2668#issuecomment-1345132515
    • https://github.com/alist-org/alist/issues/2668#issuecomment-1345480664
    • https://alist.nn.ci/guide/drivers/aliyundrive_open.html
    • https://alist.nn.ci/guide/drivers/sfpt.html
    • https://github.com/alist-org/alist/issues/2267

  • Use "shasum" to verify the checksum in Unix-like

    • shasum -a 256 ubuntu-22.04.2-live-server-amd64.iso
  • Notes
    • -a # Algorithm
    • 256 # Replace it with other algorithm (e.g. 512)
  • References
    • man shasum
    • 2023-02-26_11:59:36.png
    • https://ubuntu.com/download/server

  • Understand "Statue of Liberty"

    • A statue
    • In the United States
  • References
    • https://en.wikipedia.org/wiki/The_Legend_of_1900
    • https://en.wikipedia.org/wiki/Statue_of_Liberty

  • Keep the sshd active when closing the laptop lid

    • sudo vim /etc/systemd/logind.conf
      #HandleLidSwitch=suspend
      HandleLidSwitch=ignore
      
    • sudo reboot # Make changes effective
  • Notes
    • Solve the problem
      yaoniplan@tux ~ $ ssh root@192.168.10.100
      ssh: connect to host 192.168.10.100 port 22: No route to host
      
  • References
    • https://askubuntu.com/questions/113824/how-to-keep-ssh-server-running-with-laptop-lid-closed/1371882#1371882

  • Use "docker"

    • Try to follow the Docker Compose specification
      • compose.yaml # Replace docker-compose.yml
      • docker compose # Replace docker-compose
      • Delete the first line containing 'version' to remove obsolete warning
      • Because to make Docker simpler.
    • doas vi /etc/systemd/system/docker.service.d/proxy.conf # Set a proxy if mirror fails
      [Service]
      Environment="HTTP_PROXY=http://192.168.10.100:7890"
      Environment="HTTPS_PROXY=http://192.168.10.100:7890"
      
      • http://192.168.10.100:7890 # Replace it with your proxy
      • doas systemctl daemon-reload && doas systemctl restart docker # Make changes effective
      • docker info # Check the information about 'HTTP Proxy' or 'HTTPS Proxy'
    • doas vi /etc/docker/daemon.json # Set a mirror
      {
        "registry-mirrors": ["https://docker.nju.edu.cn/"]
      }
      
      • https://docker.nju.edu.cn/ # Replace it with a registry mirror in your country
      • doas systemctl restart docker # Restart docker to apply changes
      • docker info # Check the information about 'Registry Mirrors'
      • https://blog.lty520.faith/%E5%8D%9A%E6%96%87/%E8%87%AA%E5%BB%BAdocker-hub%E5%8A%A0%E9%80%9F%E9%95%9C%E5%83%8F/#%E6%96%B9%E6%A1%88%E4%BA%8C%E4%BD%BF%E7%94%A8-cloudflare-worker-%E6%90%AD%E5%BB%BA # Another way using your own registry mirror
    • docker exec --interactive --tty diary sh # Interact with container
    • docker cp 11a6a5e253d7:/app /tmp/tmp.fWaKJndURz/ # Copy source code
      • 11a6a5e253d7 # Container ID (Or note: NAMES)
      • /app # Working directory
      • /tmp/tmp.fWaKJndURz # Destination directory
    • docker run --interactive --tty yaoniplan/diary sh # View source code
    • docker images nginx # Check the size of an image
    • docker logs searxng # The same as docker-compose logs
    • docker container prune # Prune stopped containers
    • docker ps --format "{{.ID}} {{.Ports}}" # To write a conditional judgement
    • docker stop a3a15b7a4419 && docker rm a3a15b7a4419 # Stop and remove a container
      • docker ps --all # Get "CONTAINER ID"
    • docker rmi a3adcb495939 # Remove an image
      • docker images # Get "IMAGE ID"
    • docker search clash # Search to get the full name
  • Notes
    • Because to improve the speed of downloading Docker images.
    • docker login # Solve a problem about 'net/http: TLS handshake timeout'
    • Disable proxy
      • Delete proxy configurations (e.g. /etc/docker/daemon.json, ~/.docker/config.json)
      • Rebuild container (e.g. docker-compose down && docker-compose up --detach)
    • Reduce the size of a Docker image
      • vi ~/note/.dockerignore # Exclude during the build process
        .git
        
    • Push Docker image to Docker Hub
      • docker build --tag yaoniplan/note:latest ~/note/ # In path including Dockerfile
      • docker tag yaoniplan/note:latest yaoniplan/note:$(date +%F) # Create a tag
      • docker push yaoniplan/note:latest # Push the latest-tagged image
      • docker push yaoniplan/note:$(date +%F) # Push the date-tagged image
    • Install dependencies in Ubuntu Server 22.04
      • Follow the steps of this website
      • doas usermod --append --groups docker $(whoami) # Run the command without password
      • doas reboot # Make the changes effective
    • Install dependencies in Arch Linux
      doas pacman --sync docker # Install dependencies
      doas systemctl enable docker --now # Enable now
      doas gpasswd --add $(whoami) docker # Add user to Docker group
      
      • Log out and log back to make changes effective
  • References
    • https://docs.docker.com/compose/compose-application-model/
    • https://dev.to/pradumnasaraf/stop-versioning-your-docker-compose-file-1f41
    • https://www.zdnet.com/article/docker-101-how-to-install-docker-on-ubuntu-server-22-04/
    • https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6?permalink_comment_id=5083215#gistcomment-5083215
    • https://sci.nju.edu.cn/9e/05/c30384a564741/page.htm
    • man usermod # /^ *-a /^ *-G
    • man docker
    • Google # registry mirrors site:edu.cn
    • ChatGPT

  • Search for selected text in Vim

    • / # Search mode
    • C-r # Register
    • " # The default register
  • Notes
    • y # Yank text to the " register before entering search mode
      • yl
    • Because to search languages in other countries (e.g. Japanese).
  • References
    • https://superuser.com/questions/41378/how-to-search-for-selected-text-in-vim

  • The abbreviation of "continuous integration" / "continuous deployment" is "CI" / "CD"

    • Automation
  • References
    • https://web.archive.org/web/20221127112602/https://nn.ci/posts/github-actions.html
    • https://en.wikipedia.org/wiki/CI/CD

  • The abbreviation of "Pretty Good Privacy" is "PGP".

    • A program
    • To encrypt
  • References
    • https://en.wikipedia.org/wiki/Pretty_Good_Privacy

  • Copy files excluding hidden files in Unix-like

    • rsync -av --exclude=".*" ../learnPerl/ .
  • Notes
    • ../learnPerl/ # The source
    • . # The destination
  • References
    • man rsync
    • https://stackoverflow.com/questions/11557114/cp-r-without-hidden-files/11557219#11557219

  • Rename the branch from "main" to "master" in Git

    • git branch --move main master
    • git push origin --set-upstream master
  • Notes
    • git branch --all # List all branches
    • git push origin --delete main # Delete the main remote branch
    • git branch --delete main # Delete the main local branch
    • Because the default branch is master in Git
    • Toggle the default branch of settings of a GitHub repository to master to solve the problem
      yaoniplan@tux /tmp/note $ git push origin --delete main
      To github.com:yaoniplan/note.git
       ! [remote rejected] main (refusing to delete the current branch: refs/heads/main)
      error: failed to push some refs to 'github.com:y
      aoniplan/note.git'
      
  • References
    • git branch --help
    • git push --help
    • https://linuxize.com/post/how-to-rename-local-and-remote-git-branch/
    • https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch/6591218#6591218

  • Complete brackets and quotes automatically in Vim

    • vim ~/.vimrc
      inoremap ( ()<Left>
      inoremap ``` ```<CR>```<Up>
      
  • Notes
    • ( () # Replace it with others (e.g. [ [], { {}, < <>, ' '', " "")
    • <Left> # The left arrow key
    • Warning: Not recommended because it will conflict with replication.
  • References
    • :help <CR>
    • :help <Left>
    • Add a demo.gif here
    • https://www.reddit.com/r/vim/comments/949jmp/comment/e3jaotv/?utm_source=share&utm_medium=web2x&context=3

  • Execute Markdown code blocks in Vim

    • :MarkdownRunner
  • Notes
    • vim ~/.vimrc # Install it if you don't have it
      # Lists of plugins
      Plug 'dbridges/vim-markdown-runner'
      
    • :w # Write
    • :source ~/.vimrc # Reload the ~/.vimrc
    • :PlugInstall # Install
    • Another way
      • w !perl # Replace perl with your language
      • Visually select the code and :'<'>w !perl
  • References
    • markdown-runner.gif
    • https://www.reddit.com/r/vim/comments/u7gx5p/how_to_execute_a_piece_of_code_in_a_markdown_file/
    • https://github.com/dbridges/vim-markdown-runner

  • Use "curl"

    • '"$filePath"' # Enclose in single quotes to make variable effective
      ...
          --data-raw '{
              "path": "'"$filePath"'",
      ...
      
    • curl --remote-name https://mirrors.ustc.edu.cn/archlinux/extra/os/x86_64/extra.db # Download a file
    • curl --verbose yaoniplan.eu.org
  • Notes
    • curl --user yourPersonalAccessToken: https://api.github.com/repos/philj56/tofi # Solve the problem
      {"message":"API rate limit exceeded for 18.182.47.148. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}
      
      • yourPersonalAccessToken # Replace it with your personal access token
      • curl --include https://api.github.com/rate_limit # Check the rate limit information (e.g. limit: 60 requests per hour)
    • --max-time 10 # Stop the curl command after 10 seconds
    • --silent # Do not show progress meter
  • References
    • man curl # /^ *-s /^ *-O
    • ChatGPT

  • Understand Esperanto

    • A language
    • To assist in the international
  • References
    • https://en.wikipedia.org/wiki/Esperanto

  • The abbreviation of "Text To Speech" is "tts".

  • References
    • https://ms-ra-forwarder-lake-tau.vercel.app/ (Or https://tts.femoon.top/cn)
    • https://en.wikipedia.org/wiki/Speech_synthesis

  • Solve a problem about Let's Encrypt

    • certbot certonly --cert-name yaoniplan.eu.org -d yaoniplan.eu.org,www.yaoniplan.eu.org
  • Notes
    • Remove spaces between the domain names
    • Separate them with a comma
  • References
    • Question
      Requested domain  is not a FQDN because it contains an empty label.
      
    • https://github.com/certbot/certbot/issues/2916#issuecomment-374372893

  • Install Nginx server in FreeBSD

    • pkg install nginx
  • Notes
    • vim /etc/rc.conf
      nginx_enable="YES"
      
    • nginx -t # Test the configuration file
  • References
    • man nginx
    • https://samirparikh.com/blog/share-your-git-repositories-with-stagit-on-freebsd.html

  • Some configuration files about network in FreeBSD

    • /etc/resolv.conf
    • /etc/hosts

  • Use Stagit in FreeBSD

    1. Prepare remote Git repositories
      • vim /var/git/learnPerl/description # Add description of the repository
      • vim /var/git/learnPerl/owner # Add owner's name
      • vim /var/git/learnPerl/url # Add clone URL
    2. Install Nginx and Stagit dependency
    3. Prepare remote Git repositories for Stagit
    4. Install Stagit
  • Notes
    • I don't need it on February 21, 2023.
      • Just need a simple Git server using SSH
  • References
    • 2023-02-21_10:53:43.gif
    • https://samirparikh.com/blog/share-your-git-repositories-with-stagit-on-freebsd.html

  • The authorized_keys is

    • Sum of ~/.ssh/id_rsa.pub
  • Notes
    • scp /home/yaoniplan/.ssh/id_rsa.pub root@192.168.10.100:/tmp/id_rsa.yaoniplan.pub # In client
      • Copy public key file of client to remote
    • cat /tmp/id_rsa.yaoniplan.pub >> /home/git/.ssh/authorized_keys # In remote
      • Append public key to authorized_keys
  • References
    • Add a demo.gif here

  • Where is the repository in Git server

    • /var/git/
  • References
    • https://wiki.gentoo.org/wiki/Git#Server
    • https://serverfault.com/questions/432959/wheres-the-conventional-place-to-store-git-repositories-in-a-linux-file-system/432970#432970

  • Kill a process in the dmenu

    • pkill timer # It may kill timerOfTomato.sh
  • Notes
    • timerOfTomato.sh # A script
    • --full # Full process name
  • References
    • Add a demo.gif here

  • Display pressed key on screen in Unix-like

    • screenkey # Run it
      • pkg install screenkey # In FreeBSD
      • emerge x11-misc/screenkey # In Gentoo Linux
  • Notes
    • Pop up on the side. # I may need

  • Display public IP address

    • links ip4.me
    • curl -4 ifconfig.co

  • The abbreviation of "Domain Name System" is "DNS".

    • A system
  • References
    • https://en.wikipedia.org/wiki/Domain_Name_System

  • Remove packages in FreeBSD

    • pkg remove mysql57-client
  • Notes
    • pkg info | grep mysql # Search the package before removing
    • rm -rf /var/db/mysql/
  • References
    • https://www.cyberciti.biz/faq/how-to-install-mariadb-databases-on-a-freebsd-v10-unix-server/

  • Install Apache server in FreeBSD

    • pkg install www/apache24
    • echo 'apache24_enable="YES"' >> /etc/rc.conf
    • /usr/local/etc/rc.d/apache24 start
  • Notes
    • /usr/local/etc/rc.d/apache24 start # Replace it with service apache24 start
    • Solve the problem
      (48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
      no listening sockets available, shutting down
      
      • lsof -i :80
      • kill youPID
  • References
    • https://www.cyberciti.biz/faq/how-to-install-apache-mysql-php-stack-on-freebsd-unix-server/
    • https://www.cyberciti.biz/faq/freebsd-apache-web-server-tutorial/

  • Install MariaDB server in FreeBSD

    • pkg install mariadb103-server
    • sysrc mysql_enable=YES # Set MariaDB to start at boot time
    • service mysql-server start # Start MariaDB
  • Notes
    • pkg search mariadb | grep server # Search it before installing
    • mysql -u root -p mysql # Login as root user
  • References
    • https://wiki.freebsd.org/MariaDB
    • https://www.cyberciti.biz/faq/how-to-install-mariadb-databases-on-a-freebsd-v10-unix-server/

  • Install PHP server in FreeBSD

    • pkg install php80
    • cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
    • pkg install vim php80-xml mod_php80 php80-zip php80-mbstring php80-zlib php80-curl php80-mysqli php80-gd php80-gd # Install PHP extensions
  • Notes
    • pkg search php | grep server # Search it before installing
    • php --version # Check the version
  • References
    • https://computingforgeeks.com/how-to-install-php-8-on-freebsd-system/

  • Install Gitea in FreeBSD

    • pkg install gitea
    • sysrc gitea_enable=YES
    • service gitea start
  • Notes
    • /usr/local/etc/gitea # Config files
    • /usr/local/share/gitea # Templates, options, plugins, and themes
    • /usr/local/etc/rc.d/gitea # A start script
  • References
    • https://docs.gitea.io/en-us/install-from-package/

  • The abbreviation of certificate authority is CA

    • Let's Encrypt is a CA.
  • References
    • https://letsencrypt.org/getting-started/
    • https://en.wikipedia.org/wiki/Certificate_authority

  • Use Let's Encrypt in Apache server

    • vim /usr/local/etc/apache24/httpd.conf # Uncomment
      LoadModule ssl_module modules/mod_ssl.so
      Include conf/extra/httpd-ssl.conf
      
  • Notes
    • ``
  • References
    • ``

  • Replace #!/usr/bin/perl with #!/usr/bin/env perl in Unix-like

    • Make the script portable
  • References
    • whereis env
    • https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html

  • The abbreviation of environment is env in Unix-like

  • References
    • man env

  • Delete a user account and home directory in FreeBSD

    • pw userdel git -r
  • Notes
    • pw # Password
    • git # Replace it with your user name
    • -r Remove
  • References
    • man pw
    • https://www.cyberciti.biz/faq/freebsd-remove-user-account-command/

  • The abbreviation of "Portable Document Format" is "PDF".

  • Notes
    • less file.pdf
    • Disadvantages: Font size is small on mobile device
  • References
    • https://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal/41364#41364
    • https://en.wikipedia.org/wiki/PDF

  • Use ZFS to set a snapshot in FreeBSD

    • zfs snapshot -r zroot@testpool # Create a recursive snapshot of an entire pool
    • zfs rollback -r zroot@testpool #
    • zfs list # List
    • zfs snapshot zroot/usr/home@test1-snapshot # Create a snapshot
      • zfs allow heting snapshot zroot/usr/home # Allow an unprivilege user to use snapshot
    • zfs destroy zroot/usr/home@permitTest01 # Destroy a snapshot
      • zfs allow heting destroy,mount zroot/usr/home # Allow an unprivilege user to use destroy and mount
    • zfs list -t snapshot
      • -t # Type
  • References
    • man zfs
    • https://klarasystems.com/articles/basics-of-zfs-snapshot-management/

  • Mount the hard disk permanently in Linux

    • doas vim /etc/fstab
      UUID=f75f68b6-d1b3-4062-9a22-7dbff615efb6   /mnt/grow ext4 defaults       0 0
      
    • doas chown -R yaoniplan:yaoniplan /mnt/grow/
      • Solve the problem about operation not permitted
  • Notes
    • UUID=f75f68b6-d1b3-4062-9a22-7dbff615efb6 # Replace it with your UUID of block device
      • doas blkid # Get it
    • /mnt/grow # Replace it with your mount point
    • ext4 # Replace it with your type of block device
    • yaoniplan # Replace it with your user name
    • Mount all filesystems without rebooting
      • doas mount --all
      • lsblk
  • References
    • man mount
    • man lsblk
    • man chown
    • https://www.howtogeek.com/444814/how-to-write-an-fstab-file-on-linux/

  • Learn Perl 5

    • A programming language
  • References
    • https://en.wikipedia.org/wiki/Perl

  • Check default gateway in Unix-like

    • netstat -rn
  • Notes
    • -r # Route
    • -n # Numeric
  • References
    • man netstat
    • https://www.unixmen.com/how-to-find-default-gateway-in-linux/

  • Check netmask in Unix-like

    • ifconfig | grep netmask
  • Notes
    • 0xffffff00 # The netmask
      • In hexadecimal
  • References
    • man ifconfig
    • Example
      root@heting:~ # ifconfig | grep netmask
              inet 192.168.10.100 netmask 0xffffff00 broadcast 192.168.10.255
              inet 127.0.0.1 netmask 0xff000000
      

  • Set static IP address and DNS in FreeBSD

    • vim /etc/rc.conf
      ifconfig_re0="inet 192.168.10.100 netmask 0xffffff00"
      defaultrouter="192.168.10.1"
      ifconfig_re0="DHCP"
      
    • /etc/rc.d/netif restart && /etc/rc.d/routing restart # Restart the Network
  • Notes
    • re0 # Replace it with your network card name
    • 192.168.10.100 # Replace it with your IP address
    • 0xffffff00 # Replace it with your netmask
    • 192.168.10.1 # Replace it with your default gateway
  • References
    • netstat -rn
    • ifconfig
    • https://ostechnix.com/set-static-ip-address-and-dns-on-freebsd/

  • Create a domain name with "eu.org" (Or "us.kg")

    • GitHub pages
      • A repository named "yaoniplan.github.io"
      • Custom domain to "yaoniplan.eu.org"
    • Cloudflare
      • CNAME, @, yaoniplan.github.io, Proxied, Auto
    • eu.org (Or us.kg)
      • Enter your domain
      • brenna.ns.cloudflare.com # Name Server 1
      • jim.ns.cloudflare.com # Name Server 2
  • Notes
    • Public IP address
      • Visible on the internet instead of on the home network
  • References
    • https://register.us.kg/auth/login
    • https://www.youtube.com/watch?v=PFSLaOGSJCk
    • https://nic.eu.org/
    • https://dash.cloudflare.com/
    • https://www.quora.com/How-do-I-know-whether-an-IP-address-is-public-or-local/
    • https://www.youtube.com/watch?v=In3UZAYiP2c

  • The abbreviation of "Free Berkeley Software Distribution" is "FreeBSD".

  • Notes
    • An operating system
  • References
    • https://en.wikipedia.org/wiki/FreeBSD

  • Use the top command in FreeBSD

    • s # Seconds
    • a # Arguments (Full command)
    • / # Filter
  • Notes
    • In order to pause at some point
  • References
    • h

  • The abbreviation of "manual" is "man" in Unix-like.

    • Find a man if you have problems
  • References
    • man man

  • Use SSH to create a Git server in FreeBSD

    • Remote
      adduser
      su git
      cd
      mkdir .ssh/ && chmod 700 .ssh/
      touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
      cat /tmp/id_rsa.yaoniplan.pub >> ~/.ssh/authorized_keys
      git init --bare /var/git/myFirstFlake.git/
      
    • Client
      git init ~/myFirstFlake/
      echo "# test" >> README.md && git add --all
      git commit -m "Add README.md"
      git remote add origin git@192.168.10.100:/var/git/test.git
      git push origin master
      
  • Notes
    • /tmp/id_rsa.yaoniplan.pub # Replace yaoniplan with your user name
    • Other people on the team
      1. Copy /home/whoseName/.ssh/id_rsa.pub of client to /tmp/id_rsa.whoseName.pub of remote
      2. Append /tmp/id_rsa.whoseName.pub to /home/git/.ssh/authorized_keys in remote
    • git init --bare # Initialize a bare repository
    • chown -R git:git /var/git/ # Change the owner to git after making a directory of repository
  • References
    • git init --help
    • https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
    • https://samirparikh.com/blog/run-simple-git-server-on-freebsd-using-ssh.html

  • Check the system log in Unix-like

    • less /var/log/messages
  • Notes
    • /var/log/ # Most of log files are in this directory

  • Try to use FreeBSD as a remote server. #idea

    • Install it by following steps of this website

  • Stop a service in FreeBSD

    • service syslogd stop
  • Notes
    • syslogd # Replace it with your service

  • The abbreviation of operating system is OS

  • Notes
    • A software
  • References
    • https://en.wikipedia.org/wiki/Operating_system

  • Try to use the script in the dmenu instead of in the terminal. #idea


  • The abbreviation of "Chat Generative Pre-trained Transformer" is "ChatGPT".

  • Notes
    • A bot
    • To chat
  • References
    • https://en.wikipedia.org/wiki/ChatGPT

  • Check the version of the scp command in Unix-like

    • ssh -V
  • Notes
    • -V # Version
    • The relative tools (e.g. ssh, sftp, scp) are parts of the OpenSSH.
  • References
    • man ssh
    • https://unix.stackexchange.com/questions/704740/how-to-get-scp-version/704741#704741

  • Add a user to a group in Linux

    • doas gpasswd -a yaoniplan vboxusers
  • Notes
    • -a # Add
    • yaoniplan # Replace it with your user name
    • vboxusers # Repalce it with your group name
  • References
    • Add a demo.png here
    • man gpasswd

  • Check the host name in Unix-like

    • hostname
  • Notes
    • Other methods
      • echo $HOSTNAME # Check the environment variable
      • cat /etc/hostname # Check the file
  • References
    • https://man.freebsd.org/cgi/man.cgi?hostname(1)
    • man hostname
    • ChatGPT

  • Check the current Shell in Unix-like

    • echo $SHELL
  • Notes
    • Another way
      • cat /etc/passwd | grep bandit26
    • Because to know which Shell syntax to use
  • References
    • https://david-varghese.medium.com/overthewire-bandit-level-25-level-26-35d375ef61e

  • Set a password for a user in Unix-like

    • passwd heting
  • Notes
    • heting # Replace it with your user name

  • Create a user in FreeBSD

    • pw useradd heting
  • Notes
    • adduser # Another way

  • Add a user to multiple groups in FreeBSD

    • pw usermod heting -G wheel,video
  • Notes
    • -G # Grouplist
  • References
    • man pw
    • https://www.cyberciti.biz/faq/freebsd-add-a-user-to-group/

  • Check a installed package information in FreeBSD

    • pkg info | grep git
  • Notes
    • info # Information
    • git # Replace it with a package
  • References
    • man pkg
    • 2023-02-10_09:28:48.png

  • Write a finite loop in Bash

    • for i in {1..10}; do touch file0$i.txt; done
  • Notes
    • i # A variable
  • References
    • 2023-02-10_10:56:53.png
    • https://iq.opengenus.org/for-and-while-loop-in-shell-scripting/

  • Use "kitty"

    • vim ~/.config/kitty/kitty.conf
      # Set cursor shape
      shell_integration no-cursor
      
      # Set fonts
      font_family      Fira Code
      bold_font        auto
      italic_font      auto
      bold_italic_font auto
      
      # Disable audio bell
      enable_audio_bell no
      
      # Set font size
      font_size 12.0
      
  • Notes
    • Warnings: Selection mode needs to be improved. (To search and copy)
      • https://github.com/kovidgoyal/kitty/issues/719
    • kitty tmux # Run a program
    • --class kitty1 # Set window class for rule matching
    • Ctrl-Shift-t # New tab
    • Because for quiet and readability.
  • References
    • https://github.com/kovidgoyal/kitty/issues/4458#issuecomment-1006355953 # Make cursor_shape block work
    • https://www.reddit.com/r/KittyTerminal/comments/m3dnrq/comment/gqpeiii/?utm_source=share&utm_medium=web2x&context=3
    • https://sw.kovidgoyal.net/kitty/conf/#terminal-bell # /fonts
    • man kitty # /tabs$

  • Switch between windows with dmenu

    • Install manually
      git clone https://github.com/NikitaIvanovV/dmenu-win
      cd ./dmenu-win/
      doas make install
      
  • Notes
    • doas make uninstall # Uninstall manually
    • Another way
      • Download https://tools.suckless.org/dmenu/scripts/switch
      • Put it into your PATH (e.g. ~/.local/bin/)
      • chmod u+x ~/.local/bin/switch # Modify user executable permissions for the script
      • Type the switch in your search bar of dmenu
  • References
    • 2023-02-09_10:26:27.gif
    • https://github.com/NikitaIvanovV/dmenu-win

  • Try to use drop down terminal in i3

    • xfce4-terminal --drop-down # It works but quits when not focused
    • tdrop # Not used yet because of too many dependencies
    • qterminal # It works but quits when not focused
    • tilda # It will create a new workspace
    • guake # It works well
    • yakuake # It works well on KDE

  • Delete 2 lines in the upward direction in Vim

    • V2kd
  • Notes
    • V # Visual line mode
    • k # Up
    • d # Delete
    • The above method will delete the current line
  • References
    • 2023-02-20_14:35:30.gif
    • https://stackoverflow.com/questions/6954755/delete-n-lines-in-the-up-direction-in-vim

  • Use sha512sum to verify the checksum

    • sha512sum -c CHECKSUM.SHA512-FreeBSD-13.1-RELEASE-amd64 FreeBSD-13.1-RELEASE-amd64-disc1.iso
  • Notes
    • -c # Check
  • References
    • man sha512sum
    • 2023-02-08_10:54:57.png

  • Drop down terminal in i3

    • vim ~/.config/i3/config
      for_window [class="^kitty$"] floating enable, move absolute position 0px 0px, resize set 1366px 400px, move scratchpad
      
  • Notes
    • 0px 0px # X and Y coordinates
    • 1366px 400px # Width and height
  • References
    • 2023-02-07_18:37:33.gif
    • https://www.reddit.com/r/i3wm/comments/hxhtpc/comment/fz6epw7/?utm_source=share&utm_medium=web2x&context=3
    • https://i3wm.org/docs/userguide.html#move_direction
    • https://i3wm.org/docs/userguide.html#resizingconfig

  • Clear the current line in Vim

    • ^d$
  • Notes
    • ^ # Beginning of line
    • d # Delete
    • $ # End of line

  • Use "scrot"

    • scrot --focused $HOME/$(date +%F_%T).png # Focus a window
    • scrot --select $HOME/"$fileName" # Select a reactangle
  • Notes
    • scrot $HOME/$(date +%F_%T).png # The full screen by default
  • References
    • man scrot
    • https://wiki.archlinux.org/title/Dwm#Taking_screenshots

  • Solve problems about MySQL in Gentoo Linux

    • emerge virtual/mysql
    • emerge --config =dev-db/mysql-8.0.31-r1
  • References
    • Problem 1
       * You don't appear to have a server package installed yet.
       * ERROR: mysql failed to start
      
    • Problem 2
       * You don't appear to have the mysql database installed yet.
       *  * Please run `emerge --config =dev-db/mysql-8.0.31-r1` to have this done...
       *  * ERROR: mysql failed to start
      
    • https://forums.gentoo.org/viewtopic-t-1040120-start-0.html

  • Solve a problem about MySQL in Gentoo Linux

    • GRANT ALL PRIVILEGES ON owncloud.* TO 'yaoniplan'@'localhost';
  • References
    • Problem
      ERROR 1064 (42000): You have an error 
      in your SQL syntax; check the manual 
      that corresponds to your MySQL server 
      version for the right syntax to use near 
      'IDENTIFIED BY 'secure1t'' at line 1
      
    • https://stackoverflow.com/questions/52372165/mysql-error-1064-42000-you-have-an-error-in-your-sql-syntax/71326517#71326517

  • Print unique lines only

    • sort data.txt | uniq -u
  • Notes
    • -u # Unique
  • References
    • man uniq
    • 2023-02-06_19:18:53.png
    • https://mayadevbe.me/posts/overthewire/bandit/level18/
    • https://stackoverflow.com/questions/12782827/how-to-find-the-particular-text-stored-in-the-file-data-txt-and-it-occurs-only/31407466#31407466
    • https://overthewire.org/wargames/bandit/bandit9.html

  • Get the human-readalbe strings

    • strings ./data.txt | grep -E "=+"
  • Notes
    • strings # The same as cat, but printable
    • -E # Extended regular expressions
  • References
    • man grep
    • man strings
    • 2023-02-06_19:49:20.png
    • https://medium.com/@theGirlWhoEncrypts/overthewire-bandit-level-9-level-10-5cf4b38b5bad
    • https://overthewire.org/wargames/bandit/bandit10.html

  • Use base64 to decode

    • echo "b3ViV1lmMmtCcQ==" | base64 --decode
  • Notes
    • | # Redirect the output
    • Because to pass the Natas8 level of overthewire.org.
  • References
    • man base64
    • 2023-02-06_20:06:11.png
    • https://mayadevbe.me/posts/overthewire/bandit/level11/
    • https://overthewire.org/wargames/bandit/bandit11.html

  • Set the environment variable EDITOR

    • In Nix
      • echo 'export EDITOR="/home/yaoniplan/.nix-profile/bin/vi"' >> ~/.bashrc
      • source ~/.bashrc # Remember to make it effective
    • in Ubuntu Server 22.04
      • vim ~/.bashrc
        export VISUAL=vim
        export EDITOR=vim
        
      • source ~/.bashrc # Make the changes effective
    • In Gentoo Linux
      • eselect editor list
      • eselect editor set 2
      • 2 # The second option is "[2] vi"
      • . /etc/profile # Update the variable
      • For crontab -e
  • Notes
    • Because to set the default editor.
    • /home/yaoniplan/.nix-profile/bin/vi # Replace it with your desired editor
      • which vi # Get it
      • echo $EDITOR # Check it
    • Solve the problem
      [yaoniplan@tux ~]$ crontab -e
      no crontab for yaoniplan - using an empty one
      /bin/sh: line 1: /usr/bin/vi: No such file or directory
      crontab: "/usr/bin/vi" exited with status 127
      [yaoniplan@tux ~]$
      
      • EDITOR=$(which vi) crontab -e # Try to use other editor (e.g. emacs, nano, etc.)
    • nix profile install nixpkgs#vi # Install dependencies
  • References
    • Artificial intelligence

  • Use "tree"

    • tree -L 2 .
  • Notes
    • tree -L 1 {01..10}
    • -L # Level
    • . # Your directory
    • nix profile install nixpkgs#tree # Install dependencies
  • References
    • man tree

  • Use "sort"

    • sort --reverse music01.txt > music02.txt # Arrange the file names in the file in reverse order
  • Notes
    • Because to find out the files that failed to upload.
  • References
    • ChatGPT

  • Replace the tree command with built-in commands

    • find . | sort | sed "s;[^/]*/;|____;g" | sed "s;____|; |;g"
  • Notes
    • . # Under the current directory
    • ; # The delimiter (e.g. /)
  • References
    • Output
      .
      |____.bash_history
      |____.bash_logout
      |____.bash_profile
      |____.bashrc
      |____.config
      | |____procps
      |____.lesshst
      |____.ssh
      | |____known_hosts
      | |____known_hosts.old
      |____.viminfo
      
    • 2023-02-05_16:15:25.png
    • https://stackoverflow.com/questions/23952984/tree-functionality-using-sed-and-find-command/23953129#23953129

  • Back up the full system

    • vim /root/full-backup/full-backup.sh
      BEFORE=$(df -h)
      STARTED=$(date)
      DATE=`date "+%Y-%m-%d"`
      
      DEST="/mnt/backup/$DATE"
      
      rsync --archive --acls --xattrs --delete --progress --verbose --exclude-from=exclude.txt --link-dest=/mnt/backup/last --mkpath / $DEST
      
      ln --symbolic --force --no-dereference $DATE /mnt/backup/last
      
      echo "Started at:   " $STARTED
      echo "Current time: " $(date)
      
      echo "Before:
      
      $BEFORE
      
      Now:
      "
      
      df -h
      
    • vim /root/full-backup/exclude.txt
      /dev/*
      /proc/*
      /sys/*
      /run/*
      /var/db/repos/gentoo
      /var/db/repos/guru
      /tmp/*
      /var/tmp
      /lost+found
      /mnt/*
      /home/heting/.npm
      /home/heting/.cache
      /home/heting/go/pkg/mod/cache
      
  • Notes
    • heting # Replace it with your user name
    • Restore
      • rsync --archive --acls --xattrs --progress --verbose . /mnt
  • References
    • 2023-02-05_11:09:49.png
    • https://wiki.gentoo.org/wiki/Rsync#Backuping

  • Generate random string in Linux

    • openssl rand -base64 22
  • Notes
    • rand # Random
  • References
    • man openssl
    • https://linuxhint.com/generate-random-string-bash/

  • Use "top"

    • k # Kill
    • L # Locate
    • m # Memory
    • t # Task
    • 1 # CPU
    • c # Full path
    • h # Help
    • q # Quit
  • Notes
    • top -n 1 # The same as top then press q
      • -n # Number
  • References
    • 2023-02-05_19:55:32.gif
    • https://askubuntu.com/questions/484510/how-to-run-top-command-1-time-and-exit/484515#484515
    • https://devhints.io/top

  • Use "htop"

    • /logseq # Search a process
    • k # Kill a process
    • Enter # Comfirm deletion
  • Notes
    • Because to delete some software that takes up a lot of processes.

  • Redirect standard error stream to null

    • find / -type f -user bandit7 -group bandit6 -size 33c 2>/dev/null
  • Notes
    • -user # Own by user
      • bandit7 # A user
    • -group # Belong to group
      • bandit6 # A group
    • 2> # Redirect stderr
    • /dev/null # Null
    • vim ~/.local/bin/getIPInformation.sh
      # Output the result using notify-send if available, echo otherwise
      if ! notify-send "$outputResult" 2>/dev/null; then
          echo "$outputResult"
      fi
      
  • References
    • ChatGPT
    • man find
    • 2023-02-05_20:53:19.gif
    • https://askubuntu.com/questions/350208/what-does-2-dev-null-mean/350216#350216
    • https://medium.com/@theGirlWhoEncrypts/overthewire-bandit-level-6-level-7-e1930ac68a54
    • https://overthewire.org/wargames/bandit/bandit7.html

  • Print the first n lines with the head command

    • head -1 ./.file2
  • Notes
    • -1 # Replace the number with others
  • References
    • man head
    • 2023-02-04_22:33:46.png
    • https://stackoverflow.com/questions/6114119/how-do-i-read-the-first-line-of-a-file-using-cat/6114132#6114132

  • Empty file in Linux

    • cat /dev/null > ~/.local/bin/test.sh
  • Notes
    • ~/.local/bin/test.sh # Replace it with your target file
  • References
    • https://www.tecmint.com/empty-delete-file-content-linux/

  • Search for specific files with the find command

    • find . -type f -size 1033c ! -executable
  • Notes
    • f # File
    • c # Bytes
  • References
    • man find
    • 2023-02-05_20:11:35.png
    • https://askubuntu.com/questions/1108882/find-a-file-based-on-specifications/1432795#1432795
    • https://overthewire.org/wargames/bandit/bandit6.html

  • The abbreviation of "Secure File Transfer Program" is "SFTP"

  • References
    • man sftp
    • https://en.wikipedia.org/wiki/Secure_file_transfer_program

  • Use "rsync"

    • rsync -av test.md yaoniplan@192.168.10.106:/home/yaoniplan/
  • Notes
    • -a # --archive
    • -v # --verbose
    • Because to keep the original modification time when copying files.
  • References
    • man rsync
    • Add a demo.gif here
    • https://www.golinuxcloud.com/commands-copy-file-from-one-server-to-another-linux-unix/

  • Use "sftp"

    • sftp yaoniplan@192.168.10.100
      • get -r fileCodeBox/ . # The same as cp
    • sftp root@192.168.10.100:/root/test.md .
    • sftp -P 60022 yaoniplan@192.168.10.105:/etc/nixos/configuration.nix /tmp/
  • Notes
    • -P # Port
    • root # Replace it with your user
    • 192.168.10.100 # Replace it with your remote ip address
    • /root/test.md # Replace it with your remote file
    • . # Replace it with a directory that you want to put
    • scp -P 60022 yaoniplan@192.168.10.105:/etc/nixos/configuration.nix /tmp/ # Another way
  • References
    • 2023-02-11_12:39:35.gif
    • https://superuser.com/questions/134901/whats-the-difference-between-scp-and-sftp/1028877#1028877
    • man scp
    • man sftp
    • ChatGPT

  • The abbreviation of "Extensible Firmware Interface" is "EFI".

  • References
    • https://en.wikipedia.org/wiki/EFI_system_partition

  • Check who and what in Unix-like

    • w
  • Notes
    • w # Who and what
  • References
    • man w
    • Output
      10:37AM  up 1 day, 15:59, 1 user, load averages: 0.30, 0.18, 0.11
      USER       TTY      FROM             LOGIN@  IDLE WHAT
      root       pts/0    192.168.10.105   8:38AM     - w
      

  • Disable the swap files in Vim for a specific directory

    • autocmd BufNewFile,BufRead ~/ftp_mount/* set dir=/some/path
  • Notes
    • Haven't tested it yet as I'm not sure I really need this
  • References
    • https://stackoverflow.com/questions/25592780/special-path-of-vim-swap-files-for-files-in-certain-location

  • Read input in Shell script

    • $# # Number of argument
      • if [[ "$#" -ne 0 ]]
      • if [[ "$#" -eq 2 ]]; then
      • elif [[ "$#" -eq 1 ]]; then
    • $1 # The first argument
    • $0 # The name of the script
    • $@ # A list of all arguments
      • ${@:2} # All arguments starting from the second argument
      • Used when developing scripts with options (e.g. takeAMemo.sh --no-clipboard yourContent)
    • $* # Expand all arguments to a single word
      • trans :zh "$*"
  • References
    • ChatGPT
    • https://www.redhat.com/sysadmin/process-script-inputs

  • Use "ssh"

    • ssh bandit0@bandit.labs.overthewire.org -p 2220
  • Notes
    • ssh-copy-id git@192.168.10.100 # Use without password (Run it in local)
      • git@192.168.10.100 # Replace it with server
      • In fact, it appends client's id_rsa.pub content to server's ~/.ssh/authorized_keys file
      • ssh-keygen # Solve the problem
        yaoniplan@ubuntu2204:~$ ssh-copy-id git@192.168.10.100
        /usr/bin/ssh-copy-id: ERROR: No identities found
        
    • ssh yaoniplan@192.168.10.100 "bash -lc 'source ~/.local/bin/downloadOffline.sh \"$clipboardContent\"'" # Use local variable
    • ssh yaoniplan@192.168.10.100 'bash -c "source ~/.local/bin/runContainer.sh"' & # Execute command temporarily
    • bandit0 # Username
      • whoami # Check user name
    • bandit.labs.overthewire.org # Host
      • ip address # Check address
    • -p # Port
    • 2220 # Port
    • In OpenRC
      • doas rc-update add sshd default # Add sshd to the default runlevel
      • doas rc-service sshd status # Get sshd service status
    • In Systemd
      • doas systemctl enable sshd --now # Enable sshd now on the machine you want to connect to solve the problem
        [yaoniplan@tux ~]$ ssh yaoniplan
        ssh: connect to host 100.80.81.110 port 22: Connection refused
        [yaoniplan@tux ~]$
        
    • If you use USB to share WIFI with your phone, your connection may not respond, the solution is to connect with a network cable
    • Solve the problem in Systemd
      [yaoniplan@tux ~]$ doas systemctl status ssh
      doas (yaoniplan@tux) password:
      Unit ssh.service could not be found.
      [yaoniplan@tux ~]$
      
      • doas emerge -aq net-misc/openssh # Install it in Gentoo Linux
      • doas systemctl enable sshd # Every time at boot time
      • doas systemctl start sshd # Once now
  • References
    • https://wiki.gentoo.org/wiki/SSH#Server
    • https://overthewire.org/wargames/bandit/bandit0.html
    • man ssh

  • Open a file whose name is hyphen

    • cat ./-
  • Notes
    • ./ # The full location
    • - # The file
  • References
    • https://stackoverflow.com/questions/42187323/how-to-open-a-dashed-filename-using-terminal/42187582#42187582

  • Check system running time in Unix-like

    • uptime
  • Notes
    • 10:30AM up 1 day, 15:52, 1 user, load averages: 0.07, 0.10, 0.08 # Output
      • 1 day, 15:52 # The running time
  • References
    • man uptime

  • Type properly

    • Sit straight with your back straight
    • Aim for accuracy rather than speed
    • Type every day
    • not look at the keys while typing
  • References
    • https://www.perplexity.ai/?s=u&uuid=da362756-fc63-4229-951d-c069779a15d1
    • https://www.perplexity.ai/?s=u&uuid=0e72c679-3244-4e3a-90a4-d1e2084d0d84

  • The Linux server can do

    • Web server
    • Mail server
    • Personal cloud storage
    • Database
    • Remote
  • References
    • https://medium.com/@vinaymodepalli/cool-things-to-do-with-a-linux-server-b7035635b31d

  • Use "xclip"

    • echo "`date +%F_%T`.gif" | xclip -selection clipboard
  • Notes
    • xclip -selection clipboard # The same as xsel --input --clipboard
    • mpv --speed=2 --fullscreen --mute=yes $(xsel --output --clipboard) # Paste by default
  • References
    • 2023-01-30_17:06:06.gif
    • https://stackoverflow.com/questions/5130968/how-can-i-copy-the-output-of-a-command-directly-into-my-clipboard/5130969#5130969
    • man xsel

  • Semicolon do at shell script

    • Put two or more commands on the same line
    • Execute commands in order
  • Notes
    • sleep 3s; notifi-send "test"
      • Execute the sleep command first and then execute the notify-send command
  • References
    • 2023-01-30_15:40:19.gif
    • https://stackoverflow.com/questions/25669540/what-is-the-difference-between-double-ampersand-and-semicolon-in-linux
    • https://unix.stackexchange.com/questions/159513/what-are-the-shells-control-and-redirection-operators/159514#159514
    • https://www.javatpoint.com/linux-semicolon

  • Split a specified buffer in Vim

    • :vs #5
  • Notes
    • vs # Vertically split
    • :buffers # Show all buffers
  • References
    • :help :buffers
    • :help :vs
    • 2023-01-30_16:43:42.gif
    • https://vi.stackexchange.com/questions/8122/how-to-open-a-file-from-active-buffer-into-a-split-window
    • https://superuser.com/questions/134176/how-to-split-existing-buffer-vertically-in-vim#:~:text=To%20put%20an%20existing%20buffer,of%20the%20next%20split%20command.
    • https://vi.stackexchange.com/questions/76/can-i-open-a-new-vim-split-from-an-existing-buffer/21081#21081

  • Execute two commands at the same time

    • paplay /usr/share/sound/alsa/Noise.wav & notify-send "test" &
  • Notes
    • & # Execute in the background
  • References
    • 2023-01-30_15:58:24.gif
    • https://www.quora.com/How-do-you-run-two-commands-simultaneously-in-a-terminal

  • View processes in the background

    • jobs # Display status of jobs
  • Notes
    • kill %3 # Kill process 3
  • References
    • 2023-01-30_16:14:22.gif
    • help jobs
    • https://www.cyberciti.biz/faq/find-out-what-processes-are-running-in-the-background-on-linux/

  • Solve the swap file in Vim

    • R # Recovery
    • :w # Write
    • :e # Edit
    • D # Delete
  • References
    • Add a demo.gif here
    • https://superuser.com/questions/480367/whats-the-easiest-way-to-delete-vim-swapfiles-ive-already-recovered-from/1563076#1563076

  • Run Linux commands in the background

    • Press Ctrl-z and then type bg
  • Notes
    • for f in *; do rsync -av "$f" ~/glassShrine/ & done # Another way
      • & # Run in the background
  • References
    • ChatGPT

  • Write an infinite loop in shell script

    • vim ~/.local/bin/timerOfTomato.sh
      #! /bin/sh
      
      soundNotification() {
          paplay /usr/share/sounds/alsa/Noise.wav
      }
      while true; do
          soundNotification
          sleep 900
          soundNotification
          sleep 1200
      done
      
  • Notes
    • true # Improve the readability
  • References
    • https://www.cyberciti.biz/faq/bash-infinite-loop/

  • Use "wget"

    • wget --output-document=msyh.ttc https://raw.githubusercontent.com/taveevut/Windows-10-Fonts-Default/master/msyh.ttc
    • wget --continue yourURL # Continue interrupted download
    • wget -r -np -nH --cut-dirs=2 -R "index.html*" https://data.gpo.zugaina.org/src_prepare-overlay/x11-terms/xst/
  • Notes
    • Improve download speed (If slow)
      export http_proxy="192.168.10.105:7890"
      export https_proxy="192.168.10.105:7890"
      
      • unset http_proxy https_proxy # Unset
      • --no-proxy # Another way
    • -r # Recursive
    • -np # No-parent
    • -nH # No-host-directories (e.g. data.gpo.zugaina.org/)
    • --cut-dirs=2
      • --cut-dirs # Cut-directories
      • 2 # Two directorys (e.g. src_prepare-overlay/, x11-terms/)
    • -R # Reject
    • index.html* # Files (e.g. index.html, index.html?C=N;O=D)
    • -e robots=off # May need it
  • References
    • man wget
    • 2023-01-28_21:59:03.gif
    • https://stackoverflow.com/questions/273743/using-wget-to-recursively-fetch-a-directory-with-arbitrary-files-in-it/273776#273776
    • https://stackoverflow.com/questions/23446635/how-to-download-http-directory-with-all-files-and-sub-directories-as-they-appear/26269730#26269730
    • ChatGPT

  • Resolve a problem in Gentoo Linux

    • doas vim /etc/conf.d/display-manager
      CHECKVT=7
      DISPLAYMANAGER="sddm"
      
  • Notes
    • DISPLAYMANAGER="sddm" # Replace the sddm with your display manager
  • References
    • Problem
      * IMPORTANT: config file '/etc/conf.d/display-manager' needs updating.
      

  • Use "notify-send"

    • notify-send "$(cal)"
      • cal # Replace it with other command (e.g. date)
  • Notes
    • --expire-time=3600000 # Display for 3600000 milliseconds (Focus on one thing)
    • Install notify-send
      • doas emerge -aq x11-libs/libnotify
      • doas emerge -aq x11-misc/notification-daemon
    • Solve the problem
      Error spawning command line “dbus-launch --autolaunch=450faa763c2a5a8029678965639ae3a2 --binary-syntax --close-stderr”: Child process exited with code 1
      
      • export $(dbus-launch) # Temporarily
      • echo 'export $(dbus-launch)' >> ~/.bashrc # Permanently
    • Solve the problem
      GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
      
      • doas vim /usr/share/dbus-1/services/org.freedesktop.Notifications.service
        [D-BUS Service]
        Name=org.freedesktop.Notifications
        Exec=/usr/lib/notification-daemon-1.0/notification-daemon
        
  • References
    • man cal
    • https://wiki.archlinux.org/title/Desktop_notifications
    • https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html
    • https://unix.stackexchange.com/questions/701206/how-do-i-notify-send-a-long-command
    • https://stackoverflow.com/questions/20285697/error-in-spawning-a-dbus-launch-what-is-that

  • Return to the last used tab in Chromium

    • Press Ctrl-Shift-a and then press Enter
  • References
    • https://superuser.com/questions/402095/switching-back-to-last-used-tab-on-chrome/1679002#1679002

  • Enclose the shell command in double quotes

    • foot -e tmux new-session 'vim -c "VimwikiMakeDiaryNote"'
  • Notes
    • If there are no spaces
      > st -e tmux -c vim -c VimwikiIndex
      child exited with status 127
      
  • References
    • 2023-01-26_16:57:24.gif
    • 2023-01-26_21-39.png
    • ChatGPT

  • Remap keys in Vim

    • vim ~/.vimrc
      nnoremap <C-H> <C-W>h
      nnoremap <C-J> <C-W>j
      nnoremap <C-K> <C-W>k
      nnoremap <C-L> <C-W>l
      
  • Notes
    • C-H # Use Ctrl-h to move cursor to the left panel
    • <C-W>h # Use <Ctrl-w>h to move cursor to the left panel too
  • References
    • https://superuser.com/questions/280500/how-does-one-switch-between-windows-on-vim

  • Modify a specify commit message in Git

    • dotfiles rebase --interactive '019ae22^' # Replace pick with edit and then :wq
    • dotfiles commit --amend # Amend your commit message
    • dotfiles rebase --continue
    • dotfiles push --force
  • Notes
    • Disadvantage
      • Modify date
  • References
    • https://stackoverflow.com/questions/1186535/how-do-i-modify-a-specific-commit/1186549#1186549

  • The abbreviation of "our extended virtual terminal" is "RXVT".

  • References
    • https://en.wikipedia.org/wiki/Rxvt

  • Don't overthink things and just keep writing stuff down. #idea

  • References
    • https://github.com/lervag/wiki.vim/issues/101#issuecomment-718284921
    • https://github.com/lervag/wiki.vim/blob/master/doc/wiki.txt#L178

  • Solve the problem about image path in GitHub

    • Remove .. and then git push
  • References
    • 2023-01-24_15:08:22.gif
    • 2023-01-24_11-01.png
    • https://github.com/orgs/community/discussions/23413#discussioncomment-3240273

  • I think tools for handling gifs are ImageMagic, GIMP, and others. #idea

    • I am trying to use ImageMagic and Byzanz
    • GIMP needs to deal with many layers (e.g. a 2.8m gif has about 700 layers)
      • https://graphicdesign.stackexchange.com/questions/102711/editing-gifs-in-gimp
      • https://itsfoss.com/make-gif-in-gimp/

  • Replace VimWiki with wiki.vim in the future #idea


  • Use urxvt (rxvt-unicode)

    • Font Scrollbar Color theme Font size
  • Notes
    • Set a color theme
      ! Colors
      URxvt*background: #000000
      URxvt*foreground: #B2B2B2
      ! black
      URxvt*color0:  #000000
      URxvt*color8:  #686868
      ! red
      URxvt*color1:  #B21818
      URxvt*color9:  #FF5454
      ! green
      URxvt*color2:  #18B218
      URxvt*color10: #54FF54
      ! yellow
      URxvt*color3:  #B26818
      URxvt*color11: #FFFF54
      ! blue
      URxvt*color4:  #1818B2
      URxvt*color12: #5454FF
      ! purple
      URxvt*color5:  #B218B2
      URxvt*color13: #FF54FF
      ! cyan
      URxvt*color6:  #18B2B2
      URxvt*color14: #54FFFF
      ! white
      URxvt*color7:  #B2B2B2
      URxvt*color15: #FFFFFF
      
    • Disable scroll bar
      URxvt.scrollBar: false
      URxvt.scrollBar_right: false
      URxvt.scrollBar_floating: false
      URxvt.scrollstyle: rxvt
      
    • Set font
      URxvt.font xft:Ubuntu Mono:style=regular
      
    • xrdb ~/.Xresources # Reload the configuration
    • urxvt -fn "xft:Ubuntu Mono:style=regular" # Test a font
    • doas vim /etc/portage/package.use # In Gentoo Linux
      x11-terms/rxvt-unicode-9.30 perl xft
      
      • perl # Support perl script
      • xft # Support for XFT font renderer
  • References
    • https://wiki.gentoo.org/wiki/X_resources
    • https://www.reddit.com/r/Gentoo/comments/m8dnyi/help_with_urxvt_font_setup/
    • https://wiki.gentoo.org/wiki/Rxvt-unicode

  • Insert date and time in Vim

    • <C-r>=strftime('%F') # After the cursor (Output: 2023-02-24) in insert mode
    • :r!date # Below the current line (Output: Fri Feb 24 04:21:34 PM CST 2023)
      • r!date +\%F # 2023-05-18
  • Notes
    • <C-r> # Control key and r key
    • :r!
      • r # Read
      • ! # Execute external commands (e.g. date, templateForVimWiki.sh)
  • References
    • :help :r!
    • https://unix.stackexchange.com/questions/8101/how-to-insert-the-result-of-a-command-into-the-text-in-vim

  • Replace context of the current line in Vim

    • :s/italic/boldAndItalic/g
  • Notes
    • s # Substitute
    • g # Global
    • Shift-v # Select some line
      • : # Press it
      • s/italic/boldAndItalic/g # Type it
  • References
    • :help :substitute
    • https://stackoverflow.com/questions/46181488/how-to-search-and-replace-in-current-line-only

  • Use Bash

    • ctrl-i # Insert (The same as Tab)
    • Ctrl-d # Detach (The same as exit)
    • Ctrl-r # Reverse search history command
      • vim -c # Type it in terminal, it may display vim -c VimwikiIndex
    • Ctrl-p # The previous command
    • Alt-b or Ctrl-Left # Move the cursor back one word
    • Alt-c or Ctrl-Right # Move the cursor forward one word
    • Ctrl-h # Backspace key
    • Ctrl-d # Delete key
      • d # Delete
    • Ctrl-u # Delete left of the cursor
    • Ctrl-k # Delete right of the cursor
    • bind -lp # Show all shortcuts
    • Ctrl-j # Enter key
    • Ctrl-_ # Undo
  • References
    • rofi -show keys
    • https://stackoverflow.com/questions/4009412/how-to-use-arguments-from-previous-command
    • https://www.redhat.com/sysadmin/shortcuts-command-line-navigation

  • Use Rofi theme

    • Put theme.rasi files into the themes directory
      git clone https://github.com/newmanls/rofi-themes-collection
      cd rofi-themes-collection
      mkdir -p ~/.local/share/rofi/themes/
      cp ./* ~/.local/share/rofi/themes/
      
  • Notes
    • rofi -show drun # Show drun mode
    • Rofi Theme Selector # Type it in Rofi search bar
      • Enter # Preview
      • Esc # Cancel
      • Alt-a # Accept
      • Ctrl-Tab # Toggle mode
    • Beautiful
      • theme theme theme theme
        spotlight-dark squared-nord rounded-blue-dark dmenu by Qball
        nord-TwoLines nord-oneline sidebar-v2 by Qball
    • features
      • Font: big
      • Color: dark
      • Icon (optional)
  • References
    • https://github.com/newmanls/rofi-themes-collection

  • Use gawk

    • gawk '/use/ && /bash/; BEGIN{IGNORECASE=1}' test/diary/*
    • gawk 'BEGIN{IGNORECASE=1} /use/ && /bash/' test/diary/*
    • Width=$(xwininfo --root | gawk '/Width/ {print $2}')
  • Notes
    • && # And
    • BEGIN{IGNORECASE=1} # Ignore case
    • $2 # The second column
  • References
    • https://unix.stackexchange.com/questions/533848/and-operation-and-case-insensitivity-in-awk-regular-expression

  • Use GIF recorder named Byzanz

    byzanz-record --duration=10 \
    --x=0 --y=0 --width=1366 --height=768 \
    ~/vimwiki/assets/`date +%F_%T`.gif
    
  • Notes
    • doas emerge -aq media-gfx/byzanz # Search ebuild repository in the repository
  • References
    • https://github.com/LinuxTOY/linuxtoy.org/blob/master/content/byzanz.md

  • Rename extension of multiple files in Linux

    • find . -name '*.txt' -exec rename txt wiki {} \;
  • Notes
    • -exec # Execute
    • find . -name "*.md" -exec rename -a _ - {} \; # Rename underscores to hyphens
      • -a # All
  • References
    • man rename
    • 2023-01-22_19-50.png
    • https://unix.stackexchange.com/questions/19654/how-do-i-change-the-extension-of-multiple-files
    • https://askubuntu.com/questions/35922/how-do-i-change-extension-of-multiple-files-recursively-from-the-command-line

  • Use "git"

    • Test a PR
      • git clone https://github.com/yt-dlp/yt-dlp && cd yt-dlp # Clone repository
      • git fetch origin pull/12048/head:pr-12048 # Fetch the PR
      • git checkout pr-12048 # Switch to the PR branch
      • ./yt-dlp.sh --skip-download --ignore-errors --print-to-file url ../rockefeller.txt "https://m.ximalaya.com/album/14321728" # Verify that the PR fixes the bug
    • Switch to another branch of Git
      • git switch gh-pages # Switch to "gh-pages" branch
    • On a new computer
      • git config --global user.email "yaoniplan@gmail.com" # Set user email
      • git config --global user.name "yaoniplan" # Set user name
    • dotfiles commit --amend -m "Push to master branch on odd days" # Amend (Modify) the last commit message
      • dotfiles push origin development -f # Solve the problem
        yaoniplan@ubuntu2204:~$ dotfiles push origin development
        To 192.168.10.100:/var/git/dotfiles.git
         ! [rejected]        development -> development (non-fast-forward)
        error: failed to push some refs to '192.168.10.100:/var/git/dotfiles.git'
        hint: Updates were rejected because the tip of your current branch is behind
        hint: its remote counterpart. Integrate the remote changes (e.g.
        hint: 'git pull ...') before pushing again.
        hint: See the 'Note about fast-forwards' in 'git push --help' for details.
        
      • dotfiles pull origin development # Someone else pull the development branch
      • Because sometimes the submitted information has typos.
    • Use .gitignore to ignore every file and directory except the ones specified
      • vi ~/.config/store/supermarket/.gitignore
        # Ignore everything
        /*
        # Do not ignore .gitignore itself
        !.gitignore
        # Exclude specific files (Or directories)
        !index.html
        !styles.css
        !script.js
        # Do not ignore the src directory itself
        !src/
        
      • /* # Everything in the current directory
      • ! # Not (Exclude)
    • git clone --branch development git@100.65.173.16:/var/git/diary.git/ ~/.config/diary/ # Clone development branch to ~/.config/diary/ directory
      • development # Replace it with your branch name
      • ~/.config/diary/ # Replace it with destination path (Optional)
    • dotfiles rm --cached ~/.local/bin/openMyWebsite.sh # Untrack a newly added file after using git add
    • git diff --cached # Display the difference after using git add
      • git diff e869181..8b825a6 # After using git commit
    • git remote set-url --add --push origin git@192.168.10.100:/var/git/note.git # Add a push URL
      • git remote --verbose # Check Git remote URL
      • git remote set-url origin git@192.168.10.107:/var/git/note.git # Update the fetch URL
      • git remote add origin git@100.65.173.16:/var/git/parse.git # Add a remote named 'origin'
        error: No such remote 'origin'
        
    • git init ~/parse/ # Initialize Git repository in the directory to control version of files
      • git add --all
      • git commit --message="First commit"
      • git remote add origin git@github.com:yaoniplan/yaoniplan.git
      • New a repository in GitHub
      • git push origin master
    • git clone https://yaoniplan:yourPersonalAccessToken@github.com/yaoniplan/diary # Clone a private repository
      • yaoniplan # Replace it with your user name
      • yourPersonalAccessToken # Replace it with yours
    • Test some files
      • git reset --hard ca86a59 # Reset to previous version
      • git clean --force -d # Remove untracked files (directories)
    • Unstage all files and then stage only the modified ones
      • git reset # Unstage all files
      • git add --update # Stage only the modified ones
    • dotfiles ls-files # List tracked files
    • dotfiles commit --message="Set the default volume to 60 percent (without any arguments)" # Set commit message
    • dotfiles push git@192.168.10.100:/var/git/dotfiles.git development # Push to a specific remote URL
    • git show 97671e3:index.html # Show the last committed complete content of a file
    • git restore .config/i3/config # Discard changes of the file
      • git restore . # Restore all files
    • git checkout -b development # The same as the following two commands
      • git branch development # Create a new branch
      • git checkout development # Switch to the branch
  • Notes
    • Use a GitHub mirror when can't access the Internet
      • https://github.com/nICEnnnnnnnLee/GithubSoEasy
      • git clone https://git.yaoniplan.eu.org/yaoniplan/dotfiles
      • https://git.yaoniplan.eu.org/loginyyy?ko=1 # Access this link first to authorize before using the GitHub front end
    • add # Replace it with delete to delete the push URL
    • 192.168.10.100 # Replace it with github.com
    • /var/git/note.git # Replace it with yaoniplan/note.git
    • 97671e3:index.html # Get it by using the following command
      • git log -1 --name-only
    • s testIndex.html # Save file as testIndex.html in the less command interface
    • Solve the problem
      yaoniplan@tux ~ $ dotfiles push origin development
      Everything up-to-date
      ssh: Could not resolve hostname github.com: Temporary failure in name resolution
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      yaoniplan@tux ~ $ 
      
      • Method one
        doas systemctl disable systemd-resolved # May cause the web proxy to become unavaliable
        nmcli connection show # Get NAME (e.g. eno1)
        nmcli connection modify eno1 ipv4.dns "8.8.4.4 8.8.8.8"
        nmcli connection modify eno1 ipv6.dns "2001:4860:4860::8844 2001:4860:4860::8888"
        doas systemctl restart NetworkManager # Make changes effective
        
      • doas vi /etc/resolv.conf # Method two that the file will be cleared by NetworkManager sometimes
        nameserver 8.8.4.4
        nameserver 8.8.8.8
        
    • Solve the problem
      yaoniplan@tux ~ $ dotfiles push origin development
      ssh: connect to host github.com port 22: Connection timed out
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      yaoniplan@tux ~ $
      
      • vi ~/.ssh/config
        Host github.com
          Hostname ssh.github.com
          Port 443
        
      • ssh -T git@github.com
  • References
    • image.png
    • image.png
    • https://stackoverflow.com/questions/47630950/how-can-i-switch-to-another-branch-in-git
    • 2023-02-24_22:06:22.png
    • https://blog.yowko.com/git-push-multiple-remote-repository/
    • https://gist.github.com/miztiik/647c3b67a9c3c3e8a5c857436a59477f
    • https://gist.github.com/Tamal/1cc77f88ef3e900aeae65f0e5e504794
    • https://hedzr.com/devops/git/git-tips-ls-tree-or-files/
    • https://stackoverflow.com/questions/9393409/ssh-could-not-resolve-hostname-github-com-name-or-service-not-known-fatal-th/38343911#38343911
    • git restore --help # Replace restore (e.g. clone) with remote
    • https://learngitbranching.js.org/
    • h
    • Artificial intelligence

  • Display $PATH

    • echo $PATH
  • References
    • https://stackoverflow.com/questions/14617041/how-can-i-see-the-current-value-of-my-path-variable-on-os-x

  • Add a directory to $PATH permanently

    • vim ~/.bash_profile
      # Set PATH to execute scripts anywhere if it exists
      if [[ -d "$HOME/.local/bin/" ]]; then
          export PATH="$PATH:$HOME/.local/bin/"
      fi
      
      • Log out and log back to make changes effective
      • echo $PATH # Check it
  • Notes

    • -d # Directory
    • Advantages
      • Execute scripts anywhere
    • $HOME/.local/bin/ # Replace it with your directory
    • chmod u+x ~/.local/bin/captureFullScreen2GIF.sh # Make the command work
      • u # User
      • x # Execute
    • captureFullScreen2GIF.sh # Execute it anywhere, and works in the dmenu too
    • PATH=$PATH:$HOME/.local/bin/ # Add the directory to $PATH temporarily
  • References
    • https://serverfault.com/questions/139451/where-is-a-good-permanent-place-to-install-custom-bash-scripts
    • https://www.reddit.com/r/archlinux/comments/j35cfc/comment/g79rysk/?utm_source=share&utm_medium=web2x&context=3

  • Put scripts to directory

    • $HOME/.local/bin/ # A single user
    • /usr/local/bin/ # All users
  • References
    • https://askubuntu.com/questions/465109/where-should-i-put-my-script-so-that-i-can-run-it-by-a-direct-command

  • Show line numbers permanently in Vim

    • vim ~/.vimrc
      " Show absolute line numbers
      set number
      
  • Notes
    • set relativenumber # Show relative line numbers
    • set number relativenumber # Show absolute and relative line numbers
    • After using it for a while, It can be distracting.
      • Probably because I'm using a small screen.
  • References
    • https://phoenixnap.com/kb/vim-show-line-numbers#

  • Use "vim"

    • Copy selected text to the clipboard
      • Ctrl-v # Visual Block mode (Select text)
      • :w !wl-copy # Write the selected text to a command, pipes it to wl-copy
    • Record a repeating action
      • qd # Start recording as d
      • q # Stop recording
      • @d # Playback recording d
    • :%s/^\n//g # Remove blank lines
      • ^ # Beginning of line
      • \ # Escape
      • n # Newline
    • * # Search for the word under the cursor
      • n # Jump to the next (Opposite: N)
    • :%s/$/\=printf('%02d', line('.')+1).'.MP4'/g # Add the line number plus one to the end of each line
      • \= # Expression
      • printf() # A funcation
      • %02d # A zero-padded two-digit integer (Optional)
      • line('.')+1 # Add 1 to the current line number
      • .'.MP4' # Concatenate the formatted number with .MP4 (Optional)
      • :%s/$/\=printf(line('.'))/g # This works too
    • :%s/\v\d{2}\.MP4$//g # Remove what the above command generates
      • \v # Very magic mode
      • \d{2} # Two digits
      • \ # Escape character
    • q: # Command line mode (Query recent command)
      • / # Search
      • :q # Quit
    • Ctrl-w :term # New a terminal if tmux does not exist
    • :!cat % | wl-copy # Copy current file's content to clipboard
      • ! # Execute external commands (e.g. cat, rm, etc.)
      • % # Current file
    • :%s/$/ - 00/g # Batch add a string (e.g. ' - 00') to the end of line
    • :set encoding=utf-8 # Display Chinese characters properly
    • :set paste # Fix indentation issues when pasting
    • % # Jump the cursor to matching bracket
    • >> # Indent current line (like >l, v>)
    • o # Insert a new line below the cursor
    • u # Undo
      • Ctrl-r # Redo
    • daw # Delete a word
      • . # Repeat last change
    • vU # Uppercase
      • v # Visual mode
    • s # The same as x and then i
    • L # Bottom of screen
    • H # Top of screen
    • M # Middle of screen
    • f # Find a character within a line
    • W # The same as w, but ignore symbol (punctuation)
    • I # Insert text before the first non-blank in the line
    • A # Append text at the end of the line
    • /\vtext|vim # Search for text with multiple keywords
      • \v # Very magic
    • :set ignorecase # Search for text ignoring case
      • /thank\c # Search for "thank" ignoring case
    • :vs # Vertically split (real-time synchronization)
    • caw # Change a word
      • c # Change
    • :e# or C-6 # Switch between two files
    • C-o # Return to the previous cursor position
      • '' # Return to the previous line
    • C-p # Previous keyword completion (in insert mode)
    • C-n # Next keyword completion
    • C-[ # Esc key
    • gM # Move cursor to the middle of a line
    • r # Replace
    • Mark
      • ma # Mark as "a"
      • `a # Jump to mark "a"
    • Ctrl-w down/j # Move the cursor from the up pane to the down pane
  • Notes
    • vim ~/.vimrc # Write a function
      " Insert code block
      function! InsertCodeBlock()
          " Check if the current line has a four-space indent
          if indent('.') == 4
              " Append text below the current line
              call append(line('.'), ['      ```', '      ', '      ```'])
              " Move cursor down twice
              execute "normal! 2j"
              " Enter insert mode at the end of line (Like 'A' key)
              startinsert!
          else
              call append(line('.'), ['          ```', '          ', '          ```'])
              execute "normal! 2j"
              startinsert!
          endif
      endfunction
      
      command! InsertCodeBlock :call InsertCodeBlock()
      
      " Insert template text
      function! InsertTemplateText()
          " A single line only and the line has no content
          if line('$') == 1 && strlen(getline(1)) == 0
              " Append these lines at the cursor position in insert mode
              call append(line('i'), ['- #### ', '    - ``', '- ***Notes***', '    - ``', '- ***References***', '    - ``', '- ---'])
              " Simulate key presses in normal mode
              call feedkeys("Gdd6kA", 'n')
          else
              " Append these lines to the end of the file
              call append(line('$'), ['- #### ', '    - ``', '- ***Notes***', '    - ``', '- ***References***', '    - ``', '- ---'])
              call feedkeys("G6kA", 'n')
          endif
      endfunction
      
      command! InsertTemplateText :call InsertTemplateText()
      
      • :InsertCodeBlock # Use the command to call the function
      • Because to use markdown to write some reusable documents.
    • Manage plugins with built-in package manager
      • git clone https://github.com/vimwiki/vimwiki ~/.vim/pack/vendor/start/vimwiki # Install a plugin
      • git -C ~/.vim/pack/vendor/start/vimwiki/ pull # Update a plugin
      • mv ~/.vim/pack/vendor/start/vimwiki/ /tmp/ # Remove a plugin
      • Because it is more convenient than traditional plugin managers.
    • vim ~/.vimrc # Replace tab characters with spaces
      " Use spaces for indenting
      set expandtab " Replace tab characters with spaces
      set tabstop=4 " Insert 4 spaces when expandtab is enabled
      set shiftwidth=4 " Replace indentation with spaces
      set smartindent " Adjust indentation based on syntax automatically
      
      • :source ~/.vimrc # Reload to make changes effective
    • :e # Edit
      • Replace js with javascript in Markdown code block
    • # # Alternate buffer
      • :ls or :buffers # Check buffer
      • :b 7 # Move to buffer 7
  • References
    • https://vim.fandom.com/wiki/Recording_keys_for_repeated_jobs#:~:text=To%20start%20recording%2C%20press%20q,keystrokes%20to%20the%20specified%20register.
    • https://missing-semester-cn.github.io/2020/editors/
    • https://vimhelp.org/repeat.txt.html#packages
    • https://web.archive.org/web/20230130013710/https://codingshower.com/vim-set-tab-to-n-spaces/
    • :help /\v
      • \n
    • :help .
    • 2023-01-16_11-50.png
    • https://stackoverflow.com/questions/2946051/changing-case-in-vim/2946054#2946054
    • https://m4xshen.me/posts/vim-basic-commands/
    • https://unix.stackexchange.com/questions/114264/is-there-a-command-reverse-search-in-vim
    • https://stackoverflow.com/questions/704434/is-there-any-way-to-highlight-multiple-searches-in-gvim
    • https://docs.oracle.com/cd/E19620-01/805-3902/6j3n40vuh/index.html#:~:text=Searches%20normally%20are%20case%2Dsensitive,stop%20at%20its%20first%20occurrence.
    • https://medium.com/@Sohjiro/introduction-to-vim-buffers-dd966ff518d
    • https://stackoverflow.com/questions/19971023/how-to-go-back-to-previous-opened-file-in-vim
    • https://vi.stackexchange.com/questions/2462/how-do-i-move-the-cursor-to-the-center-of-current-line
    • Artificial intelligence

  • Rcover tmux when computer is turned on

    • vim ~/.bashrc
      alias mux='pgrep -vx tmux > /dev/null && \
          tmux new-session -d -s delete-me && \
          tmux run-shell ~/.tmux/plugins/tmux-resurrect/scripts/restore.sh && \
          tmux kill-session -t delete-me && \
          tmux attach-session || tmux attach-session'
      
  • Notes
    • I don't need it on January 20, 2023.
    • vim ~/.tmux.conf
      set -g @plugin 'tmux-plugins/tmux-resurrect'
      set -g @plugin 'tmux-plugins/tmux-continuum'
      
      # Set restore automatically by using tmux-continuum
      set -g @continuum-restore 'on'
      
      # Set start automatically by using tmux-continuum
      set -g @continuum-boot 'on'
      
      # Set the save interval to 1 minute
      set -g @continuum-save-interval '1'
      
    • prefix + I # Press it to install the plugins
    • tmux source-file ~/.tmux.conf # Reload the file
    • -v # Inverse
    • -x # Exact
    • /dev/null # Empty file
    • && # And
    • -d # Detach
    • -s # Session-name
    • run-shell # Run shell-command
    • -t # Target
    • || # Or
  • References
    • man tmux
    • man bash
    • https://github.com/tmux-plugins/tmux-continuum/blob/master/docs/faq.md
    • https://github.com/tmux-plugins/tmux-continuum/blob/master/docs/automatic_start.md
    • https://github.com/tmux-plugins/tmux-continuum
    • https://tech.serhatteker.com/post/2019-11/restore-tmux-after-reboot/

  • Use "crontab"

    • crontab -e
      0~59 8 * * * $HOME/.config/checkIn/.venv/bin/python $HOME/.config/checkIn/checkIn.py
      * * * * * /usr/bin/bash /home/yaoniplan/.tmux/plugins/tmux-resurrect/scripts/save.sh
      @reboot /usr/bin/touch /home/yaoniplan/testTwo.md
      30 16 * * * /usr/bin/bash $HOME/.local/bin/pushCode.sh
      
  • Notes
    • * * * * * # Every minute when the computer is running
      • 53,54,55 11 * * * # At 11:53, 11:54, and 11:55
      • 53 # 53rd minute
      • 11 # 11th hour
      • 0~59 8 * * * # At a random minute between 8:00 and 8:59
      • */5 * * * * # Every 5 minutes is an interval
      • * # Every
      • / # Interval
      • 0 */6 * * * # Every 6 hours is an interval
      • 0 # Specify the exact minute of the hour (0th minute)
      • 24 Hours divided by 6 Hours equals 4 intervals
    • /usr/bin/bash # Path of command
      • which bash # Get it
    • /home/yaoniplan/.tmux/plugins/tmux-resurrect/scripts/save.sh # Argument of command
    • @reboot # Every time when the computer is turned on
    • 30 16 * * * # 16:30 every day
    • Make the changes effective
      • In OpenRC
        doas rc-update add cronie default
        doas /etc/init.d/cronie start
        
      • In Systemd
        doas systemctl enable cronie
        doas systemctl start cronie
        
  • References
    • https://stackoverflow.com/questions/34753831/execute-a-shell-script-everyday-at-specific-time
    • https://github.com/tmux-plugins/tmux-continuum/issues/99#issuecomment-992457058

  • Save file automatically in Vim without plugins

    • vim ~/.vimrc
      autocmd TextChanged,TextChangedI * silent write
      
  • Notes
    • Try not to use it, accidents may happen
  • References
    • https://stackoverflow.com/questions/60600151/use-autosave-in-vim-using-no-plugin

  • Disable swap files in Vim for VimWiki

    • vim ~/.vimrc
      set noswapfile
      
  • Notes
    • ls ~/.cache/vim/swap/ # View the default swap file
    • I don't recommend it, but you can organize swap files
      • mkdir ~/.vim/tmp/
      • vim ~/.vimrc
        set directory^=$HOME/.vim/tmp//
        
  • References
    • https://vi.stackexchange.com/questions/177/what-is-the-purpose-of-swap-files#:~:text=Disabling%20swap%20files,setlocal%20swapfile%20while%20running%20Vim.

  • Use "vimwiki"

    • :VimwikiTable 4cols 6rows # Create a table with 4 cols and 6 rows
    • :VimwikiGenerateLinks # Generate links of wiki pages automatically
    • ]] # Next header
    • vim -c VimwikiIndex # Return index.wiki in terminal
      • <Leader> ww # Return index.wiki
    • vim -c VimwikiMakeDiaryNote # Return to today's diary (e.g. 2023-01-18.md)
      • <Leader> w <Leader> w # Return 2023-01-18.md
    • Ctrl-upArrow # The previous diary
    • :VWS /Use VimWiki/ # Search 'Use VimWiki'
      • :VWS # The alias of :VimwikiSearch
      • :VWS /\csymbol/
        • \c # Case-insensitive
      • :lopen # List open
      • :lnext
    • = # Add header level
    • gll # Increase indent of list item
    • glh # Decrease indent of list item
    • gl- # Insert hypen (-)
    • Ctrl-space # Add a check box ([ ])/Add a X/Remove a X
  • Notes
    • vim ~/.vimrc # Configure as needed
      " Make plugins named VimWiki work
      set nocompatible
      filetype plugin on
      syntax on
      
      " Use Markdown syntax for VimWiki
      " Replace `diary/` with `journals/`
      let g:vimwiki_list = [{
          \ 'path': '~/.config/note/',
          \ 'diary_rel_path': 'journals/',
          \ 'syntax': 'markdown',
          \ 'ext': '.md'}]
      " Replace `[Vim](Vim)` with `[Vim](Vim.md)`
      " Refer to https://github.com/vimwiki/vimwiki/issues/1210
      let g:vimwiki_markdown_link_ext = 1
      " Disable all Concealing (level: 0-3)
      let g:vimwiki_conceallevel = 3
      " Disable URL shortening
      let g:vimwiki_url_maxsave = 0
      " Replace spaces in the file names with underscores
      let g:vimwiki_links_space_char = '_'
      " Change leader key from '\' to ' '
      let mapleader = " "
      " Map the keys to complete strings
      " (n: normal; nore: non-recursive)
      " (`<Left>`: Move cursor one position to the left)
      nnoremap <leader>w/ :VimwikiSearch //<Left>
      " `<CR>` # Carriage Return (Same as `<Enter>`)
      nnoremap <leader>it :InsertTemplateText<CR>
      
    • Advantage: Wiki
      • Enter # Press it to create a wiki file
        • ../pages/Vim # Create ~/vimwiki/pages/Vim.md file
      • Tab # Next wiki link or hyper link
      • Shift-Tab # Previous wiki link
      • v # Visual
        • e # End
    • git clone https://github.com/vimwiki/vimwiki ~/.vim/pack/vendor/start/vimwiki # Install dependencies
  • References
    • https://overflow.smnz.de/questions/446269/can-i-use-space-as-mapleader-in-vim
    • :help VimwikiTable
    • https://www.reddit.com/r/vim/comments/8xzpkz/you_probably_dont_need_vimwiki/
    • https://samgriesemer.com/Vimwiki#Settings
    • https://gist.github.com/ovelny/72659e841c1dbcee173eb244c8609252
    • https://vi.stackexchange.com/questions/19357/search-through-entire-vimwiki#:~:text=Vimwiki%20has%20a%20simple%20search,help%20pages%20%3Ah%20%3AVimwikiSearch%20.
    • https://github.com/vimwiki/vimwiki
    • ChatGPT

  • Use "ps"

    • ps aux | grep clash
    • kill 3828
  • Notes
    • ps # Process status
    • a # All
    • u # User
    • x # Use with the a option
    • 3828 # PID
      • PID # Process ID
  • References
    • man ps
    • https://askubuntu.com/questions/910922/what-does-the-aux-option-of-ps-stand-for
    • https://www.linuxfoundation.org/blog/blog/classic-sysadmin-how-to-kill-a-process-from-the-command-line

  • The punctuation of "at sign" is "@".

  • References
    • https://en.wikipedia.org/wiki/At_sign

  • Use tmux plugins named tmux-tilish

    • Alt-Enter # New a pane
    • Alt-h/j/k/l # Move the cursor to the left/down/up/right pane
    • Alt-Shift-q # Quit the pane
    • Alt-z # Zoom in
    • Alt-Shift-h/j/k/l # Move pane
    • Alt-Shift-1/2/3 # Move pane or window to window 1/2/3
    • Alt-s # Split like -
      • Alt-v # |
  • Notes
    • Install the plugins
      • vim ~/.tmux.conf
        # Lists of plugins
        set -g @plugin 'jabirali/tmux-tilish'
        
        # Set default layout by using tmux-tilish plugin
        set -g @tilish-default 'main-vertical'
        
    • Integrate Vim and tmux
      • vim ~/.tmux.conf
        set -g @plugins 'sunaku/tmux-navigate'
        
        " Use navigate with tilish together
        set -g @tilish-navigate 'on'
        
        • prefix I # Install plugins of tmux
      • vim ~/.vimrc
        Plug 'sunaku/tmux-navigate'
        
        • :source ~/.vimrc
        • PlugInstall # Install plugins of Vim
      • Alt-h/j/k/l # Move cursor in Vim to the left/down/up/right pane of tmux
        • :vs # A pane of Vim
        • Alt-Enter # A pane of tmux
    • Warning: Not suitable for use with tiling window managers (e.g. i3, DWM, etc.)
      • Shortcut key conflict
  • References
    • https://github.com/sunaku/tmux-navigate
    • https://github.com/jabirali/tmux-tilish

  • Set dark theme in Linux

    • vim ~/.config/gtk-3.0/settings.ini
      [Settings]
      gtk-application-prefer-dark-theme=1
      
  • Notes
    • Chromium
      • about:settings # Type it in search bar
      • Ctrl-f # Press it and type appearance
      • Use GTK # Click it
    • doas reboot # Make it work (Maybe just restart browser)
    • It works on the notify-send command.
  • References
    • 2023-01-16_11-23.png
    • https://unix.stackexchange.com/questions/63389/how-can-i-use-adwaita-dark-for-all-applications-in-gnome-3
    • https://forums.gentoo.org/viewtopic-t-1079650-start-0.html

  • Move all images from multiple subfolders into one directory

    • find . -name '*.png' -exec mv {} ../testone/ \;
  • Notes
    • *.png # Files with PNG extension
      • png # Replace it with other extensions (e.g. jpg, gif, etc.)
  • References
    • 2023-01-15_15-55.png
    • https://unix.stackexchange.com/questions/67503/move-all-files-with-a-certain-extension-from-multiple-subdirectories-into-one-di

  • Install a plugins manager for Vim

    • Type it in terminal
      curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
      
  • Notes
    • -f # Fail
    • -L # Location
    • -o # Output
    • backslash # A new line
      • Write the rest of command on the next line
  • References
    • man curl
    • https://github.com/junegunn/vim-plug/wiki/tutorial

  • Use Vim plugins manager

    • vim ~/.vimrc # A small configuration
      call plug#begin()
      Plug 'vimwiki/vimwiki'
      Plug 'sunaku/tmux-navigate'
      Plug 'dbridges/vim-markdown-runner'
      call plug#end()
      
    • :source ~/.vimrc # Restart Vim
  • Notes
    • Install plugins
      • :source ~/.vimrc
      • :PlugInstall
    • Remove plugins
      • Comment out
      • :source ~/.vimrc
      • :PlugClean
    • Update plugins
      • :PlugUpdate
    • Upgrade vim-plug itselt
      • :PlugUpgrade
  • References
    • https://github.com/junegunn/vim-plug
    • https://github.com/junegunn/vim-plug/wiki/tutorial

  • Use "vi"

    • set -o vi # Enable Vi mode in the Linux shell
    • ZZ # Same as :wq
    • :%s/espeak/gtts\-cli/g # Replace espeak with gtts-cli globally
    • Use four space for indenting temporarily
      • :set tabstop=4
    • 1G # Move cursor to the first line
  • Notes
    • !$ # The last argument of the last command (Or $_, !!:$, Alt-Shift-Hypen)
    • Ctrl-[ # The same as Esc key (Ctrl-c is ok if no [ key)
      • _ # Last argument of last command
      • d$ # Same as Ctrl-k of Emacs mode
      • Ctrl-l # Clear screen
      • k # The same as Ctrl-p of Emacs mode
      • / # The same as Ctrl-r of Emacs mode
    • set -o # Show the current settings
    • vi ~/.bashrc # Method one that enable by default
      # Enable Vi mode
      set -o vi
      bind -m vi-command 'Control-l: clear-screen'
      bind -m vi-insert 'Control-l: clear-screen'
      
      • set -o emacs # Enable Emacs mode
    • vi ~/.inputrc # Method two that enable by default
      set editing-mode vi
      $if mode=vi
      
      set keymap vi-command
      Control-l: clear-screen
      
      set keymap vi-insert
      Control-l: clear-screen
      $endif
      
    • Because to try to replace Vim with Vi and for portability.
      • Use external scripts and commands
  • References
    • https://libreddit.perennialte.ch/r/ish/comments/13198h8/permissions_issues_and_startup_commands/
    • https://unix.stackexchange.com/questions/197005/recover-last-argument-of-the-last-command-in-bash-vi-mode/202589#202589
    • https://unix.stackexchange.com/questions/155702/how-to-recall-last-argument-in-bash-with-vi-setting/157021#157021
    • https://unix.stackexchange.com/questions/104094/is-there-any-way-to-enable-ctrll-to-clear-screen-when-set-o-vi-is-set/104101#104101
    • https://wiki.gentoo.org/wiki/Bash
    • :set all
    • ChatGPT

  • Use TPM (tmux plugins manager)

    • mkdir -p ~/.tmux/plugins/
    • git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
    • vim ~/.tmux.conf
      # Lists of plugins
      set -g @plugin 'tmux-plugins/tpm'
      
      # Initialize tmux plugins manager
      # (Put this line at the bottom)
      run -b '~/.tmux/plugins/tpm/tpm'
      
    • tmux source ~/.tmux.conf # Reload tmux
  • Notes
    • Install plugins
      • vim ~/.tmux.conf
        set -g @plugin 'tmux-plugins/yank'
        
      • Press prefix + I
        • I # Install
    • Uninstll plugins
      • vim ~/.tmux.conf
        # set -g @plugin `tmux-plugins/yank`
        
      • Press prefix + Alt + u
        • u # Uninstall
  • References
    • https://github.com/tmux-plugins/tpm/blob/master/docs/automatic_tpm_installation.md
    • https://wiki.gentoo.org/wiki/Tmux/plugins/tpm

  • Add a README to #GitHub when using a bare #Git repository
    • mkdir ~/.github/
    • vim ~/.github/README.md
  • References
    • 2023-01-14_21-24.png
    • 2023-01-14_21-27.png
    • https://stackoverflow.com/questions/62561933/how-to-add-readme-md-on-github-but-not-have-same-readme-md-in-home-directory-whi
    • https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes

  • Use "picom"

    • Fading
      fading = true;
      
    • Shadow
      shadow = true;
      
    • Rounded corner
      corner-radius = 9;
      backend = "glx";
      
    • Opacity
      active-opacity = 1.0;
      inactive-opacity = 0.8;
      frame-opacity = 0.8;
      
      opacity-rule = [
          "80:class_g = 'st-256color'"
      ];
      
    • Background blur
      blur-method = "dual_kawase";
      backend = "glx";
      
  • Notes
    • xprop # Get the class_g (e.g. Chromium)
      WM_CLASS(STRING) = "chromium", "Chromium"
      
    • vim ~/.config/picom.conf # Edit the configuration file
    • doas emerge -aq x11-misc/picom # Install the package
    • Make the changes effective
      • ps aux | grep picom # Get the PID
      • kill yourPID # Kill it
      • picom & # Enable it again
  • References
    • https://philipj.ydns.eu/stagit/dotfiles/file/i3/picom.conf.html
    • https://config.phundrak.com/picom.html
    • https://wiki.gentoo.org/wiki/Picom

  • Add a #patch in [[Gentoo Linux]]

    • doas mkdir -p /etc/portage/patches/x11-terms/st-0.8.5/
    • doas cp ~/st-alpha-0.8.5.diff /etc/portage/patches/x11-terms/st-0.8.5/
    • cd /usr/portage/x11-terms/st/
    • doas ebuild ./st-0.8.5.ebuild clean prepare
    • doas mv /etc/portage/patches/x11-terms/st-0.8.5/st-alpha-0.8.5.diff /tmp/
    • doas emerge -q x11-terms/st
  • Notes
    • cd /usr/portage/x11-terms/st/ # Change the package's ebuild repository
    • doas mv /etc/portage/patches/x11-terms/st-0.8.5/st-alpha-0.8.5.diff /tmp/ # Remove the patch from the directory (Prevent compilation failure)
  • References
    • https://st.suckless.org/patches/alpha/
    • /etc/portage/patches - Gentoo Wiki

  • Set prompt for Bash

    • doas emerge -q app-shells/starship # Install Starship
    • vim ~/.bashrc # Setup the Shell (Bash) to use Starship
      eval "$(starship init bash)"
      
    • starship preset plain-text-symbols > ~/.config/starship.toml # Configure Starship
  • Notes
    • After using Starship for a while, I think the default is the best.
      • To keep it maintainable on Linux servers.
  • References
    • 2023-01-12_19-07.png
    • demo.gif
    • https://github.com/starship/starship

  • Add a ebuild repository in Gentoo Linux

    • eselect repository list
    • doas eselect repository enable augaina
    • doas emaint sync -r zugaina
    • doas emerge -aq media-fonts/nerd-fonts
  • Notes
    • eselect repository list -i # List installed
      • -i # Installed
    • doas eselect repository remove zugaina # Remove the ebuild repository
  • References
    • man repository.eselect
    • eselect/repository - Gentoo Wiki

  • Extract a ".zip" file

    • unzip FiraCode.zip
  • Notes
    • -O GB18030 # If file name displays garbled characters
    • -d ./FiraCode/ # An optional directory to which to extract files
    • nix profile install nixpkgs#unzip # Install dependencies
      • Warning: This -O option is no longer supported on March 24, 2024 when using Nix.
      • doas pacman --sync unzip # Install dependencies to solve the problem
    • python # Another method
      >>> import zipfile
      >>> with zipfile.ZipFile('archive.zip', 'r') as zip_ref:
      ...     zip_ref.extractall()
      ... 
      >>> 
      
  • References
    • 2023-01-12_18-32.png
    • https://stackoverflow.com/questions/28249384/decompress-zip-with-given-encoding/45583116#45583116
    • man unzip # /-d
    • ChatGPT

  • Set random wallpaper with #Feh

    • crontab -e
      * * * * * DISPLAY=":0.0" feh --randomize --bg-fill ~/app/wallpaper/*
      
  • Notes
    • * * * * * # Every minute
  • References
    • https://github.com/antoniosarosi/Wallpapers
    • https://github.com/inigochoa/wallpapers
    • https://github.com/goatfiles/wallpapers
    • https://wiki.gentoo.org/wiki/Feh

  • Use "feh"

    • Fill window
      • feh --keep-zoom-vp {1..9}.jpg
      • feh --zoom 80 {1..9}.jpg
      • feh --scale-down {1..9}.jpg # View them with automatically zoon
    • feh --bg-fill $HOME/note/assets/dark.jpg # Set wallpaper
    • n / space # Next image
    • ! # Zoom the image to fill the size of window (like --bg-fill)
    • Alt-upArrow # Scroll up one page
    • feh /mnt/grow/220824wallpaper/ # Enable slideshow mode
      • Ctrl-upArrow # Move up
      • leftArrow # Previous image
      • upArrow # Zoom in
      • Ctrl-Delete # Delete the current image
  • Notes
    • vim ~/.config/feh/themes # Set the background to black
      feh --image-bg black
      
      • mkdir ~/.config/feh/ # Make the directory If you don't have it
    • d # Draw filename
    • /mnt/grow/220824wallpaper/ # Replace it with your directory including wallpaper
      • http://192.168.10.100:5244/d/grow/2023-06-06/230605takeTheAdmissionTicketAboutExamination.jpg # Use URL of image (Another way)
    • feh -i /mnt/grow/220824wallpaper/ # Index
    • feh -m /mnt/grow/220824wallpaper/ # Montage
    • feh -t /mnt/grow/220824wallpaper/ # Thumbnails
    • feh -w /mnt/grow/220824wallpaper/ # Multiwindow
    • feh -l /mnt/grow/220824wallpaper/ # List
  • References
    • 2023-01-27_18:14:43.gif
    • https://unix.stackexchange.com/questions/426526/how-to-permanently-set-default-color-of-fehs-background-to-black/673439#673439
    • https://unix.stackexchange.com/questions/255693/how-do-i-delete-images-from-disk-using-feh/255697#255697
    • https://wiki.gentoo.org/wiki/Feh
    • man feh # /ctrl\+delete

  • [[Zoom in]] is enlarge #Idea

    • in # Near big

  • Use "dotfiles"

    • First use
      git init --bare $HOME/.dotfiles
      echo "alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME/'" >> $HOME/.bashrc
      source ~/.bashrc
      dotfiles config --local status.showUntrackedFiles no
      dotfiles status
      dotfiles add .bashrc
      dotfiles commit -m "Add .bashrc"
      dotfiles remote add origin git@github.com:yaoniplan/dotfiles.git
      dotfiles push -u origin master
      
    • Second machine
      git clone --bare https://github.com/yaoniplan/dotfiles.git $HOME/.dotfiles
      echo "alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME/'" >> $HOME/.bashrc
      source ~/.bashrc
      dotfiles checkout
      dotfiles config --local status.showUntrackedFiles no
      
  • Notes
    • git clone --branch development git@100.65.173.16:/var/git/diary.git/ ~/.config/diary/ # Clone development branch to ~/.config/diary/ directory
    • dotfiles config --local status.showUntrackedFiles no # Hide untracked files
    • Replace ".bashrc" with your file name (e.g. .zshrc)
    • Replace "yaoniplan" with your user name
  • References
    • https://fwuensche.medium.com/how-to-manage-your-dotfiles-with-git-f7aeed8adf8b
    • https://medium.com/@simontoth/best-way-to-manage-your-dotfiles-2c45bb280049

  • Replace /etc/environment with ~/.bash_profile in #Linux

    • vim ~/.bash_profile
      # Set proxy
      export http_proxy="127.0.0.1:7890"
      export https_proxy="127.0.0.1:7890"
      export no_proxy="localhost, 127.0.0.1"
      
      • Put them at the top of the file
  • Notes
    • Advantages
      • Set environment permanently
      • Prevent /etc/environment file from being initialized


  • 1 inch = 2.54 centimeters #Idea

  • Notes
    • 0.5 inch = 1.27 centimeters
  • References
    • 2023-01-08_18-37.png

  • Use #todotxt in #Linux

    • todocli add "Buy soap" # Add it to todo.txt file
    • todocli list # List todo
    • todocli done 1 # Mark 1 done
    • todocli replace 1 "Buy some soap" # Replace a task
    • todocli pri 4 A # Prioritize task (4) to the highest level (A)
    • todocli append 10 "https://wiki.gentoo.org/wiki/Neofetch" # Append task (10) text to the end of the line
    • todocli depri 7 # Deprioritize (remove the priority) task (7)
    • todocli help # Display help
  • Notes
    • todocli # An alias
      • vim ~/.bashrc
        alias todocli=todo.sh
        complete -F _todo todocli
        
        • source ~/.bashrc # Make changes effective
  • References
    • 2023-01-08_16-55.png
    • t -h
    • Todo.txt CLI Manages Your Tasks from the Command Line

  • Install #todotxt in [[Gentoo Linux]]

    • doas emerge -aq app-misc/todo
    • bzcat /usr/share/doc/todo-2.12.0-r2/todo.cfg.bz2 > ~/.todo/config
  • Notes
    • Clik this link If you have a question about "have been masked"
    • bzcat /usr/share/doc/todo-2.12.0.r2/todo.cfg.bz2 > ~/.todo/config
      • mkdir ~/.todo/ # Make the directory if you don't have it
  • References
    • 2023-01-08_16-14.png
    • Fresh brew install fails with Fatal Error: Cannot read configuration file /Users/me/.todo/config · Issue #252 · todotxt/todo.txt-cli

  • Choose a toothbrush

    • bristles head handle no reason to return
  • Notes
    • soft bristles
      • Protect teeth and gums
    • small head
      • Reach hard-to-reach places (e.g. back teeth)
    • non-slip handle
    • optional: powered toothbrush
      • Make brushing easier
    • Using
      • Replace the brush head every 3 months (or when the bristles begin to show wear)
        • Replace # Bristles may trap bacteria leading to reinfection
      • Don't brush teeth sideways, brush up and down
  • References
    • How to Choose a Toothbrush
    • https://github.com/yaoniplan/note/issues/17#issue-1464378817

  • The abbreviation of "potential of hydrogen" is "pH".

  • References
    • 2023-01-08_09-36.png
    • https://en.wikipedia.org/wiki/PH

  • Choose a soap

    • pH fatty acids glycerin
  • Notes
    • Sensitive skin
      • No artificial fragrances
      • No alcohol
      • No sulfates
  • References
    • https://skinkraft.com/blogs/articles/how-to-choose-the-right-soap-for-your-skin-type#:~:text=Look%20for%20ingredients%20like%20salicylic,your%20soap%20is%20non%2Dcomedogenic.
  • Downgrade for software in [[Gentoo Linux]]

    • doas emerge =media-gfx/flameshot-11.0.0
  • Notes
    • =media-gfx/flameshot-11.0.0
      • equery list -po flameshot # Check what package versions are available
        • -p # Portage-tree
        • -o # Overlay-tree
  • References
    • 2023-01-06_16-43.png
    • 2023-01-06_16-46.png
    • man equery
    • linux - How to select the software's version in gentoo by emerge? - Stack Overflow

  • Set a proxy for the phone when the phone does not have proxy software

    • HTTP (e.g. web browser)
      • Proxy settings: Manual
      • Proxy hostname: 192.168.10.107
      • Proxy port: 7890
    • Socks5 (e.g. Telegram)
      • Server: 192.168.10.107
      • Port: 7891
  • Notes
    • 192.168.10.107
      • ip address # Get computer IP address
        inet 192.168.10.107/24 brd 192.168.10.255 scope global dynamic noprefixroute eno1
        
    • Advantages
      • Faster than using mobile proxy software
    • Disadvantages
      • Keep computer on
  • References
    • 2023-01-06_15-24.png
    • Screenshot_2023-01-06-15-06-20-28.png
    • Screenshot_2023-01-06-15-10-38-45.png

  • The abbreviation of "Portable Network Graphics" is "PNG".

    • A format
    • Lossless
  • References
    • 2023-01-05_11-55.png
    • https://en.wikipedia.org/wiki/Portable_Network_Graphics

  • Print system information in Shell

    • uname --all # Print all information
  • Notes
    • Because to print which operating system I am using.
  • References
    • 2023-01-04_16-27.png
    • man uname


  • Reasons for the air switch to trip: overload protection, circuit short circuit and leakage. #idea

  • References
    • 2023-01-03_10-21.png
    • Cause analysis and treatment of air switch trip | Quisure Circuit Breaker

  • Eating fried food can seriously damage body organs (e.g. mouth, throat, etc.). #idea


  • Check dependencies of a package in Gentoo Linux

    • equery g x11-misc/cdm
  • Notes
    • equery g x11-misc/cdm
      • g # graph
      • emerge --search CDM # Search in ebuild repository if you don't know its full name
  • References
    • 2022-12-31_09-59.png
    • 2022-12-31_10-07.png
    • equery --help
    • man emerge
    • https://wiki.gentoo.org/wiki/Equery

  • Write a conditional judgment in Linux Bash

    • if [[ "$numberOfFiles" -gt 30 ]]; then
  • Notes
    • -gt # Greater than
  • References
    • ChatGPT

  • Dust damages the lungs. #Idea


  • Execute a script at boot time in [[Gentoo Linux]] with #OpenRC

    • doas vim /etc/local.d/script.start
    • doas chmod a+x /etc/local.d/script.start
  • Notes
    • doas vim /etc/local.d/script.start
      #!/usr/bin/env bash
      
      # Set the brightness to 20% (976/4882)
      echo 976 > /sys/class/backlight/intel_backlight/brightness
      
      • A script about brightness
  • References
    • 2022-12-28_15-54.png
    • https://wiki.gentoo.org/wiki//etc/local.d
    • https://unix.stackexchange.com/questions/30924/how-do-i-set-default-brightness-after-boot

  • The #abbreviation of [[Et Cetera]] is #etc in #Linux.

  • References
    • 2022-12-27_11-15.png
    • Et cetera - Wikipedia

  • Write a #Shell script in #Linux

    • vim dotfiles.sh
      #!/usr/bin/env sh
      
  • Notes
    • ./dotfiles.sh # Execute the script
      • chmod u+x dotfiles.sh # Solve a problem about permission denied
  • References
    • 2022-12-27_10-33.png

  • Check when a #GitHub account was created

    • https://api.github.com/users/yaoniplan
  • Notes
    • api. # Add it before github.com/
    • users/ # Add it after github.com/
    • yaoniplan # Replace it with a name of user
  • References
    • 2022-12-26_11-31.png
    • 2022-12-26_11-32.png
    • Where can we check how old is a github account ? : github- #### The punctuation of "tilde" is "~".
  • References
    • https://en.wikipedia.org/wiki/Tilde

  • Use "ln"

    • ln --symbolic ~/.config/i3/config ./i3/config
      • ln # Link
  • Notes
    • unlink ./i3/config # Remove a symbolic link
    • ~/.config/i3/config # A hard link
    • ./i3/config # A symbolic link
      • mkdir ./i3/ # Make a directory before using the ln command
    • Optional: Check the symbolic link and the hard link
      • ls -l ./i3/config
    • Because to make a symbolic link on Linux.
  • References
    • 2022-12-25_15-44.png
    • 2022-12-25_15-47.png
    • 2022-12-25_16-11.png
    • man ln
    • https://www.freecodecamp.org/news/dotfiles-what-is-a-dot-file-and-how-to-create-it-in-mac-and-linux/

  • Use "tmux"

    • C-b [ # Enter copy mode
    • C-b , # Rename the current window
    • C-b C-o # Move lower pane up (Make sure the cursor is in the up pane)
    • C-b { # Move the current pane up
    • C-b ! # Break pane to a window
    • C-b z # Zoom (Make a pane larger or smaller)
    • C-b ? # Help
    • C-b w # Windows of tree mode
    • C-b c # Create a window
      • C-b l # Last window (previously used)
    • C-b " # Split down (Split right: C-b %)
      • C-b ; # Last pane (previously used)
    • C-b space # switch to the next layout
    • C-b : # Prompt for a command (Vim-like)
      • bind-key f display-popup -w 50 -h 30 -E "tmux new -s popup" # Bind a key C-b f temporarily
      • new-window # New a window
      • kill-pane # The same as C-b x
      • join-pane -t 1 # Join pane
      • break-pane # Break pane to a window
      • move-window -t 2:2 # Move window to another session
      • kill-session -t 15 # Kill session target 15
      • kill-window -t 1 # Kill window 1
      • kill-pane -t 1 # Kill pane 1
      • C-b arrowKey # Change the active pane
      • split-window -h # Horizontal
      • split-window -v # Vertical
      • attach -t 1 # attach session 1
      • rename-session 0 # Rename session (active) to 0
      • rename-window 1 # Rename window (active) to 1
      • source-file ~/.tmux.conf # Reload the Tmux configuration file
  • Notes
    • vim ~/.tmux.conf
      # Toggle floating scratchpad
      # Bind a key
      bind-key -n M-Space if-shell -F '#{==:#{session_name},scratch}' {
          detach-client
      } {
          display-popup -E -w 100% -h 50% "tmux new-session -A -s scratch"
      }
      
      • M-Space # Replace it with your desired key (e.g. M-f)
      • scratch # Replace it with your desired name (e.g. fzf)
      • display-popup -E "tmux new-session -A -s fzf 'ls ~/.local/bin/ | fzf | sh'" # Interact with fzf
      • -w 100% -h 50% # Customize the width and height (Optional)
    • vim ~/.tmux.conf
      # Hide status bar to show more space
      set -g status off
      
      • -g # Global
    • vim ~/.tmux.conf
      # Retain more history when scrolling up
      set -g history-limit 50000
      
    • vim ~/.tmux.conf # Copy text from tmux to clipboard in Linux
      # Enable Vi mode
      set -g mode-keys vi
      bind -T copy-mode-vi 'v' send -X begin-selection
      bind -T copy-mode-vi 'C-v' { send -X begin-selection ; send -X rectangle-toggle }
      bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -selection clipboard"
      
      • Ctrl-v # Visual block mode (Default: Ctrl-b [ v Ctrl-v)
      • doas emerge -aq x11-misc/xclip # Install in Gentoo Linux
      • xclip -selection clipboard # Replace it with wl-copy on Wayland
    • vim ~/.tmux.conf # Avoid triggering bound keys accidentally
      # Set the escape time to 0
      set -sg escape-time 0
      
      • -s # Sessions
    • vim ~/.tmux.conf # Solve a problem about join-pane -t 0
      # Set the base index to one
      set -g base-index 1
      
    • tmux ls # List all sessions
      • ls # list-sessions
    • tmux attach-session -t 1 # Attach session 1
    • tmux kill-server # kill all server (e.g. sessions, windows, and panes)
  • References
    • https://github.com/tmux/tmux/blob/c07e856d244d07ab2b65e72328fb9fe20747794b/regress/conf/01840240e807e837dbf76d85b4b938de.conf#L805
    • https://github.com/tmux/tmux/issues/992
    • https://libreddit.nohost.network/r/tmux/comments/129ct3a/is_there_a_way_to_pin_a_slipt_pane/
    • man tmux # /mode-keys
    • tmux_status_line_diagram.png
    • https://wiki.gentoo.org/wiki/Tmux
    • https://github.com/jbranchaud/til/blob/master/tmux/break-current-pane-out-to-separate-window.md
    • https://leimao.github.io/blog/Tmux-Tutorial/
    • https://gist.github.com/russelldb/06873e0ad4f5ba1c4eec1b673ff4d4cd
    • https://github.com/tmux/tmux/wiki/Getting-Started
    • https://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting-ubuntu/
    • ChatGPT

  • Replace sudo with doas in Gentoo Linux

    • sudo emerge -aq app-admin/doas
    • sudo vim /etc/doas.conf
    • sudo vim ~/.bashrc
  • Notes
    • sudo vim /etc/doas.conf
      # Allow all users in the wheel group to execute any command as root
      permit :wheel
      
      # Allow a user to use a command (e.g. reboot, poweroff, etc.) without a password
      permit nopass yaoniplan cmd reboot
      permit nopass yaoniplan cmd poweroff
      
    • sudo vim ~/.bashrc # Configure completion for doas
      complete -cf doas
      
    • su root # Substitute root if your doas doesn't work
  • References
    • https://wiki.gentoo.org/wiki/Doas

  • The abbreviation of "application programming interface" is "API".

    • A way
    • To communicate
  • References
    • https://en.wikipedia.org/wiki/API

  • The abbreviation of "Advanced Linux Sound Architecture" is "ALSA".

    • A software framework
  • References
    • 2022-12-22_09-37.png
    • https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture

  • Set USE flag temporarily in [[Gentoo Linux]]

    • sudo USE="minimal" emerge -aq media-libs/libsndfile
    • sudo USE="-pulseaudio" emerge -aq media-sound/mpg123
    • sudo emerge -aq pulseaudio
  • Notes
    • If you have the problem
      It might be possible to break this cycle
      by applying any of the following changes:
      - media-libs/libsndfile-1.1.0-r1 (Change USE: +minimal)
      - media-sound/mpg123-1.31.1 (Change USE: -pulseaudio)
      
      Note that this change can be reverted, once the package has been installed.
      
      Note that the dependency graph contains a lot of cycles.
      Several changes might be required to resolve all cycles.
      Temporarily changing some use flag for all packages might be the better option.
      
    • sudo USE="minimal" emerge -aq media-libs/libsndfile
      • USE="minimal" # Add it between sudo and emerge
    • sudo USE="-pulseaudio" emerge -aq media-sound/mpg123
      • - # Cancel
  • References
    • 2022-12-22_08-31.png
    • USE flag - Gentoo Wiki

  • The #abbreviation of /var is #variable in #Linux. #Idea

  • References
    • 2022-12-21_11-28.png

  • Use ebuild repository in Gentoo Linux

    • doas eselect repository create test
    • doas mkdir -p /var/db/repos/test/app-misc/logseq/
    • doas vim /var/db/repos/test/app-misc/logseq/logseq-0.8.8.ebuild
    • doas chown -R portage:portage /var/db/repos/test/
    • cd /var/db/repos/test/app-misc/logseq/
    • doas ebuild ./logseq-0.8.8.ebuild manifest
    • sudo emerge -aq app-misc/logseq
  • Notes
    • doas eselect repository create test # Create an empty ebuild repository named test
      • doas emerge -aq app-eselect/eselect-repository # Install it if you don't have it
    • doas vim /var/db/repos/test/app-misc/logseq/logseq-0.8.8.ebuild # Create the ebuild file named logseq-0.8.8
      • logseq-0.8.8.ebuild
        
        # Copyright 1999-2022 Gentoo Authors
        # Distributed under the terms of the GNU General Public License v2
        
        

        EAPI=8

        inherit unpacker

        DESCRIPTION="A privacy-first, open-source platform for knowledge management and collaboration" HOMEPAGE="https://logseq.com/" SRC_URI="https://github.com/logseq/logseq/releases/download/${PV}/Logseq-linux-x64-${PV}.zip" S="${WORKDIR}"

        LICENSE="GNU Affero General Public License v3.0"

        SLOT="0" KEYWORDS="~amd64"

        IUSE=""

        #RESTRICT="strip"

        RDEPEND=""

        DEPEND="${RDEPEND}"

        BDEPEND=""

        src_unpack() { unpack_zip ${A} }

        src_install() {

        dodir "/opt/logseq"
        insinto "/opt/logseq"
        cd "${WORKDIR}/Logseq-linux-x64/"
        doins -r "."
        fperms +x "/opt/logseq/Logseq"
        cd "/opt/logseq"
        
        dosym "/opt/logseq/Logseq" "/usr/bin/Logseq"
        

        }

      • app-misc/ # A category (e.g. app-misc, app-editors, etc.) directory

      • logseq/ # A package (e.g. logseq, vim, etc.) directory

      • 0.8.8 # A package version (e.g. 0.8.8, 9.0.0099, etc.)

    • doas chown -R portage:portage /var/db/repos/test/
      • portage:portage # root:root
    • doas ebuild ./logseq-0.8.8.ebuild manifest # Create the package's manifest file
      • Faster than doas pkgdev manifest
  • References
    • 2023-01-12_15-29.png
    • https://wiki.gentoo.org/wiki/Repository_format/package/Manifest
    • https://raw.githubusercontent.com/jacksongodsey/gentoo-ebuilds/master/logseq-bin-0.8.8.ebuild
    • https://wiki.gentoo.org/wiki/Creating_an_ebuild_repository

  • Understand an #idiom about #惨不忍睹. #idea

  • Notes
    • 睹 # Look with eyes
  • References
    • 2022-12-19_16-43.png
    • https://www.chinesewords.org/idiom/show-3093.html

  • Check the file size of a directory in #Linux

    • du -sh note/
  • Notes
    • du # Device usage
    • -s # --summarize
    • -h # --human-readable
    • note/ # a directory
  • References
    • 2022-12-19_15-42.png
    • 2022-12-19_15-40.png
    • man du

  • Create a .desktop file for application in Linux

    • sudo vim /usr/share/applications/logseq.desktop
      [Desktop Entry]
      Encoding=UTF-8
      Version=1.0
      Type=Application
      Terminal=false
      Exec=/usr/bin/Logseq
      Name=Logseq
      Icon=logseq
      
  • Notes
    • Exec=/usr/bin/Logseq # Replace /usr/bin/Logseq with a executable path of application
    • Name=Logseq # Replace logseq with a name of application
  • References
    • 2022-12-19_15-24.png
    • https://www.maketecheasier.com/create-desktop-file-linux/

  • The #abbreviation of #initialization is #init. #Idea
  • Notes
    • A daemon process
  • Refernces
    • 2022-12-18_18-42.png
    • init - Wikipedia

  • Understand the #OpenRC #Idea
  • Notes
    • A #init system
  • References
    • 2022-12-18_18-44.png
    • https://en.wikipedia.org/wiki/OpenRC

  • Use "OpenRC"

    • doas rc-service display-manager status
    • doas rc-service display-manager start
    • doas rc-update del display-manager default
    • doas rc-update add display-manager default
  • Notes
    • dispaly-manager # Replace it with your service
    • del # Delete
    • /etc/init.d/display-manager # The same as rc-service display-manager
  • References
    • https://wiki.gentoo.org/wiki/OpenRC_to_systemd_Cheatsheet

  • Modify brightness in Gentoo Linux

    • sudo emerge -aq sys-power/acpilight
    • sudo usermod -a -G video yaoniplan
    • sudo vim /etc/udev/rules.d/90-backlight.rules
      # Allow video group to control backlight and leds
      SUBSYSTEM=="backlight", ACTION=="add", \
        RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness", \
        RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
      SUBSYSTEM=="leds", ACTION=="add", KERNEL=="*::kbd_backlight", \
        RUN+="/bin/chgrp video /sys/class/leds/%k/brightness", \
        RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
      
  • Notes
    • sudo usermod -a -G video yaoniplan
      • mod # Modify
      • -a # --append
      • -G # --groups
      • video # a name of group
      • yaoniplan # Replace it with your name of user
  • References
    • 2022-12-17_20-41.png
    • 2022-12-17_20-22.png
    • man usermod
    • https://linuxize.com/post/how-to-add-user-to-group-in-linux/
    • https://gitlab.com/wavexx/acpilight

  • Remove packages form the operating system in Gentoo Linux

    • sudo emerge -c x11-apps/xbacklight
  • Notes
    • -c # Depclean
  • References
    • man emerge
    • 2022-12-17_19-07.png
    • 2022-12-17_19-09.png
    • https://unix.stackexchange.com/questions/42783/safely-uninstall-a-package-in-gentoo
    • https://wiki.gentoo.org/wiki/Handbook:AMD64/Full/Working#Removing_software

  • Update the whole system in Gentoo Linux

    • doas emerge --sync # Update the package list
    • doas emerge -avuDN @world
  • Notes
    • -a # --ask
    • -v # --verbose
    • -u # --update
    • -D # --deep
    • -N # --newuse
    • If you have the problem
      !!! existing preserved libs:
      >>> package: x11-libs/libdrm-2.4.114
           *  - /usr/lib64/libdrm_amdgpu.so.1
           *  - /usr/lib64/libdrm_amdgpu.so.1.0.0
           *      used by /usr/lib64/xorg/modules/drivers/amdgpu_drv.so (x11-drivers/xf86-video-amdgpu-22.0.0)
          Use emerge @preserved-rebuild to rebuild packages using these libraries
           * After world updates, it is important to remove obsolete packages with
           * emerge --depclean. Refer to `man emerge` for more information.
      
      • sudo emerge --depclean # Remove obsolete packages
      • sudo emerge @preserved-rebuild # Clean up the old library version
    • Solve the problem
       * IMPORTANT: 5 config files in '/etc' need updating.
       * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS
       * sections of the emerge man page to learn how to update config files.
       * After world updates, it is important to remove obsolete packages with
       * emerge --depclean. Refer to `man emerge` for more information.
      
      • doas etc-update # Update all config files in '/ect'
      • doas emerge --depclean # Remove obsolete packages
      • doas reboot
  • References
    • 2022-12-17_18-41.png
    • man emerge
    • https://wiki.gentoo.org/wiki/Upgrading_Gentoo
    • https://wiki.gentoo.org/wiki/Preserved-rebuild

  • The abbreviation of the "Unicode Transformation Format - 8-bit" is the "UTF-8". #Idea

  • Notes
    • An encoding
  • References
    • 2022-12-17_10-35.png
    • https://en.wikipedia.org/wiki/UTF-8

  • Understand the #LLVM. #Idea

  • Notes
    • A #compiler
    • It took about four hours to compile the sys-devel/llvm in [[Gentoo Linux]]. (e.g. 15:50-20:07)
  • References
    • 2022-12-17_09-45.png
    • 2022-12-17_09-47.png
    • LLVM - Wikipedia

  • The #abbreviation of the [[Good Game]] is #GG. #Idea

  • Notes
    • A #slang
    • Used at the end of a gaming match commonly
  • References
    • 2022-12-17_09-14.png
    • GG - Wiktionary

  • The #abbreviation of the [[computed tomography scan]] is [[CT scan]] . #Idea

  • References
    • 2022-12-17_09-05.png
    • CT scan - Wikipedia

  • The abbreviation of the "identity document" is "ID". #Idea

  • References
    • 2022-12-17_08-49.png
    • https://en.wikipedia.org/wiki/Identity_document

  • Check screen resolution in Linux

    • cat /sys/class/graphics/fb0/modes
  • References
    • 2022-12-16_17-22.png
    • 2022-12-16_17-25.png
    • https://superuser.com/questions/196532/how-do-i-find-out-my-screen-resolution-from-a-shell-script

  • Display backticks in the code block of #Markdown

    • import -window root `date +%F_%T`.png
  • Notes
    • import -window root `date +%F_%T`.png # Output
    • Add two backticks to the left of the content; add two backticks to the right of the content.
      • Sometimes: Replace two backticks with two backticks and a space; Replace two backticks with a space and two backticks
  • References
    • image.png
    • image.png
    • https://linuxhint.com/escape-backtick-markdown/

  • I am trying to use #GIF in #Markdown files. #Idea

  • Take a screenshot with the #import command from #ImageMagick #application

    • import -window root screenshot.png # Take a picture of the whole screen
    • import screenshot.png # Take a picture of the selected part
  • Notes
    • sleep 5; import -window root screenshot.png # Delay five seconds before taking a picture
    • import -window root `date +%F_%T`.png # Image file named by time
      • %F # Full date (e.g. 2022-12-13)
      • %T # Time (e.g. 15:15:03)
    • import -window 0x1a00002 `date +%F_%T`.png # Take a picture of a single window you want
      • 0x1a00002 # A window ID
      • xwininfo # Get the window ID
        • sudo emerge -aq x11-apps/xwininfo # Install it if you don't have it
  • References
    • image.png
    • image.png
    • https://www.oreilly.com/library/view/linux-multimedia-hacks/0596100760/ch01s02.html
    • https://dev.to/fmtweisszwerg/how-to-capture-a-screenshot-of-the-single-window-you-want-using-command-line-59hc#:~:text=To%20capture%20a%20screenshot%20of%20the%20selected%20window%20using%20import,ID%22%20with%20%2Dwindow%20option.&text=Finally%2C%20the%20screenshot%20is%20saved%20in%20the%20current%20directory!

  • The #abbreviation for #kilo is #k. #idea

  • Notes
    • #Kilo is one thousand
  • References
    • image.png
    • image.png
    • K - Wikipedia

  • Use "clash"

    • chmod u+x clash-linux-amd64-v1.12.0 # Add user executable permission
      • https://web.archive.org/web/20231003084307/https://github.com/Dreamacro/clash/releases
    • sudo mv clash-linux-amd64-v1.12.0 /usr/local/bin/clash # Execute anywhere
    • mv yourClashConfig.yaml ~/.config/clash/config.yaml # Use your own configuration file
    • clash # Initialize and enable clash
      • https://clash.razord.top/
      • https://yacd.haishan.me/
  • Notes
    • vim ~/.config/clash/config.yaml # Select server automatically
      - name: "auto"
        type: url-test
        proxies:
          - ss1
        url: 'http://www.gstatic.com/generate_204'
        interval: 300
      
      • ss1 # Replace it with other proxy
    • vim ~/.bashrc # Edit it on other machines
      setProxy() {
          export http_proxy="192.168.10.105:7890"
          export https_proxy="192.168.10.105:7890"
          export no_proxy="localhost, 127.0.0.1"
      }
      
      unsetProxy() {
          unset http_proxy https_proxy no_proxy
      }
      
      • source ~/.bashrc # Remember to make it effective
      • setProxy # Enable proxy temporarily
      • unsetProxy # Disable proxy temporarily
    • Set environment globally
      • sudo vim /etc/environment
        # Proxy
        export http_proxy="127.0.0.1:7890"
        export https_proxy="127.0.0.1:7890"
        export no_proxy="localhost, 127.0.0.1"
        
    • Solve the problem about address already in use
      ERRO[0438] Start Mixed(http+socks) server error: listen tcp 127.0.0.1:7890: bind: address already in use
      
      • Use "lsof"
      • nix profile install nixpkgs#lsof # Install dependencies
      • lsof -i :7890 # Get the PID (ps aux | grep clash)
      • kill yourPID # Replace yourPID with PID you got
  • References
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • 2023-01-12_14-32.png
    • https://github.com/Hackl0us/SS-Rule-Snippet
    • https://cdn.jsdelivr.net/gh/Hackl0us/SS-Rule-Snippet@master/LAZY_RULES/clash.yaml
    • https://web.archive.org/web/20231130214526/https://skyao.io/learning-linux-mint/docs/daily/network/clash.html

  • The #abbreviation for the "solid-state drive" is "SSD". #idea

    • A storage device
  • References
    • image.png
    • Solid-state drive - Wikipedia

  • Set CSS for Vimium UI permanently

    • vim vimium-1.67.4/content_scripts/vimium.css # Edit the file after downloading form source code
      div.internalVimiumHintMarker {
        position: absolute;
        display: block;
        top: -1px;
        left: -1px;
        white-space: nowrap;
        overflow: hidden;
        font-size: 11px;
        padding: 1px 3px 0px 3px;
        background: linear-gradient(to bottom, #000000 100%,#FFC542 100%);
        border: solid 0px #C38A22;
        border-radius: 3px;
        box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.3);
      }
      
      • image.png
    • Edit CSS for Vimium UI options of #extension
      div > .vimiumHintMarker {
      /* linkhint boxes */
      background: -webkit-gradient(linear, left top, left bottom, color-stop(100%,#000000),
        color-stop(100%,#FFC542));
      border: 0px solid #E3BE23;
      }
      
      div > .vimiumHintMarker span {
      /* linkhint text */
      color: black;
      font-weight: bold;
      font-size: 12px;
      }
      
      div > .vimiumHintMarker > .matchingCharacter {
      }
      
      • image.png
  • Notes
    • Theses two places (vimium.css and CSS for Vimium UI) must be changed, otherwise it will not work sometimes.
  • References
    • image.png
    • image.png
    • https://github.com/philc/vimium/issues/3418#issuecomment-547781986

  • Remember What G does in #Vim #Idea

    • G is bigger than g
    • So it's heavy and sinks to the bottom
  • References
    • image.png
    • Why aren't gg and G switched? : vim- Set some aliases for pages in #Logseq
    • Type this code (alias:: extensions) on the first block of the page and replace extensions with your alias
  • Notes
    • What is alias?
    • This means merging pages with the same meaning.
  • References
    • image.png
    • image.png
    • The Ultimate Guide to Aliases in Logseq | Aryan Sawhney

  • Disable all hotkeys except itself for the Global Speed extension

    • Shift q # Press the Shift key and q key together
  • Notes
    • Volumn control
      • Audio Effects selection - gain - 1.5
      • Adjust the video's volume slider to change the default volume
      • https://github.com/polywock/globalSpeed/issues/196#issuecomment-1109283484
      • https://github.com/polywock/globalSpeed/issues/292#issuecomment-1343084217
    • Create a "state" in "Shortcut Editor" # Another way
      • Click on "NoKey" and press your desired shortcut key (e.g. Alt-s)
    • except itself # This means enabling the hotkey (Shift q) only
    • Global Speed # A Google Chrome extension to set the speed of web pages
      • Ctrl-m # Mute
    • Shift q # To avoid hotkeys conflicts with other extension (e.g. Vimium )
  • References
    • image.png
    • image.png
    • https://github.com/polywock/globalSpeed

  • Stop forgetting to breathe #Idea

    • Exhale on the effort
  • References
    • image.png
    • Don't Forget to Breathe - YouTube
  • Enable spell checker in the #Logseq #application

    • A red underline will be displayed when the spelling is wrong.
  • References
    • image.png
    • image.png

  • I am trying to use Grammarly to revise a wordy sentence. #Idea

    • I am trying to test it, but it does not work in Logseq.
    • Test again.
    • Don't support the #Logseq website.
    • Support the [[Google Translate]] website.
    • Membership is required sometimes.
  • References
    • image.png
    • image.png
    • https://chrome.google.com/webstore/detail/grammarly-grammar-checker/kbfnbcaeplbcioakkpcpgfkobkghlhen

  • I am trying to use Wordeep to revise a wordy sentence. #Idea

    • Do not support #Markdown sometimes.
    • Support the #Logseq website.
  • References
    • https://chrome.google.com/webstore/detail/wordeep-proofreading/olmmaccabblmaegeofmeidedoahadlkp

  • I am trying to use Quillbot to revise a wordy sentence. #Idea

    • Do not support #Markdown.
    • Support the #Logseq website.
  • References
    • image.png
    • https://chrome.google.com/webstore/detail/quillbot-for-chrome/iidnbdjijdkbmajdffnidomddglmieko

  • I am trying to use ProWritingAid to revise a wordy sentence. #Idea

    • Support the #Logseq website.
    • Do not support #Markdown sometimes.
  • References
    • https://chrome.google.com/webstore/detail/prowritingaid-grammar-che/npnbdojkgkbcdfdjlfdmplppdphlhhcf

  • I am trying to use LanguageTool to revise a wordy sentence. #Idea

    • Support the #Logseq website.
    • Support #Markdown.
    • Need to manually add some proper nouns sometimes.
    • Membership is required sometimes.
  • References
    • image.png
    • https://chrome.google.com/webstore/detail/grammar-spell-checker-%E2%80%94-l/oldceeleldhonbafppcapldpdifcinji

  • I am trying to use Ginger to revise a wordy sentence. #Idea

    • Support the #Logseq website.
    • Support #Markdown sometimes.
    • Don't support [[Google Translate]].
  • References
    • image.png
    • https://chrome.google.com/webstore/detail/grammar-and-spelling-chec/kdfieneakcjfaiglcfcgkidlkmlijjnh
  • The abbreviation of the "European Union" is "EU".

    • In Europe
    • A union
    • 27 member states
  • References
    • image.png
    • https://en.wikipedia.org/wiki/European_Union

  • Copy text from Vim to external application without using mouse

    • Shift-v # Visual line mode
    • "+y # Copy text from Vim
    • Ctrl-v # Paste text to external application (e.g. web browser, instant messaging, etc.)
  • Notes
    • "+y # Means pressing ", + and y one by one
      • y # Yank
    • If your clipboard is not working
      • :version # Check the clipboard feature in Vim 2022-12-17_16-09.png
      • doas apt install vim-gtk3 # In Debian-based distribution
      • doas pacman -S gvim # In Arch Linux
      • sudo vim /etc/portage/package.use/zz-autounmask # Add the USE flag to enable the clipboard feature
        # required by app-editors/vim
        app-editors/vim X
        
        2022-12-17_16-10.png
      • sudo emerge -q app-editors/vim # Recompile it to enable the USE flag
  • References
    • image.png
    • image.png
    • image.png
    • https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
    • https://wiki.gentoo.org/wiki/Vim


  • I am trying to mix and not just handedness. #Idea

  • References
    • image.png
    • Handedness - Wikipedia

  • Chew food properly #Idea

    • Don't overload your spoon or fork
    • Chew with your mouth closed, with your tongue moving food form side to side and your jaw rotating slightly
    • Chew slow and steadily, counting to 32 with each bite
    • Wait until you have finished food in your mouth before drinking fluids
  • Notes
    • overload your spoon # It will fall off the sides
    • 32 # Just ensure the food in your mouth loses all of its texture before swallowing
    • drinking fluids # It will slow the digestive process by diluting enzymes in the body which break down food
  • References
    • image.png
    • Is there a right way to chew your food?- ---
  • "Biography" (Bio) #abbreviation #GitHub

    • References
      • image.png
      • image.png- ---
  • Set USE flags for each package in Gentoo Linux

    • sudo vim /etc/portage/package.use
      x11-terms/rxvt-unicode-9.30 perl xft
      
  • References
    • image.png
    • image.png
    • https://wiki.gentoo.org/wiki//etc/portage/package.use

  • Search in current line #Vim

    • Shift+v # Select current line
    • /24 # Just like a normal search and press Esc key after the step
  • Notes
    • Shift+v # Press Shift follow by v in normal mode
    • /24 # Replace 24 with what you want to search for
  • References
    • image.png
    • image.png
    • https://stackoverflow.com/questions/16572611/vim-find-pattern-on-currently-line-only

  • Use "st"

    • doas vim /etc/portage/savedconfig/x11-terms/st-0.9
      # Set fonts
      static char *font = "Liberation Mono:pixelsize=14:antialias=true:autohint=true";
      
      • sudo emerge st # Recompile to make changes effective
  • Notes
    • doas vim /etc/portage/package.use/zz-autounmask
      # required by /etc/portage/savedconfig/x11-terms/st
      # Set the USE flage (`savedconfig`) fo the package (`x11-terms/st`)
      x11-terms/st savedconfig
      
      • To save custom configuration files
      • To avoid the file being lost
    • Because to install ST (simple terminal) in Gentoo Linux.
  • References
    • https://forums.gentoo.org/viewtopic-t-1158543-start-0.html
    • https://wiki.gentoo.org/wiki/St

  • Solve error about module repository Gentoo Linux

    • sudo emerge eselect-repository
  • Notes
    • Error
      yaoniplan@yaoniplan ~ $ eselect repository enable torbrowser
      !!! Error: Can't load module repository
      exiting
      yaoniplan@yaoniplan ~ $
      
  • References
    • image.png
    • image.png
    • image.png
    • https://github.com/luliu/swift-overlay/blob/main/README.md

  • Choose a keyboard for a computer

    • Mechanical fast response PBT
  • Notes
    • Form factor
      • 100% (full-size) # Large and inefficient
    • Ergonomic
      • Align the "H" key with the center of the body
      • Flat and follow the angle of the thighs
    • Wired and wireless
    • Arrow and function key
    • Switches
      Name Type Force Noise
      Brown Tactile 45 g Average
      Clear Tactile 65 g Average
      Red Linear 45 g Low
      Black Linear 60 g Low
      Blue Clicky 50 g High
    • Typing and programming
      • Build quality
        • Plastic # Cheap, but will flex when you press too hard
        • Metal or higher-quality
      • Keycaps
        • ABS # Prone to wear and become smooth with heavy use
        • PBT # More durable
      • Programmability
        • Onboard # Customize certain keys
      • Removable cable
        • Removeable USB cable # Replace just the cable rather than the whole keyboard
  • References
    • Keyboard layouts
    • Compact keyboard layouts
    • 61RWq1Sr7DL._AC_SX569_.jpg
    • 71kM7aW7+tS._AC_SX569_.jpg
    • Bluetooth-Compatible-5-0-Mechanical-Gaming-Keyboard-Ergonomic-Wireless-Mechanical-Keyboard-2-4G-68-Keys-Hot.jpg_Q90.jpg_.webp
    • image.png
    • image.png
    • unparalleled_extensibility-v3-60FPS-compressed-v2.gif
    • agent-screencast5.gif
    • Extreme_customizability-compressed.gif
    • https://www.nytimes.com/wirecutter/blog/how-to-shop-for-a-mechanical-keyboard/
    • https://ergo.human.cornell.edu/AHTutorials/ckd.htm
    • https://www.bilibili.com/video/BV1jm4y1R7kz/?spm_id_from=333.337.search-card.all.click
    • https://ultimatehackingkeyboard.com/

  • CopyQ installation #application

    • sudo emerge -aq --autounmask=y --autounmask-write x11-misc/copyq
      • sudo etc-update
      • -3 # Merge all files automatically
    • sudo emerge -aq x11-misc/copyq

  • I am trying to replace "unorder list" syntax with "heading" syntax. #Idea

    • because it has a link to share anyone.

  • Nordic-darker theme installation
    • sudo cp -r Nordic-darker/ /usr/share/themes/
    • Notes
      • Nordic-darker/ # The theme folder
        • tar -xf Nordic-darker.tar.xz # Extract the file if you download it
      • /usr/share/themes/ # Add your theme folder to this derectory
    • References
      • image.png
      • image.png
      • https://github.com/EliverLara/Nordic#installation

  • Extract a ".tar.xz" file

    • tar -xf Nordic-darker-v40.tar.xz
  • Notes
    • -x # Extract
    • -f # File
  • References
    • image.png
    • image.png
    • man tar # /-x /-f
    • https://linuxhint.com/uncompress-tar-xz-files/

  • Solve problem about "echo", ">>" and permission #Linux #Command
    • echo "=x11-base/xorg-server-1.11.99.2" | sudo tee -a /etc/portage/package.unmask
    • Notes
      • tee # Replace output redirection (e.g. > and >>)
      • -a # Append
    • References
      • image.png
      • yaoniplan@yaoniplan ~/note $ sudo echo "=x11-base/xorg-server-1.11.99.2" sudo >> /etc/portage/package.unmask
        bash: /etc/portage/package.unmask: Permission denied
        
      • man tee
      • https://askubuntu.com/questions/103643/cannot-echo-hello-x-txt-even-with-sudo

  • Kvantum installation #Qt #Theme #application

    • sudo emerge -aq --autounmask=y --autounmask-write x11-themes/kvantum
    • sudo etc-update
      • -3 # Type it, then press "enter" key
      • Y # Type it, the press "enter" key
    • sudo emerge -aq x11-themes/kvantum # Install it now
  • Notes
    • --autounmask=y --autounmask-write # Solve the following error
      !!! All ebuilds that could satisfy "x11-themes/kvantum" have been masked.
      !!! One of the following masked packages is required to complete your request:
      - x11-themes/kvantum-1.0.1::gentoo (masked by: ~amd64 keyword)
      
  • References
    • image.png
    • Knowledge Base:Accepting a keyword for a single package - Gentoo Wiki

  • Lxappearance installation #GTK #Theme #application
    • sudo emerge -aq lxde-base/lxappearance

  • Rofi installation #i3 #Gentoo #Linuxn
    • sudo emerge -aq x11-misc/rofi
    • sudo vim ~/.config/i3/config
      • # start dmenu (a program launcher)
        #bindsym $mod+d exec --no-startup-id dmenu_run
        # A more modern dmenu replacement is rofi:
        bindsym $mod+d exec "rofi -modi drun,run -show drun"
        
    • Notes
      • -a # Ask
      • -q # Quiet
    • References
      • image.png
      • man emerge # Type (by pressing "/") "--ask" or "--quiet" in manual page about emerge

  • Set brightness on i3 and Gentoo Linux

    • sudo emerge --ask x11-apps/xbacklight
    • sudo vim ~/.config/i3/config
      bindsym XF86MonBrightnessUp exec xbacklight -inc 10
      bindsym XF86MonBrightnessDown exec xbacklight -dec 10
      
  • Notes
    • sudo reboot # Reboot the operating system finally
  • References
    • image.png
    • https://zjuyk.gitlab.io/posts/i3wm-config/

  • Enable audio or sound in Gentoo Linux

    • cd /usr/src/linux
    • doas make menuconfig
    • doas make -j6
    • doas make modules_install
    • doas make install
    • doas euse -E alsa
    • doas emerge -avuDN @world
    • doas emerge -aq media-sound/alsa-utils
    • doas gpasswd -a yaoniplan audio
    • doas rc-update add alsasound boot
    • alsamixer
  • Notes
    • doas make menuconfig # Refer this link to activate kernel options
      • lspci | grep -i audio # List all PCI devices and print lines containing audio ignoring case
        • lspci # List all PCI devices
        • -i # --ignore-case
    • doas euse -E alsa # Enable the USE flag (alsa) in /etc/portage/make.conf
      • -E # --enable
      • doas emerge -aq app-portage/gentoolkit # Install it to use the euse command
    • doas gpasswd -a yaoniplan audio # Add the user to the group
      • -a # --add
      • yaoniplan # Replace it with a name of your user
      • audio # A group
      • grep audio /etc/group # Print lines containing audio in /etc/group file
    • doas rc-update add alsasound boot # Add the service to the runlevel by using OpenRC
      • alsasound # A service
      • boot # A runlevel
    • alsamixer
      • Press the M key to unmute if display MM
      • Press the Escape key to exit the interface
    • Use "pactl"
      • pactl list sinks # Display the current volume level
      • pactl set-sink-volume @DEFAULT_SINK@ +10% # Increase the volume by ten percent
      • pactl set-sink-volume @DEFAULT_SINK@ -10% # Decrease the volume by ten percent
      • pactl set-sink-mute @DEFAULT_SINK@ toggle # Toggle mute
      • pactl # Pulse audio control
      • Because enable audio or volume in Linux with pipeware.
  • References
    • man pactl
    • man rc-update
    • man gpasswd
    • man euse
    • man grep
    • man lspci
    • image.png
    • https://wiki.archlinux.org/title/Dwm#Adjusting_volume
    • https://wiki.gentoo.org/wiki/ALSA

  • Install google-chrome in Gentoo Linux

    • sudo vim /etc/portage/package.license
      www-client/google-chrome google-chrome
      
    • sudo emerge --ask www-client/google-chrome
  • Notes
    • www-client/google-chrome google-chrome # Accept license if you want to install and use this software
  • References
    • https://wiki.gentoo.org/wiki/Chrome

  • Use "sddm" theme in Gentoo Linux

    • git clone https://github.com/MarianArlt/sddm-chili
    • doas mv ~/sddm-chili /usr/share/sddm/themes/
    • doas vim /etc/sddm.conf
      [Theme]
      # Current theme name
      Current=sddm-chili
      
  • Notes
    • doas emerge --ask dev-qt/qtquickcontrols # Solve an error
      file:///usr/share/sddm/themes/sddm-chili//Main.qml:22:1: module "QtQuick.Controls" is not installed
      
    • doas emerge --ask dev-qt/qtgraphicaleffects # Solve an error
      file:///usr/share/sddm/themes/sddm-chili//components/Wallpaper.qml:21:1: module "QtGraphicalEffects" is not installed
      
    • doas vim /usr/share/sddm/themes/sddm-chili/theme.conf # Customize the theme
      # Screen resolution (Use command: screenfetch or neofetch)
      ScreenWidth=1366
      ScreenHeight=768
      
      # Size (between 10 and 16) of font
      FontPointSize=15
      # Pixel size of avatar
      AvatarPixelSize=150
      
    • /usr/share/sddm/faces/yaoniplan.face.icon # Avatar file
      • /usr/share/sddm/faces/ # Add your coustomized picture to the avatar folder
      • yaoniplan # Change it to your user name
      • .face.icon # Keep it default
        # /usr/share/sddm/themes/sddm-chili/Main.qml
        text = new Date().toLocaleString(Qt.locale("en_US"), "ddd dd MMMM yyyy, hh:mm")
        
    • Optional: Take a screenshot of the login screen
      • sddm-greeter --test-mode --theme /usr/share/sddm/themes/sddm-chili/
      • Press the print screen key to take a screenshot
    • Solve the problem about white background 2022-12-16_15-48.png
      • Convert background.jpg file to background.png file (Make sure the image file extension is png)
      • Make sure there is a background.png file in the /usr/share/sddm/themes/sddm-chili/assets/ directory
      • doas vim /usr/share/sddm/themes/sddm-chili/theme.conf
        [General]
        background=assets/background.png
        
  • References
    • image.png
    • image.png
    • https://github.com/MarianArlt/sddm-chili/issues/15#issuecomment-1764010005
    • https://askubuntu.com/questions/43458/how-can-i-take-a-screenshot-of-the-login-screen
    • https://github.com/MarianArlt/sddm-chili
    • Artificial intelligence

  • SDDM Usage Gentoo Linux DM
    • sudo emerge --ask x11-misc/sddm # Install x11-misc/sddm
    • sudo usermod -a -G video sddm # Add the sddm to the video group
  • Notes
    • OpenRC
      • doas emerge --ask gui-libs/display-manager-init
      • doas vim /etc/conf.d/display-manager
        CHECKVT=7
        DISPLAYMANAGER="sddm"
        
      • rc-update add display-manager default # Add the display-manager to the system's default runlevel
      • rc-service display-manager start # Start the display-manager
    • Another way
      • echo "exec dwm" >> ~/.xinitrc # Repalce dwm with your WM
      • echo "startx" >> ~/.bash_profile
  • References
    • https://wiki.gentoo.org/wiki/SDDM

  • The abbreviation of the "Miscellaneous" is "misc".
  • References
    • image.png

  • Remove package from @world set #Gentoo #Linux
    • sudo emerge --deselect sys-kernel/gentoo-kernel-bin
    • Notes
      • cat /var/lib/portage/world | less # View packages in the @world set
    • References
      • image.png
      • image.png
      • Gentoo Cheat Sheet - Gentoo Wiki

  • Compress as a ".zip" file

    • zip archive.zip *.mp3 # Zip a file
    • zip -r wallpaper.zip wallpaper/ # Zip a directory
  • Notes
    • -r # Recursive
    • -e # Encrypt
    • wallpaper/ # A folder you want to compress
    • nix profile install nixpkgs#zip # Install dependencies
  • References
    • man zip # /-r /--encrypt
    • image.png

  • Do not use "sudo rm -rf test/" unless you used "sudo cp -r test/ /tmp/" before. #Idea #Linux

  • Set dark mode in Ventoy

    • doas ./VentoyPlugson.sh /dev/sdc
    • http://127.0.0.1:24681
    • Change the "display_mode" in "Theme Plugin" from "GUI" to "CLI"
  • Notes
    • doas mount /dev/sdc1 /mnt/SanDisk # Mount it before using the command
    • /dev/sdc # Replace it with your block device
      • lsblk # Get it (e.g. /dev/sda, /dev/sdb, etc.)
    • Warning: It has some bugs about displaying.
  • References
    • image.png
    • image.png
    • image.png
    • https://www.ventoy.net/en/plugin_plugson.html
    • https://github.com/ventoy/Ventoy/releases

  • Use "qemu"

    • Create a disk image
      • qemu-img create -f qcow2 ~/testQemu.cow 100G
    • Install the OS
      qemu-system-x86_64 -m 8G -enable-kvm \
        -bios /usr/share/ovmf/x64/OVMF.fd \
        -nic user,hostfwd=tcp::60022-:22 \
        -cdrom /mnt/grow/230504archlinux-2023.05.03-x86_64.iso \
        -drive file=~/testQemu.cow,format=qcow2 \
        -boot order=d
      
    • Run the machine
      qemu-system-x86_64 -m 8G -smp 4 -enable-kvm \
        -bios /usr/share/ovmf/x64/OVMF.fd \
        -nic user,hostfwd=tcp::60022-:22 \
        ~/testQemu.cow -audiodev pa,id=sound0 \
        -device ich9-intel-hda \
        -device hda-output,audiodev=sound0
      
  • Notes
    • -display sdl,gl=on -vga virtio # Enable 3D acceleration if you cannot enter the desktop after entering the password in the window manager
    • -bios /usr/share/ovmf/x64/OVMF.fd # 64bit UEFI
    • ssh yaoniplan@192.168.10.105 -p 60022 # Connect it
    • doas pacman -S qemu-full # Install dependencies
    • doas pacman -S remmina # Install the VNC client (Another way)
      # Click the "New connection profile" icon
      Remmina VNC plugin for GNOME and KVM # Protocol
      localhost:5900 # Server
      # Click the "Save" button
      # Double-click to connect the VNC server
      
  • References
    • https://pkgbuild.com/~tpowa/archboot/web/archboot.html
    • https://leedev.org/2015/12/13/arch-linux-qemu.html
    • https://ict4g.net/adolfo/notes/admin/qemu-virtual-machines.html
    • ChatGPT

  • Understand "Wayland"

    • A display server protocol
    • Replace X11
  • References
    • image.png
    • https://www.cbtnuggets.com/blog/technology/networking/why-use-wayland-versus-x11

  • Decompress a ".xz" file in Unix-like

    • xz -d ./FreeBSD-13.1-RELEASE-amd64-bootonly.iso.xz
  • Notes
    • -d # Decompress
  • References
    • man xz
    • 2023-02-12_14:44:43.png
    • https://www.quora.com/How-do-I-extract-an-XZ-file-in-Linux

  • The punctuation of "Underscore" is "_".
  • References
    • image.png
    • https://en.wikipedia.org/wiki/Underscore

  • how to chewing and swallowing (or eating) properly #Idea
  • References
    • image.png

  • View all commits of a user #GitHub
    • https://github.com/search?q=author:yaoniplan # Change user "yaoniplan" to yours
  • Notes
    • recently committed: image.png
  • References
    • image.png
    • image.png
    • https://webapps.stackexchange.com/questions/54148/can-i-view-all-time-all-repo-commits-of-a-user-at-github

  • I am trying to replace pages (e.g. abbreviation, punctuation, etc.) with tags. #Idea- ---
  • Add a [[abbreviation]]

    Yet Another Multicolumn Layout (YAML)
  • References
    • image.png
    • YAML (framework) - Wikipedia

  • Shortcuts developer tools on Chromium

    CTRL + Shift + c # Open developer tools
  • Notes
    • CTRL + Shift + i # Close developer tools
  • References
    • image.png
    • image.png
    • https://www.theodinproject.com/lessons/foundations-javascript-developer-tools

  • Add a [[punctuation]]

    Question mark (?)
  • References
    • image.png
    • Question mark - Wikipedia

  • The punctuation of "backtick" is "`".

    • Another name
      • "grave"
  • References
    • image.png
    • https://en.wikipedia.org/wiki/Backtick
  • The abbreviation of "Incorporation" is "Inc".

  • References
    • image.png

  • Add a [[abbreviation]]

    Main Character (MC) in anime
  • References
    • image.png

  • The punctuation of "exclamation mark" is "!"

  • References
    • https://en.wikipedia.org/wiki/Exclamation_mark

  • Add a [[punctuation]]

    Space ( )
  • References
    • image.png
    • Space (punctuation) - Wikipedia

  • I'm trying to refactor Markdown.md in English. #Idea

  • test typesetting

    Use headings unordered lists images links code
  • Notes
    • test # test
    • test # test
  • References
    • test_image
    • test_image
    • test_link
  • I'm trying to complete my GitHub. #Idea
  • References
    • image.png
    • image.png
    • https://github.com/pengx17

  • Push using [[Git]] automatically
    • "~/.config/shell/autoGit.sh"
      #!/bin/sh
      while true; do
        cd ~/note
        sleep 20
        git add *
        sleep 20
        git commit -m "Update at `date +%F-%T`"
        sleep 20
        git push
      done
      
    • "~/.config/i3/config"
      # Git automatically
      exec ~/.config/shell/autoGit.sh
      
  • Notes
    • chmod u+x ~/.config/shell/autoGit.sh # Add executable permission
  • References
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • Making git auto-commit - Stack Overflow

  • I'm trying to automate commit and push using [[Git]]. #Idea
    • test it using Git hooks
    • write a sh file
    • test sh file about "sleep"
    • test sh file about "sleep" again
    • change sleep 540 to 20
    • It doesn't work about commit message again
    • Change ";" to ":"

  • I am trying to publish my [[Logseq]]. #Idea
    • test the publish function
    • Succeeded
    • https://yaoniplan.github.io/note/

  • Publish [[Logseq]]
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
  • Notes
    • git pull -f # After completing the steps in GitHub
  • References
    • https://www.youtube.com/watch?v=UYqJcFEYUsY
    • https://github.com/pengx17/knowledge-garden/blob/main/.github/workflows/main.yml
    • https://github.com/pengx17/logseq-publish
  • [[Logseq]]plugin "logseq-focus-mode"
    • Toggle Line Highlight
    • Toggle Top Bar
  • Notes
    • .references.mt-6.flex-1.flex-row # Hide "Unlinked References"
    • /* content: "🗓 "; */ # Hide the emoji of calendar about journals (Edit it in your custom.css file)
  • References
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • sethfair/logseq-focus-mode: The Focus Mode plugin for Logseq allows you to quickly switch into a distraction-free "zen" mode by toggling into full-screen and hiding elements like the sidebar or properties section.
    • How to Write Using Logseq (Long Form Writing Setup) - YouTube

  • I am trying out plugins and themes for Logseq. #Idea

  • [[Logseq]]plugin "logseq-plugin-vim-shortcuts"

    • j # move down
    • k # move up
    • i # insert cursor at the beginnig of the line
    • a # insert cursor at the end of the line
    • o # insert cursor to the next line
    • G # scroll to bottom
  • Notes
    • 111j # scroll to bottom (means move down 111 lines)
    • Optional: Change default [[shortcut keys]] (e.g. gg) for the plugin (#Logseq-vim-shortcuts ) and the #application (#Logseq )
      • sudo vim ~/.logseq/settings/logseq-vim-shortcuts.json
            "top": "g g",
        
      • Change it after pressing the g key and the s key to display this page image.png
  • References
    • image.png
    • vipzhicheng/logseq-plugin-vim-shortcuts: Add part of VIM key bindings experience to Logseq

  • [[Logseq]]plugin "logseq-plugin-bullet-threading"
  • References
    • image.png
    • pengx17/logseq-plugin-bullet-threading: Add bullet threading to your active blocks in Logseq.

  • [[Logseq]]theme "logseq-cusgit-theme"
    • vim ~/note/logseq/custom.css # Copy the whole content of custom.css to yours
  • References
    • image.png
    • image.png
    • image.png
    • https://github.com/mendax1234/logseq-cusgit-theme

  • The punctuation of "hyphen" is "-".

  • References
    • https://en.wikipedia.org/wiki/Hyphen

  • [[GitHub]]repository created time (date)
    • https://api.github.com/repos/yaoniplan/note
  • Notes
    • api. # Add it before the "github.com/"
    • repos/ # Add it after the "github.com/"
    • note # Remove the slash (/) after the repository name (note)
  • References
    • image.png
    • image.png
    • image.png
    • https://www.ilovefreesoftware.com/16/programming/check-creation-date-github-repository.html

  • The abbreviation of "Graphics interchange format" is "GIF"

  • References
    • https://en.wikipedia.org/wiki/GIF

  • [[Vim]]highlight disable temporarily
    • :noh
  • References
    • image.png
    • image.png
    • Clear Search Highlight in Vim — tech.serhatteker.com

  • Add string to the end of specified lines in Vim

    • :'<,'>s/$/<\/li>/
  • Notes
    • :'<,'>
      • V # Select lines in visual line mode
      • : # See the format
    • s # Substitute
    • $ # The end of line
    • <\/li> # Replace it with your desired string
      • backslash # Escape character
  • References
    • image.png
    • image.png
    • https://stackoverflow.com/questions/253380/how-to-insert-text-at-beginning-of-a-multi-line-selection-in-vi-vim

  • [[abbreviation]]"Massive open online course" (MOOC)
  • References
    • image.png
    • Massive open online course - Wikipedia

  • The brain grows most by getting questions wrong, not right. #quote

  • As long as we embrace struggle and mistakes, we can learn anything. #quote #Idea

  • References
    • image.png
    • https://www.khanacademy.org/college-careers-more/talks-and-interviews/talks-and-interviews-unit/conversations-with-sal/a/the-learning-myth-why-ill-never-tell-my-son-hes-smart

  • [[Flameshot]]screenshot (capture) full screen
    • Ctrl + c # Copy to clipboard
    • Notes
    • Print screen # Capture screen before Ctrl + c
    • References
    • image.png
  • [[Chrome]]move tab's position
    • Ctrl + Shift + PageDown # Move tabs right
    • References
    • image.png
    • image.png
    • https://support.google.com/chrome/answer/157179?hl=en&co=GENIE.Platform%3DDesktop#zippy=%2Ctab-window-shortcuts%2Cmouse-shortcuts
    • https://superuser.com/questions/629432/keyboard-shortcuts-to-arrange-chrome-tabs-on-windows
  • [[Markdown]]Comment
    • between <!-- and -->
    • References
    • image.png
    • image.png
    • https://github.com/yaoniplan/note/blob/5cf3fb4fb65540ac253d217e396f107fa131d7df/README.md
    • https://gist.github.com/jonikarppinen/47dc8c1d7ab7e911f4c9

  • Commit message rules in Git

    • Separate subject from body with a blank line
    • Limit the subject line to 50 characters
    • Capitalize the subject line
    • Do not end the subject line with a period
    • Use the imperative mood in the subject line
    • Wrap the body at 72 characters
    • Use the body to explain what and why vs. how
  • Notes
    • git commit -m 'foo' # Write the subject line
    • git commit --amend # Write the body
    • If applied, this commit will
      • Complete the subject line above
  • References
    • image.png
    • https://cbea.ms/git-commit/

  • [[Symbol]]Period .
    • Notes
    • . # In computing, it is called a dot
    • References
    • image.png
    • image.png
    • Full stop - Wikipedia

  • The abbreviation of "Cascading Style Sheets" is "CSS".

  • References
    • image.png
    • https://www.w3schools.com/html/html_css.asp

  • I will write an extension (e.g. Linux commands) of google chrome. #Idea

  • Notes
    • Two methods in English
      • man date
      • date --help
      • Replace the "date" command with your desired program.

  • [[Git]]edit comments
    • git commit --amend
    • Notes
    • git config --global core.editor /usr/bin/vim # When you have an error about editor (e.g. /bin/nano)
    • References
    • image.png
    • image.png
    • image.png
    • https://stackoverflow.com/questions/52195877/how-can-i-fix-git-commit-error-waiting-for-your-editor-to-close-the-file-wi
  • The abbreviation of "HyperText Markup Language" is "HTML".

  • Notes
    • A markup language
    • A file format
  • References
    • 2022-12-25_18-46.png
    • https://en.wikipedia.org/wiki/HTML

  • Search syntax in Google

    • define:test # Use online dictionary
    • artificial intelligence after:2023/03/27
  • Notes
    • after:2023/03/20 # Time
  • References
    • https://bbs.archlinux.org/viewtopic.php?id=124937
    • https://www.google.com/advanced_search
    • ChatGPT

  • The abbreviation of "Command Line Interface" is "CLI"

    • Because to use it can achieve semi-automation by combining it with other tools.
  • References
    • https://nju-projectn.github.io/ics-pa-gitbook/ics2024/0.2.html
    • https://en.wikipedia.org/wiki/Command-line_interface

  • [[github]]star view
    • https://github.com/yaoniplan/note/stargazers # add /stargazers to the end of the URL of a repository
    • References
    • image.png
    • image.png
    • https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars#viewing-who-has-starred-a-repository
  • [[symbol]]number sign #
    • References
    • image.png
    • Number sign - Wikipedia
  • Decompress a ".bz2" file

    • bzcat /usr/share/doc/picom-9.1/picom.sample.conf.bz2 > ~/.config/picom.conf
  • Notes
    • bunzip2 --keep dict-en-en.df.bz2 # Decompress (Keep original file)
  • References
    • man bunzip2 # /keep
    • image.png
    • image.png
    • https://wiki.gentoo.org/wiki/Alacritty
  • [[symbol]]backslash ""
    • References
    • image.png
    • Backslash - Wikipedia
  • [[symbol]]colon :
    • References
    • image.png
    • Colon (punctuation) - Wikipedia -- #### The punctuation of "semicolon" is ";".
  • References
    • image.png
    • https://en.wikipedia.org/wiki/Semicolon

  • [[symbol]]comma ,
    • References
    • image.png
    • Comma - Wikipedia
  • [[symbol]]asterisk *
    • References
    • image.png
    • Asterisk - Wikipedia
  • [[symbol]]minus -
    • References
    • image.png
    • Plus and minus signs - Wikipedia
  • [[symbol]]greater-than sign >
    • References
    • image.png
    • Greater-than sign - Wikipedia
  • [[symbol]]less-than sign <
    • References
    • image.png
    • Less-than sign - Wikipedia
  • [[symbol]]less than or equal to <=
    • References
    • image.png
    • 关于“小于/等于/大于”的英文缩写
  • Sort by file size in Linux

    • ls -lS ~/note/pages/
  • Notes
    • -S # Size
  • References
    • man ls
    • image.png
    • image.png

  • [[symbol]]percent sign %
    • References
    • image.png
    • Percent sign - Wikipedia
  • [[symbol]]quotation marks ' "
    • References
    • image.png
    • Quotation mark - Wikipedia
  • I have a dream to build Iron Man. #Idea
  • I participated in a game about "shiyanlou_100th_floor_2022-09-15_2022-10-14". #Idea


  • Symbol wiki

    • https://en.wikipedia.org/wiki/Punctuation
    • https://zh.wikipedia.org/wiki/%E6%A0%87%E7%82%B9%E7%AC%A6%E5%8F%B7

  • The punctuation of "round brackets" are "()".

  • Notes
    • "{}" # Curly brackets
  • References
    • https://en.wikipedia.org/wiki/Bracket

  • The punctuation of "dot" is ".".

    • yaoniplan.eu.org
  • Notes
    • Decimal point
      • 4.8 # Four point eight
  • References
    • https://en.wikipedia.org/wiki/Dot

  • lenovo_gentoo-i3_daily_use_2022-10-05_github_push_test
  • [[github]]pull from github
    • git pull # If you use "git push" on another computer you must use "git pull" on one computer.
    • References
    • image.png
  • browser_vimium_CSS_for_Vimium_UI_default
    div > .vimiumHintMarker {
    /* linkhint boxes */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFF785),
      color-stop(100%,#FFC542));
    border: 1px solid #E3BE23;
    }
    
    div > .vimiumHintMarker span {
    /* linkhint text */
    color: black;
    font-weight: bold;
    font-size: 12px;
    }
    
    div > .vimiumHintMarker > .matchingCharacter {
    }
    
  • [[Vimium]]theme
    • Dracula_Dark https://github.com/dracula/vimium/tree/54a6d0cf56248611755527bf58cc5cf238b68ace
    • image.png
    • image.png
    • Arc_Dark https://github.com/philc/vimium/issues/3157#issuecomment-476652867
    • image.png
    • image.png
    • https://qiita.com/nisshy0516/items/0eec4d49c68b39f15716
    • image.png
    • image.png
    • simply-dark https://github.com/ysjn/vimium-simply-dark
    • image.png
    • image.png
    • rainbow https://github.com/zozonteq/vimium-rgb-theme?ref=codetea.com
    • image.png
    • image.png
    • image.png
  • I am a Chinese who is learning English. #Idea
  • And I think English is just a tool for me. #Idea

  • The punctuation of "slash" is "/".

  • References
    • https://en.wikipedia.org/wiki/Slash_(punctuation)

  • [[usb]]dd iso to usb
    • sudo dd if=/home/gentoo/Downloads/ubuntu-22.04.1-live-server-amd64.iso of=/dev/sdc bs=4M && sync
    • Notes
    • /dev/sdc # your usb device (lsblk can view it)
    • sync # If you don't do this, you will get an "Operating System not Found"error.
    • References
    • image.png
    • image.png
    • image.png
    • https://askubuntu.com/questions/372607/how-to-create-a-bootable-ubuntu-usb-flash-drive-from-terminal

  • I need to spend a lot of time cleaning the HP laptop (e.g. electric fan, GPU, etc.) because it has a lot of screws. #Idea

  • References
    • https://www.youtube.com/watch?v=p7XZNsNLQss

  • [[Vimium]]temporarily disable vimium
    • i # ignore all commands of vimium by hitting this key (i is insert)
    • Notes
    • esc # exit and enable vimium by hitting this key
    • References
    • image.png
    • https://github.com/philc/vimium

  • View the current filename (or full path) in #Vim

    • Press 1 followed by Ctrl-g # Method one
    • :set laststatus=2 # Method two
    • :f # Method three
  • References
    • image.png
    • image.png
    • image.png
    • image.png
    • https://unix.stackexchange.com/questions/111558/how-can-i-constantly-see-the-current-filename-in-vim
    • https://codeyarns.com/tech/2014-02-13-how-to-view-full-path-of-file-in-vim.html#gsc.tab=0

  • [[Vim]]paste text
    • "*p # enter them in vim normal mode after you copied (e.g. ctrl + c) text
    • Notes
    • p # please don't enter it in vim normal mode after you copied (e.g. ctrl + c) text
    • ctrl + v # please don't enter it after you copied (e.g. ctrl + c) text
    • References
    • image.png
    • image.png
  • [[linux]]copy files excluding existing ones
    • sudo cp -rn ~/kaigua/* ~/test # -n is --no-clobber (not overwrite)
    • image.png
    • image.png
    • man cp # have a problem finding a man
    • v5.0.0 EFI, linux swap 24GiB, no encryption, /dev/sda, desktop-systemd, gentoo cn mirror, no ~amd64, run mirrorselect, screenfetch, vim, i3-gaps, sddm # install compelete.
    • v4.0.0 EFI, linux swap, no encryption, /dev/sda, systemd, gentoo cn mirror, no ~amd64, run mirrorselect, screenfetch # install compelete.
    • v3.1.0 the first lower link: git clone --depth 1 https://anongit.gentoo.org/git/repo/sync/gentoo.git 100KiB/s
    • v3.0.0 bios, linux swap, no encryption, /dev/sda, openrc, gentoo cn mirror, no ~amd64, run mirrorselect, screenfetch # install compelete.
    • v2.2.0 stage3 # don't need desktop (i3) (It will need a lot of time to compiling rust. So i3 need desktop.)
    • v2.1.0 emerge --verbose sys-kernel/dracut sys-kernel/gentoo-kernel-bin app-arch/zstd # Command Failed
    • v2.0.0 git mirrors: https://mirrors.ustc.edu.cn/gentoo.git; gentoo mirrors: https://mirrors.ustc.edu.cn/gentoo/; not run select gentoo mirrors # speed is faster than 1.
    • v1.0.0 git mirrors: default; gentoo mirrors: https://mirrors.ustc.edu.cn/gentoo/ run select gentoo mirrors # speed is lower, 100KiB/s (lower first link: git clone --depth1 https://anongit.gentoo.org/git/repo/sync/gentoo.git)
    • References
    • https://www.youtube.com/watch?v=I-vu9IHHYLg # install gentoo finish
    • https://github.com/oddlama/gentoo-install
    • v0.0.0 gentooinstall test

  • Find and replace strings in Vim

    • :%s/#//g # Find "#", and replace it with ""
  • Notes
    • : # Command-line mode
    • % # The entire file
    • s # Substitute
    • :%s/\[\[//g # Find "[[" and replace it with ""
      • "" # Add the escape character to solve the problem about pattern not found
  • References
    • :help :range
    • :help :substitute
    • :help :
    • https://vim.fandom.com/wiki/Search_and_replace
    • https://stackoverflow.com/questions/19994922/find-and-replace-strings-in-vim-on-multiple-lines

  • Use "e.g. " in English

    • (e.g. marzipan) # for example marzipan
  • References
    • image.png
    • https://en.wiktionary.org/wiki/e.g.

  • gentoo install v1.3.0 github
    • gentoo-install-1.3.0.tar.gz
    • gentoo-install-1.3.0.zip
  • [[computer]] [[linux]] [[gentoo]] I need a computer that can replace the CPU when the computer compiling or building on gentoo. #Idea
  • [[i3]] If you don't input any keys with keyboard in terminal.
    • ctrl + z # use ctrl and z hotkey, then you your terminal will fine.

  • Partition fdisk in Linux

    • fdisk /dev/sda
  • Notes
    • /dev/sda # A device
      • fdisk -l # List
    • fdisk common command
      m # help
      p # print the partition
      g # create a GPT partition and remove all partitons
      n # new a partition (Partition number: default) (First sector: default; Last sector: +512M (+size{K,M,G,T,P}))
      t # change a partition type
      l # list partitions type (Then enter a number of partition)
      w # write partitions to disk and exit
      
  • References
    • Example
      Mount point Partition Type Size
      /mnt/boot /dev/ESP EFI 300 MiB
      [SWAP] /dev/swap Linux swap 512 MiB
      /mnt /dev/root Linux x86-64 root The rest
    • https://wiki.archlinux.org/title/Installation_guide#Example_layouts
    • https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Disks#Partitioning_the_disk_with_GPT_for_UEFI

  • [[Git]] ignore files
    • .gitignore # You can add what you want to ignore in the file.
    • .git/info/exclude # You can add what (e.g. logseq/bak) you want to ignore in the file. (after you changed directory (e.g. cd ~/note) of your repository)
    • References
    • Git - gitignore Documentation
  • [[ssh]] WARNING solve
    • ~/.ssh/known_hosts # rename it. (for example: mv ~/.ssh/known_hosts ~/.ssh/known_hosts_old.old)
    • ssh user@ipaddress # enter it. (for example: ssh root@192.168.10.110)
    • References
    • https://www.cnblogs.com/johnchain/archive/2013/04/08/3006631.html

  • I'll try gentoo linux. # learn snapshot, backup, restore, software, etc. #Idea -- #### Cut hair process
    • hairpin # pin or hold hair
    • spray bottle # make hair wet
    • hair comb # straighten hair
    • hair clipper # cut length of hair
    • hair dryer # dry hair
    • hair wax # change hairstyle
    • hair spray # fixed hairstyle
    • target # not long
  • References
    • image.png
    • image.png
    • images.jpeg
    • image.png
    • image.png
    • image.png
    • image.png
    • image.png
    • download.jpeg
    • images.jpeg
    • image.png
    • https://www.youtube.com/watch?v=gwJyKWtdP2s

  • [[linux]] backup and restore os with clonezilla
    • image.png
    • image.png
    • References
    • # VLOG 28 | 【电脑小技巧】如何使用 CloneZilla再生龍 来备份操作系统?
    • # VLOG 37 | 【电脑小技巧】如何使用CloneZilla再生龙来还原操作系统?
    • Clonezilla - About
  • [[Markdown]] hide section or a collapsed section
    <details><summary>CLICK ME</summary>
    <p>
    
    You can edit this.
    
    </p>
    </details>
    
    • References
    • image.png
    • https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections

  • Solve the problem about hunchback

    • Reduce usage of eyes
    • Focus on abdomen and chest
  • Notes
    • abdomen # Contract
    • chest # Up

  • Living Working
    Self-improvement Workplace Competitiveness
    Computer programming Leadership
    Life Management Graphic Design
    Emotional Sexuality Human Resources
    Health and Wellness We Media Marketing
    Dining Gastronomy Copywriting
    Business Knowledge Various templates
    Hobbies Various research materials
    Literary accomplishment
    • test_merge_and_rename_tables_of_markdown_v1.0.0
  • Living Working
    Self-improvement Software Tutorial
    Computer Programming Workplace Competitiveness
    Life Management Leadership
    Emotional Sexuality Graphic Design
    Health and Wellness Human Resources
    Dining Gastronomy We Media Marketing
    Business Knowledge Copywriting
    Hobbies Various templates
    Literary accomplishment Various research materials
    • test_merge_tables_of_markdown_v1.0.1
  • hair_cut_buy_something_2022-09-22

    • hairpin
    • spray bottle
  • References
    • https://www.youtube.com/watch?v=Mbds03Yh3Ts
    • https://www.youtube.com/watch?v=4GgIecNYLmU
    • https://www.youtube.com/watch?v=N05yY9EwOOQ
  • There is no tiger in the mountain, the monkey is the king. #quote -- #### python name good habits

    • in English # You can fluently read english tutorial after a while.
    • camelCase # lower camel case
    • CamelCase # upper camel case
  • Notes
    • Server-Side Query # serverSideQuery
      • Begin with a lowercase letter
      • Use only letters and numbers; avoid special characters
      • For each subsequent words, start with an uppercase letter
      • Eliminate all spaces between words
      • Merge all words into a single continuous string
  • References
    • image.png
    • image.png

  • [[python]]check class
    • type() # This is a function that check class.
    • References
    • image.png
  • I think the KanBan function is suitable for recoding a long-term plan. #Idea
    • image.png
  • [[Vim]]copy and paste content from one file to another file
    • vim to_copy_file to_paste_file # to_copy_file: you want to copy to_paste_file: you want to paste
    • :n # You will edit the next file after you copy. (You can select where you want to copy via enter "v", then you can copy via enter "y".)
    • p # You can paste it via enter "p"
    • References
    • https://www.youtube.com/watch?v=YS9PZJ-c7ps
  • Check memory in Linux

    • cat /proc/meminfo | less
  • Notes
    • proc # Process
    • meminfo # Memory information
    • free -h # Another way
      • -h # Human

  • [[linux]] [[gentoo]] livegui password
    • sudo passwd # You can set a root password yourself if you don't know it.

  • Set mirror in Gentoo Linux

    • doas vim /etc/portage/make.conf
      GENTOO_MIRRORS="https://mirrors.ustc.edu.cn/gentoo/"
      
  • Notes
    • Because to improve the speed of installing packages.
  • References
    • https://mirrors.ustc.edu.cn/help/gentoo.html

  • Hair preparation

    • Hair clip
    • Hair scissors
    • Spray bottle # Make hair wet
  • References
    • image.png
    • image.png
  • [[Python]] yunsuanfuzuoyou doufangyigekongge zaishuxiebiaodashishi
    • PEP 8 - Style Guide for Python Code
    • image.png
    • image.png
  • [[i3]] mod1
    • xmodmap # see mod1, mod2, mod3, mod4, mod5.
    • Reference
    • image.png
    • What are Mods2 and 3?
  • [[linux]] mkfs # make file system
    • Reference
    • image.png
  • snapshot
    • tool: timeshift(GUI), snapper(CLI)

  • List GitHub syntax

    • Search for content in a repository
      • repo:YanG-1989/m3u 七龙珠 # (repo:aUser/aRepo theContent)
    • Search for file name in a repository
      • yourFileName in:path
      • path:**/yourFileName
  • Reference
    • https://stackoverflow.com/questions/18991908/is-it-possible-to-search-for-a-particular-filename-on-github

  • [[i3]] i3bar hide
    bar {
            mode hide
            hidden_state hide
            modifier Mod4
    }
    
    • Reference
    • i3: i3 User's Guide
    • image.png
    • image.png
  • [[Git]] status
    • git status # see status (Untracked files (track: zhuizong))
    • image.png
    • image.png
  • [[GitHub]] should allow you to register the same SSH public key for more than one repo. # I test it on September 14, 2022.
    • Reference
    • https://discuss.bitrise.io/t/how-to-add-ssh-public-key-to-multiple-github-repos/15544
    • image.png
    • image.png
  • [[Python]] 1 > 2 and not 1 > 3 or 2 > 3 priority (优先)
    • 等价于 ((1 > 2) and (not (1 > 3))) or (2 > 3)
    • (False and (not False)) or False # 算术运算符 > 逻辑运算符
    • (False and True) or False # 逻辑运算符 not
    • False or False # 逻辑运算符 and
    • False # 逻辑运算符 or
    • 总结: 算术运算符 > 逻辑运算符(not > and > or)
    • image.png
  • Use Vimium

    • d # Down
      • Space # In Chromium
    • yy # Copy the current URL to the clipboard
      • C-l C-c # In Chromium
    • f # Feature
      • And then press capital leters
      • Will open a link in a new tab
  • Notes
    • ? # Help
    • Needs
      • hover
  • References
    • https://github.com/philc/vimium#keyboard-bindings
    • https://support.google.com/chrome/answer/157179?hl=en&co=GENIE.Platform%3DDesktop#zippy=%2Ctab-window-shortcuts%2Cgoogle-chrome-feature-shortcuts%2Caddress-bar-shortcuts%2Cwebpage-shortcuts%2Cmouse-shortcuts

  • print("{:5} {:7.2f}".format(fahrenheit, celsius)) 含义
    • :5 # 5 个字符宽度
    • .2f # 四舍五入到小数点后两位
    • :7.2f # 7 个字符宽度,四舍五入到小数点后两位
    • image.png
  • [[python]] tuple (元组) # 在一行内定义多个变量
    • a, b = 45, 54 # 将值 45 分配给变量 a; 将值 54 分配给变量 b
    • 注意事项
    • 用 , (逗号) 来创建 tuple (元组)
    • 也可用于交换值(如下图所示)
    • image.png
  • [[linux]] cp 文件 目录 # 注意事项:若目录存在此同名文件,将会覆盖此同名文件
  • Hair style

    • 有光泽
    • 定型
    • 发泥 # 一指节长度(短发)、 增加摩擦感
    • 发蜡 # 抓线条、旁分、中分、头发的束感、一点点光泽
    • 发胶 # 适合刘海容易掉下来的、有定型效果
    • 通用使用方法
        1. 指背扣(用量:指甲片) 2. 涂匀手指头(发泥)或手掌(发蜡、发胶) 3. 搓发从发根处中间往上(发泥)或左右搓揉在分线的地方拨开去抓(发蜡)或从侧面梳进去服帖的压下来用手指头把发胶带进去(发胶)
        1. 吹头发(八成干) 2. 抓头发(手指伸进去、手指合起来、往上拉、送风2-3次、往前挪) 3. 抓型状(涂抹后,用手捏一捏,捏出纹理来)
        1. 蘑菇头(剪成平平的)2. 吹头发(37分,发根位置矫正,加热发根) 3. 发蜡(抹均匀、发根不用刻意去抹带光泽抹太多会塌掉) 4. 塑形(吹风机)和定型喷雾(支撑发根)
        1. 分区(顶部(太阳穴到后脑勺)、耳朵侧边、后脑勺) 2. 手推剪 # 韩系短发
        1. Pull up on the nose and eyeballs 2. With curling comb and hair clip 3. With hair wax 4. With hair spray
  • References
    • https://www.youtube.com/watch?v=kF6LEa6ZRgo
    • https://www.youtube.com/watch?v=alfCDu6BoGg
    • https://www.youtube.com/watch?v=gLhDOoSX9hM
    • https://www.youtube.com/watch?v=gwJyKWtdP2s
    • https://www.youtube.com/watch?v=yttpvmbOJGk
    • https://www.youtube.com/watch?v=NKIC5bZ712Q

    • Git 和 GitHub
    • Git # 版本 (更方便地管理版本)
    • uid8504-20190523-1558583904136.png
    • image.png
    • GitHub # 代码 (更方便地管理代码)
    • uid810810-20220819-1660889787761.png
    • image.png
    • Git 的安装
      • git # 查看常用命令(顺便检测是否安装) (在终端输入)
      • image.png
      • image.png
    • 在 GitHub 上创建仓库
    • 注册 GitHub 账号
      • github.com # 输入 GitHub 官方网址 (在搜索引擎中)
      • Sign up # Sign up (注册)
      • 使用邮箱注册,验证通过即可 (在填写完相关信息之后)
    • 新建代码仓库
      • image.png
      • image.png
    • 添加 SSH 关联授权
      • ssh-keygen # 生成公钥私钥 (在终端输入,并按几次回车)
      • image.png
      • cat ~/.ssh/id_rsa.pub # 连接公钥文件并打印输出 (选中后,ctrl + shift + c (复制))
      • 在 GitHub 上添加公钥 (Title (标题) (你可自定义), Key (钥匙) (粘贴刚才复制的公钥))
      • image.png
      • image.png
      • image.png
      • image.png
      • git clone git@github.com:yaoniplan/Demo.git # 将远程仓库克隆到本地
      • image.png
      • ls -al # 以列表的形式列出所有文件 (在切换到 Demo 目录后) (出现 .git 目录即表示处于 Git 版本管理下)
      • image.png
      • git config --global user.email "yaoniplan@gmail.com" # commit 时的 Author 信息 (yaoniplan@gmail.com (请填写你注册 GitHub 时的邮箱))
      • git config --global user.name "yaoniplan" # commit 时的 Author 信息 (yaoniplan (请填写你注册 GitHub 时的账户名))
      • image.png
      • image.png
    • 提交代码
      • git add . # add (添加) .(当前目录) (你可以单独添加某个文件或多个文件) 文件到 index (索引)
      • git commit -m 'test' # commit (record changes to the repository) 记录变化到仓库 -m (message) 信息 test (对变化的描述,你可以自定义)
      • git push # push (推送) 到远程仓库
      • image.png
      • image.png
      • image.png
  • Python_的流程控制
    • Python_文件的创建和执行
      • vim test.py # 用 vim 打开 test.py 文件 (若没有 test.py 文件,则创建并打开 test.py 文件)
      • python3 test.py # 用 python3 interpreter (解析器) 执行 test.py 文件
      • image.png
    • 流程控制 # 告诉计算机什么时候该干什么事
    • 条件判断
      • image.png
      • 注意第一行的 : (冒号);第二行的 space (空格) (4个空格作为一个缩进)
      • else elif # elif: else if (用来执行更复杂的)
    • 比较大小游戏
      • uid8504-20190522-1558512042778.jpg
      • image.png
    • 更多判断
      • 嵌套
      • image.png
      • 结合 and 和 or
      • image.png
    • 循环控制 # 实现功能:重复和自动
      • for 循环
      • uid8504-20190604-1559632549800.jpg
      • for # for (对于)
      • in # in (在……之中)
      • item # item (每个元素) (你可以自定义,如果你喜欢的话)
      • for i in namelist # 对于在 namelist 中的每个元素 (i) 执行从属代码
      • image.png
      • uid8504-20190522-1558514369488.jpg
      • range() 函数
      • range(x)
        • range(10) # 生成 10 (x) 个整数 (从 0 开始)
        • image.png
      • range(a, b)
        • range(1, 11) # 生成 11 - 1 (b - a) 个数 (从 1 (a) 开始)
        • image.png
      • while 循环
        • uid8504-20190604-1559632814963.png
        • while # while (当……时)
        • while a <= 10: while (当……时) (当 a <= 10 时,执行从属代码,否则循环停止)
        • image.png
        • uid8504-20190604-1559633545292.gif
    • 区别 (for 循环与 while 循环)
      • uid8504-20190522-1558516464511.png
      • break 和 continue
      • break
        • break # break (打破) (打破当前循环) (不会打破所有循环)
        • image.png
      • continue
        • continue continue (继续) (继续循环的下一次迭代)
        • image.png
        • image.png

  • Undo git add

    • git reset # All
    • git reset ~/.config/i3/config # A file
  • Notes
    • Because to remove a file from the index without changing anything else.
  • References
    • 2023-01-11_09-13.png
    • https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit

  • [[python]] 认识 Python
    • 进入 Python 开发环境
      • python3 # 调用 interpreter (口译员;解释器)
      • image.png
      • >>> # primary prompt (主要的提示符),处于 interactive mode (交互模式)
      • ... # secondary prompt (辅助的提示符),因为需要 continuation lines (续行)
      • image.png
      • Control-D quit() exit() # exit the interpreter (退出解释器)
      • image.png
    • 第一行代码
      • print("Hello World!") # print() (打印函数) Hello World (字符串) (用引号括起来) (无论是一对单引号、还是一对双引号,灵活使用)
      • image.png
    • 数据类型
      • int # integer (整数)
      • float # 浮点数 (小数) 3.14 = 0.314 * 10 (小数点可以改变位置,故称浮点数)
      • Ture False # bool type (布尔类型)
      • image.png
      • None # NoneType (无类型)
    • 变量
      • name = "yaoniplan"
      • = # equal sign (等号) assign a value to variable (分配一个值给变量)
      • name # variable (多变的,变量)
      • "yaoniplan" # value (值)
      • image.png
    • Input() 函数
      • ID = input("请输入你的ID:") # input() (输入函数)
      • image.png
    • 字符串
      • print('"isn\'t it," they said.')
      • '...' "..." # Strings (字符串) (用引号括起来的就是字符串)
      • backslashes (反斜杠) # escape quotes ((逃脱,转义)引号)
      • image.png
      • 索引
        • strings = "yaoniplan"
        • strings[0] # 第一个字符的索引为 0
        • strings[-1] # 最后一个 (倒数第一个) 字符的索引为 -1
        • image.png
      • format()
        • format() # 专门用来格式化字符串的函数
        • 插入数据
          • print("你叫{},今年{}岁了".format(name, age))
          • image.png
          • "{} {}".format(a, b) # 等价于 "{0} {1}".format(a, b)
          • uid8504-20190522-1558507543867.jpg
        • 数字格式化
          • print("{:.2f}".format(3.1415926)) # 保留两位小数
          • image.png
    • 注释
      • # # # (井号) 后面的内容 (包括代码) 会被忽略 (适用于单行注释;暂时不需要执行的代码)
      • image.png
    • 运算符
      • 算术运算符 # 常用的有 + - * / % (加减乘除余)
        • a + b # + (加) (a 加上 b)
        • a - b # - (减) (a 减去 b)
        • a * c # * (乘) (a 乘以 c)
        • a / c # / (除) (a 除以 c)
        • b % a # % (余) (b 除以 a 的余)
        • a ** b # ** (幂) (a 的 b 次幂)
        • c // b # // (整) (c 除以 b 的整)
        • image.png
        • image.png
      • 比较运算符 # 常用于 判断和循环 中
        • a == b # == (等于) (a 等于 b)
        • a != b # != (不等于) (a 不等于 b)
        • a > c # > (大于) (a 大于 c)
        • a < c # < (小于) (a 小于 c)
        • b >= c # >= (大于等于) (b 大于等于 c)
        • b <= c # <= (小于等于) (b 小于等于 c)
        • image.png
        • image.png
      • 赋值运算符 # 主要是为了简写
        • c = a + b # = (赋值符,等号) (分配一个值给变量) (分配 a + b 的值给 c 这个变量)
        • c += a # += (加法赋值符) (等价于 c = c + a)
        • image.png
        • c -= a # -= (减法赋值符) (等价于 c = c - a)
        • image.png
        • c *= a # *= (乘法赋值符) (等价于 c = c * a)
        • image.png
        • c /= a # /= (除法赋值符) (等价于 c = c / a )
        • image.png
        • c %= a # %= (余赋值符) (等价于 c = c % a)
        • image.png
        • c **= a # **= (幂赋值符) (等价于 c = c ** a)
        • image.png
        • c //= a # //= (整赋值符) (等价于 c = c // a)
        • image.png
      • 逻辑运算符
        • 0 1 # 0 代表 False; 1 代表 True (在逻辑运算中)
        • image.png
        • a and b # and (与) (a 与 b 都为 Ture,则返回 True,否则返回 False)
        • image.png
        • a or b # or (或) (a 或 b 为 Ture,则返回 Ture)
        • image.png
        • not a # not (非) (a 为 True,则返回 False;否则返回 True)
        • image.png
  • [[linux]] mv directory1 directory2 (solve: Direcroty not empty)
    • cp -r directory1 directory2 # 递归地复制目录1到目录2
    • rm -r directory1 # 递归地消除1目录
    • 注意事项
    • 产生问题的原因是目录2已经有目录1的同名目录,而 mv 命令不能够灵活的变通一下,所以采用 cp 和 rm 命令来实现功能
    • 参考资料
    • mv: Directory not empty
    • image.png
  • Display user name

    • whoami
  • Notes
    • Other methods
      • echo $USER
      • echo $LOGNAME
      • id --user --name
      • who
      • logname
    • Because to share reuse scripts with everyone.
  • References
    • man id
    • ChatGPT

  • [[linux]] chown -R owner:group file

    • chown # change owner (改变拥有者)
    • -R # R:recursive (递归的) (应用场景:连同目录及其下的所有文件及目录)
    • owner # 用户名 (可使用 whoami 在终端中查看)
    • group # 组 (一般情况下,与 owner (用户名)一致)
    • file # 文件 (linux 一切皆文件 (包括目录,可配合上面的 -R 一起使用))
    • 参考资料
    • man chown # manual (手册) (在终端中查看)
    • 如何更改 linux 文件的拥有者和用户组 (chown 和 chgrp)
    • image.png
  • wallpaper (2022-09-07)

    • dark.jpg
    • Syu.png
  • my chinese font (2022-09-07)

    • wqy-microhei # 安装中文字体 wqy-microhei (有效解决中文乱码问题)
    • 参考资料
    • image.png
  • 实践是检验真理的唯一标准 #quote

    • 实践就像是编程里的 coding (写代码)
    • image.png
  • Python 新手入门课,二刷中……

  • Linux 目录操作

    • ls # list (列出) (列出当前目录下的文件及目录)
    • image.png
    • cd # change directory (切换目录) (切换到其他目录下)
    • image.png
      • 快捷操作
        • cd .. # .. (上一级) (切换到上一级目录)
        • image.png
        • cd - # - (上一次) (切换到上一次所在目录) (效果:在最近的两次目录中无限循环)
        • image.png
        • cd ~ # ~ (/home/your_owner_name) (切换到 /home 目录下的当前用户名的目录下)
        • image.png
        • cd / # / (根目录) (切换到根目录下)
        • image.png
      • 绝对路径
        • pwd # print working directory (打印工作中的路径)
        • image.png
        • cd /home/f/kaigua/Python_新手入门课 # 切换到该目录下 (无论你在哪个目录) (记补全或降低输入错误可以使用 Tab 键补全)
        • image.png
      • 新建目录
        • mkdir linshi # make directory (制作目录) (制作一个名叫 linshi 的目录)
        • image.png
        • mkdir -p linshi/linshione # parents (父母) (制作有父母关系的目录) (即使不存在)
        • image.png
  • Linux_文件操作

    • touch linshi.md # touch (触碰) (触碰 linshi.md) (生成 linshi.md 文件)
    • image.png
    • cp linshi.md linshione/linshitwo # copy (复制) (复制 linshi.md 文件到 linshione/linshitwo 目录下)
    • image.png
    • cp -r linshi linshione/linshitwo # recursive (递归的) (递归地复制 linshi 目录到 linshione/linshitwo 目录下)
    • image.png
    • rm linshi.md # remove (消除) (消除 linshi.md 文件)
    • image.png
    • rm -r linshione # recursive (递归的) (递归地消除 linshione 目录及其下所有文件、目录)
    • image.png
    • mv linshi.md linshi # move (移动) (移动 linshi.md 文件到 linshi 目录下)
    • image.png
    • mv linshi linshione # rename (改名) (改名 linshi 目录为 linshione 目录)
    • image.png
      • 查看文件内容
        • cat linshi.md # concatenate (连接) (连接 linshi.md 文件并打印到标准输出上)
        • image.png
        • cat -n linshi.md # number (编号) (给连接 linshi.md 文件所有输出行编号并打印到标准输出上)
        • image.png
      • 编辑文件
        • image.png
      • 帮助命令
      • man cat # manual pages (手册页) (查看 cat 命令的手册页)
      • image.png
      • cat --help # help (帮助) (显示 cat 命令的帮助)
      • image.png
      • image.png
  • [[linux]] ls -lh命令

    • ls # list (动词:列出)
    • -lh # 参数
    • l # list (名词:列表)
    • h # human readable (人类可读)
    • 参考资料
    • image.png

  • Use "chmod"

    • find node_modules/ -type f -exec chmod a-x {} \;
    • chmod -R a+X .wrangler/
    • sudo chmod -R 777 ~/note/grow/029_googleTranslateExtension2.0.12_0/
    • chmod a+x /usr/bin/sleep.py
  • Notes
    • -R # recursive
    • 777 # the first "7" are permissions of user; the second "7" are permissions of user's group; the third "7" are permissions of others
      • permissions # read, write and execute
      • 7 # $2^2 + 2^1 + 2^0$
    • a # All (Users and groups)
      • u # User (Current user)
    • + # Grant (Opposite: -)
    • x # Execute (Permission)
      • X # All directories (Excluding files)
  • References
    • image.png
    • image.png
    • man chmod
    • chmod # Change mode
    • image.png
    • image.png

  • [[linux]] /usr/bin 含义
    • usr # unix software resources (unix 软件资源)
    • bin # binary (二进制)
    • 参考资料
    • image.png
  • [[Vim]] o
    • o # 在当前行下方,插入一个新行,并进入编辑模式 (在普通模式下,按 o (小写字母))
    • 参考资料
    • image.png
  • [[linux]] ~/.zshrc 含义
    • ~ # 等价于 /home/你的用户名 (当前用户的用户文件夹)
    • / # /home/你的用户名/ (在这里,指当前目录下)
    • . # 隐藏文件 (可以使用 ls -a 查看包括隐藏文件的所有文件)
    • zsh # shell 是 zsh
    • rc # run commands
    • 参考资料
    • image.png
  • [[linux]] source ~/.zshrc
    • source ~/.zshrc # 手动运行 ~/.zshrc
    • 参考资料
    • image.png
  • [[linux]] pid ppid 含义
    • pid # p:process (进程)
    • ppid # p:parent (父母) p:process (进程)
    • 参考资料
    • image.png
  • 测试 csv 转 markdown v1.0.0
    关于耀拟计划 & 免责声明
    - 时间就是金钱,效率就是生命 -
    000 - 自我提升 400 - 生活
    行动管理 阿里云盘链接 生活管理 阿里云盘链接
    时间管理 阿里云盘链接 形象提升 阿里云盘链接
    学习效率 阿里云盘链接 健康养生 阿里云盘链接
    文笔口才 阿里云盘链接 餐饮美食 阿里云盘链接
    思维认知 阿里云盘链接 商业知识 阿里云盘链接
    为人处事 阿里云盘链接 情感两性 阿里云盘链接
    100 - 幼儿到高中学习资料 兴趣爱好 阿里云盘链接
    幼儿教育 阿里云盘链接 500 - 文学修养
    小学初中教育 阿里云盘链接 人物传记 阿里云盘链接
    高中教育 阿里云盘链接 演讲演说 阿里云盘链接
    200 - 计算机编程教程 传统国学 阿里云盘链接
    计算机基础 阿里云盘链接 600 - 职场相关
    Python 阿里云盘链接 职场竞争力 阿里云盘链接
    Web前端 阿里云盘链接 领导能力 阿里云盘链接
    Android 阿里云盘链接 项目管理 阿里云盘链接
    300 - 软件教程 平面设计 阿里云盘链接
    PPT教程 阿里云盘链接 人力资源 阿里云盘链接
    Word教程 阿里云盘链接 自媒体营销 阿里云盘链接
    Excel教程 阿里云盘链接 文案写作 阿里云盘链接
    PS教程 阿里云盘链接 各种模板 阿里云盘链接
    PR教程 阿里云盘链接 700 - 各类考证资料
    摄影教程 阿里云盘链接 公务员考试 阿里云盘链接
    思维导图教程 阿里云盘链接 驾考资料 阿里云盘链接
    Anki教程 阿里云盘链接 阿里云盘链接
    Powered by 凉风习~又一秋! v2021.12.12
  • 测试 vsc 转 markdown v1.0.1
    关于耀拟计划 & 免责声明
    - 时间就是金钱,效率就是生命 -
    000 - 自我提升 400 - 生活
    行动管理 阿里云盘链接 生活管理 阿里云盘链接
    时间管理 阿里云盘链接 形象提升 阿里云盘链接
    学习效率 阿里云盘链接 健康养生 阿里云盘链接
    文笔口才 阿里云盘链接 餐饮美食 阿里云盘链接
    思维认知 阿里云盘链接 商业知识 阿里云盘链接
    为人处事 阿里云盘链接 情感两性 阿里云盘链接
    100 - 幼儿到高中学习资料 兴趣爱好 阿里云盘链接
    幼儿教育 阿里云盘链接 500 - 文学修养
    小学初中教育 阿里云盘链接 人物传记 阿里云盘链接
    高中教育 阿里云盘链接 演讲演说 阿里云盘链接
    200 - 计算机编程教程 传统国学 阿里云盘链接
    计算机基础 阿里云盘链接 600 - 职场相关
    Python 阿里云盘链接 职场竞争力 阿里云盘链接
    Web前端 阿里云盘链接 领导能力 阿里云盘链接
    Android 阿里云盘链接 项目管理 阿里云盘链接
    300 - 软件教程 平面设计 阿里云盘链接
    PPT教程 阿里云盘链接 人力资源 阿里云盘链接
    Word教程 阿里云盘链接 自媒体营销 阿里云盘链接
    Excel教程 阿里云盘链接 文案写作 阿里云盘链接
    PS教程 阿里云盘链接 各种模板 阿里云盘链接
    PR教程 阿里云盘链接 700 - 各类考证资料
    摄影教程 阿里云盘链接 公务员考试 阿里云盘链接
    思维导图教程 阿里云盘链接 驾考资料 阿里云盘链接
    Anki教程 阿里云盘链接 阿里云盘链接
  • 测试 csv 转 markdown v1.0.2
    000 - 自我提升 400 - 生活
    行动管理 生活管理
    时间管理 形象提升
    学习效率 健康养生
    文笔口才 餐饮美食
    思维认知 商业知识
    为人处事 情感两性
    100 - 幼儿到高中学习资料 兴趣爱好
    幼儿教育 500 - 文学修养
    小学初中教育 人物传记
    高中教育 演讲演说
    200 - 计算机编程教程 传统国学
    计算机基础 600 - 职场相关
    Python 职场竞争力
    Web前端 领导能力
    Android 项目管理
    300 - 软件教程 平面设计
    PPT教程 人力资源
    Word教程 自媒体营销
    Excel教程 文案写作
    PS教程 各种模板
    PR教程 700 - 各类考证资料
    摄影教程 公务员考试
    思维导图教程 驾考资料
    Anki教程
  • 测试 csv 转 markdown v1.0.3
    000 - 自我提升 400 - 生活
    行动管理 生活管理
    时间管理 形象提升
    学习效率 健康养生
    文笔口才 餐饮美食
    思维认知 商业知识
    为人处事 情感两性
    100 - 幼儿到高中学习资料 兴趣爱好
    幼儿教育 500 - 文学修养
    小学初中教育 人物传记
    高中教育 演讲演说
    200 - 计算机编程教程 传统国学
    计算机基础 600 - 职场相关
    Python 职场竞争力
    Web前端 领导能力
    Android 项目管理
    300 - 软件教程 平面设计
    PPT教程 人力资源
    Word教程 自媒体营销
    Excel教程 文案写作
    PS教程 各种模板
    PR教程 700 - 各类考证资料
    摄影教程 公务员考试
    思维导图教程 驾考资料
    Anki教程
  • 测试 csv 转 markdown v1.0.4
    ------ 自我提升 ------ ------ 软件教程 ------ ------ 文学修养 ------
    行动管理 PPT 人物传记
    时间管理 World 演讲演说
    学习效率 Excel 传统国学
    文笔口才 PS ------ 职场相关 ------
    思维认知 PR 职场竞争力
    为人处事 摄影 领导能力
    - 幼儿到高中学习资料 - 思维导图 项目管理
    幼儿教育 Anki 平面设计
    小学初中教育 -------- 生活 -------- 人力资源
    高中教育 生活管理 自媒体营销
    --- 计算机编程教程 --- 形象提升 文案写作
    计算机基础 健康养生 各种模板
    Python 餐饮美食 ---- 各类考证资料 ----
    Web前端 商业知识 公务员考试
    Android 情感两性 驾考资料
    兴趣爱好
  • [[python]]文件名、文件夹名命名约定
    • hello_world.py # 文件名命名约定
    • 注意事项
    • hello world # 小写字母
    • _ # 下划线代替空格
    • 参考资料
    • image.png
    • Python编程:从入门到实践 (第2版) .pdf

  • 从他人对大学生活的吐槽中,了解了 #Idea

    • 破一本,强制的活动、班会、会议 # 没有任何意义,除了浪费精力
  • References
    • image.png
    • https://www.chongbuluo.com/forum.php?mod=viewthread&tid=11022

  • Reset to a previous version

    • git log
    • git reset --hard 8172b02
    • git push -f
  • Notes
    • git log # Show commit logs (e.g. 8172b02..., e3bd5dd..., etc)
    • git reset --hard 8172b02 # Revert to the 8172b02... version
    • -f # Force
    • git reflog # Show all commit logs (including discarded version)
    • Warning: The method is not recommended. (Make sure what you discarded is less important)
      • git status # Make sure all changes are pushed to the remote before using the command
  • References
    • image.png
    • image.png
    • https://www.liaoxuefeng.com/wiki/896043488029600/897013573512192

  • 英语 , etc. (等等) 使用

    • comic1, comic2, etc. # 漫画1, 漫画2, 等等。
    • 注意事项
    • comic1, comic2 # 两个同类事物 (你可以自定义两个及以上)
    • , etc. # 等等,tec 前要有 , (逗号空格), 其后要有 . (英文句点)
    • 参考资料
    • image.png
    • image.png
    • 学术英语:关于such as, for example, etc., and so on, i.e., 和e.g.的使用
  • 断电半小时(今年断电次数有点多),考虑备用能源(发电机……) in the future #Idea -- [[linux]] command [-options] [parameter]

    • command [-options] [parameter] # 终端命令格式
    • 注意事项
    • command # 命令名
    • [] # 可选 (大白话: 可有可无)
    • options # 选项
    • parameter # 参数
    • 参考资料
    • image.png
  • [[linux]] ip address | grep inet

    • ip address | grep inet # 查看网卡 ip 地址
    • 注意事项
    • ip address # 网卡配置信息
    • | # pipe (管道) (一个命令的输出,作为另一个命令的输入。大白话:将左边命令显示出来的结果,用右边命令来显示)
    • grep # 文本搜索 (相当于网页浏览器的 ctrl + f)
    • inet # grep 搜索的文本
    • 参考资料
    • image.png
    • image.png
  • 2022-09-01,yaoniplan 完全转移更新平台(从腾讯文档转移至GitHub)

    • 参考资料
    • 耀拟计划-v2.1.06-2022-09-01历史记录.zip - github.ocm
    • 耀拟计划-v2.1.06.csv - github.com
    • 耀拟计划-v2.1.06-更新日志.csv - github.com
    • 耀拟计划-v2.1.06.png -github.com
    • 耀拟计划-v2.1.06-更新日志.png - github.com
    • 耀拟计划-v2.1.06-all.xlsx - github.com
  • [[python]] x op= expression

    • x op= expression # 简写运算的语法
    • 注意事项
    • x # 变量名
    • op # 运算符 (op: operator)
    • = # 赋值
    • expression # 表达式
    • x op= expression # 等价于 x = x op expression
    • 参考资料
    • image.png
    • Python3 简明教程 - 运算符和表达式
  • [[i3]]默认配置文件目录 (2022-08-31)

    • .config/i3/config //位于 /home/你的用户名/ 下面
    • a = f(1, 2) + g(3, 4) //参数列表中,在, 后面添加一个空格;在运算符周围各添加一个空格
    • 参考资料
    • image.png
    • # 这是一个注释 //井号 (#) 后面跟一个空格,再写注释
    • 注意事项
    • 开发人员和维护代码库人员 # 面向人群
    • 参考资料
    • image.png
  • 修改已经 git push 的 git commit -m 'beizhu' 中的 beizhu

    • git commit --amend # 修改 beizhu (进入到类似 vim 的编辑器操作界面)
    • git push -f # 强制 push (在修改了 beizhu 之后) (f: forcce) -- [[shell]] [[zsh]]快捷键(补充)
    • ctrl + b //向左边移动一个字节 (b: back)
    • ctrl + f //向右边移动一个字节 (f: forward)
  • [[regex]]学习路线 (regex: regular expression) (正则表达式)

    • Regex Learn - 正则表达式交互课程
    • Regex Crossword
  • 行:是横着的;列:是竖着的

    • 参考资料
    • image.png
  • 付出不一定有收获,但是不付出一定没有收获 #quote

    • 参考资料
    • https://toutyrater.github.io/
  • [[linux]]代理配置先用着 clash-for-windows (闭源+广告) ,毕竟代理需求已经实现,先把计算机科学与技术的基础能力提升上去,再去考虑这些问题,计划下一步:使用 v2ray-core (否则只能是被卖了,还在帮他人数钱,并洋洋自得毫不自知) #Idea

  • xx只有高低之分,没有贵贱之别 #quote

  • 展露出强大的实力才能震慑住宵小之辈,但也只能是宵小之辈 #quote


  • Decompress a ".tar" file

    • tar -xf testData5.tar
  • Notes
    • -x # Extract
    • -f # File
  • References
    • man tar
    • https://medium.com/secttp/overthewire-bandit-level-12-439f655f6fd5

  • [[Vim]]:!命令
    • :!python oeasy.py //执行外部命令 python oeasy.py
    • 参考资料
    • image.png -- [[i3]]锁屏
    • i3lock //锁定屏幕 (在终端输入)
    • 注意事项
    • bindsym $mod+x exec i3lock //绑定快捷键 $mod+x 终端执行 i3lock (当然,你可以绑定快捷键并自定义,如果你喜欢的话)
  • 安卓模拟器 (future,有需求再尝试) #Idea
    • anbox
    • waydroid
  • [[Logseq]]crtl + k检索
    • ctrl + k //检索
    • 注意事项
    • Re-index //Rebuild the graph (目前(2022-08-27)检索前,需要手动重建图,否则最近的更新,检索不出来)
    • 参考资料
    • image.png
  • 光年:光在宇宙真空中沿直线传播了一年时间所经过的距离

    • 注意事项
    • 地球上用到的距离单位(毫米、厘米、分米、米、千米、天文单位)用来衡量宇宙空间太小,所以有了光年这个距离单位
    • 参考资料
    • 什么是光年?-科普100问-湖北科普网 #quote
  • [[linux]]mkdir命令
    • mkdir '目录名' //创建目录
    • 注意事项
    • '目录名' //用 ' (单引号) 括起来 (目录名中有空格)(否则,将会生成多个目录)
    • 参考资料
    • image.png
    • image.png
  • [[linux]]cd ..
    • cd .. //上一级目录
    • 注意事项
    • cd ../note //进入上一级目录下的 note 目录 (应用场景:在同一个目录下,拥有多个仓库,需要分别进行 git 相关操作)
    • 参考资料
    • image.png -- [[i3]]开机自启动clash-for-windows软件
    • exec --no-startup-id cfw //enable proxy "cfw" (在后台启动 cfw)
    • 注意事项
    • --no-startup-id //禁用启动通知 (即开机的时候,启动但不在工作区显示窗口)
    • Silent Start //开启后台启动 (在 cfw 的 Settings-General 下面,把 Silent Start 按钮打开,否则开机可能会显示 cfw 的窗口)
    • 参考资料
    • https://i3wm.org/docs/userguide.html#exec

  • Set scrachpad in i3

    • vim ~/.config/i3/config
      bindsym Mod1+Shift+space move scratchpad
      bindsym Mod1+space scratchpad show
      for_window [class="^st-256color$"] move scratchpad
      
  • Notes
    • move scratchpad # Move a window to the scratchpad workspace
    • scratchpad show # The window will be shown or hidden
  • References
    • 2023-02-03_23:16:41.gif
    • 2023-01-25_23-10.png
    • https://i3wm.org/docs/userguide.html#_scratchpad

  • #Shell shortcut keys
    • ctrl + u //剪切 (当前行)
    • ctrl + y //粘贴 (被命令删除的文字)
    • ctrl + w //删除光标左边一个单词 (w: word)
    • ctrl + e //移动到行尾 (e: end)
    • ctrl + a //移动到行首
    • ctrl + k //删除从光标到行尾的内容
    • ctrl + l //清屏 (相当于 clear)
    • alt + . # Parameters of the previous command
  • References
    • zsh的快捷键操作 - 掘金
  • [[i3]]Automatically starting applications on i3 startup (开机自动打开应用)
    • exec command //自动在终端执行命令
    • 注意事项
    • command //这个是能在终端执行的命令 (举例:在终端输入alacritty能够打开终端模拟器,则command为alacritty;在终端输入chromium能够打开网页浏览器,则command为chromium;……)
    • 参考资料
    • https://i3wm.org/docs/userguide.html#_automatically_starting_applications_on_i3_startup
    • image.png

  • Assign applications to workspace in #i3

    • assign [class="st-256color"] number 1
  • Notes
    • st-256colors # A class name
      • xprop # Type it in terminal and then click an applications you want to get class name
    • 1 # Replace the workspace name with other number (e.g. 2, 3, etc.)
  • References
    • image.png
    • image.png
    • https://www.youtube.com/watch?v=lvLExb1SUzM&ab_channel=EF-LinuxMadeSimple
    • https://i3wm.org/docs/userguide.html#assign_workspace

  • 今天(2022-08-26),查看 archiso 的 shell,它的默认 shell 为 zsh
    • 总结:可以使用 zsh 的快捷键,进行操作 archiso
    • 参考资料
    • image.png
  • [[i3]] and [[Vim]] move hotkey
    • jkl; //i3 默认移动键
    • hjkl //vim 默认移动键
    • Notice
    • $mod+d //与 horizontal 热键冲突 (请修改 horizontal 的热键,比如:$mod+semicolon)
    • hjkl //统一 i3 与 vim 移动键
  • [[i3]] [[sound]]
    • 修改前
    • image.png
    • 修改后
    • image.png
    • Notice
    • $mod+F10 +10% $mod+F9 -10%//音量增加/减少 (请根据你自己电脑的音量键,设置相应的键,你也可以自定义)
    • mute $mod+F11 //静音键 (同上,mute: 沉默的)
    • $mod+Shift+r //重启 i3 (然后按下静音键) (如果没有声音的话)
  • [[Logseq]]上传文件
    • /Upload an asset //上传文件 (在 logseq 中输入此命令)
  • [[i3]] [[screenshot]]
    • bindsym Print exec flameshot gui //开启截图 (如果没有 flameshot 的话,请安装 flameshot)

  • Set gaps in i3

    for_window [class="^.*"] border pixel 6 //隐藏窗口标题栏,并设置窗口边框像素(可以自定义数字)
    gaps inner 5 //相邻 window(窗口)之间的距离
    gaps outer 0 //window(窗口)与屏幕边缘之间的距离
    smart_gaps on //如果 workspace(工作空间)只有一个 window(窗口),将禁用 gaps(间隙)
    
  • Notes
    • Draw only if more than one container is in the workspace
      smart_gaps on
      smart_boards on
      
  • References
    • image.png
    • image.png
    • image.png
    • https://www.reddit.com/r/i3wm/comments/kjzehs/is_possible_to_add_gaps_when_only_one_window_is/
    • https://wiki.gentoo.org/wiki/I3#Configuring_gaps_between_tiled_windows_.28i3-gaps_only.29

  • [[i3]] [[exit]]
    • bindsym $mod+Shift+e exit //退出 i3,不用鼠标 (移除 "exec ……" 这个警告,并添加 "exit")
  • [[i3]]改变聚焦 (避免与浏览器快捷键冲突,如果你的 $mod 键是alt的话)
    #bindsym $mod+Left focus left //注释这行
    #bindsym $mod+Down focus down //注释这行
    #bindsym $mod+Up focus up //注释这行
    #bindsym $mod+Right focus right //注释这行
    
  • [[Vim]]行间移动
    • 10j //向下10行 (number (数字) + h/j/k/l,你可以自定义)
  • [[i3]] [[i3status]] 取消状态栏图标
    • 在行首,添加注释 (i3status 的配置文件)
    • image.png
    • Notice
    • locate i3status //查找 i3status 的配置文件 (使用 locate 命令)

  • Use "locate"

    • locate awesome # Locate file including "awesome" text
  • Notes
    • awesome # Replace it with your desired file name
    • doas emerge -aq sys-apps/mlocate # Install it in Gentoo Linux
    • doas updatedb # Update the database before locating
    • doas groupadd mlocate # Add a group to solve the problem
      [yaoniplan@tux:~]$ sudo updatedb
      updatedb: can not find group `mlocate'
      [yaoniplan@tux:~]$
      
  • References
    • https://askubuntu.com/questions/800347/cant-locate-a-directory-using-locate?
    • ChatGPT

  • [[i3]]workspace(工作区)图标
    • 将复制的图标粘贴到如图所示的位置
    • image.png
    • Notice
    • https://fontawesome.com/cheatsheet //ctrl + c 即可复制 (如果找不到可以复制的图标的话)
    • 如果没有awesome字体,请安装 ttf-font-awesome
    • References
    • https://www.youtube.com/watch?v=Bw5sDLOvN20&ab_channel=GerryStudios
  • 主机快照timeshift(快照可存其他盘,非系统盘) future #Idea
  • [[linux]] [shell]zsh
    • chsh -s /bin/zsh //改变 shell (如果没有 zsh,请安装 zsh)
    • 安装 Powerlevel10k (请在国内源/国外源,选择其中一个)
    • 国内源
    git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k
    echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
    
    • 国外源
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
    echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
    
    • exec zsh //尝试 zsh
    • p10k configure //重新自定义配置 (如果你对刚才配置的不满意的话)
    • 注意事项
    • 如果出现 zsh 没有生效的情况,请注销并重新登陆
    • ctrl + shift + e # If your zsh is't work, then please use hotkey ctrl + shift + e to exit i3 in your i3wm.(After exiting i3, you need input your password to start i3.)
    • 参考资料
    • https://github.com/romkatv/powerlevel10k#installation

  • Mount a hard drive temporarily in Unix-like

    • doas mkdir /mnt/isoFile/
    • doas mount /dev/sdc1 /mnt/isoFile/
  • Notes
    • doas umount /mnt/isoFile/ # Unmount
    • /dev/sdc1 # Replace it with block device (e.g. /dev/sdb)
      • lsblk # Get it
    • Mount in an empty directory under the /mnt/ directory
  • References
    • https://www.pathname.com/fhs/2.2/fhs-3.11.html

  • [[i3]] [[fullscreen]] [[hotkey]]
    • mod + f //全屏打开被聚焦的窗口 (f: fullscreen)
    • 参考资料
    • i3 - Gentoo Wiki
    • [[i3]] 界面功能需求(2022-08-24)
    • 窗口背景模糊
    • 聚焦边框颜色 (方便知道聚焦的窗口是哪个)
    • 顶部状态栏自定义
    • 80grz78ctfh91_1660544487184_0.png
    • 参考
    • [dwm] guess which OS i use : unixporn
  • [[i3]] autostart [[redshift]]
    • exec --no-startup-id redshift -O 1800 //开启 redshift
    • Notice
    • redshift //如果没有 redshift 的话,请安装 redshift
    • 1800 //色温 (你可以自定义)
  • picom is so slow in i3 (linux) #Idea
  • [[i3]] [[wallpaper]]
    • exec --no-startup-id feh --bg-fill /home/uesrname/wallpaper/Syu.png //开启壁纸
    • Notice
    • feh //如果没有 feh 的话,请安装 feh
    • /home/username/wallpaper/Syu.png //壁纸目录 (你可以自定义)
  • [[i3]] [[input method]] autostart
    • exec --no-startup-id fcitx5 //开启 fcitx5 (请添加在 i3 的配置文件中)
    • Notice
    • fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-zhwiki //如果没有 fcitx5 的话,请安装 fcitx5
    • /etc/environment //编辑这个文件
    GTK_IM_MODULE=fcitx //添加这一行
    QT_IM_MODULE=fcitx //添加这一行
    XMODIFIERS=@im=fcitx //添加这一行
    
  • Use "arch-chroot" in Arch Linux on btrfs

    • mount /dev/sda2 /mnt -o subvol=/@
    • arch-chroot /mnt
  • Notes
    • After the modification is completed
      • exit # Exit the chroot environment
      • umount /mnt # Unmount the filesystem
  • References
    • lsblk
    • fdisk -l
    • https://forum.endeavouros.com/t/chroot-into-a-btrfs-uefi-system-from-live-media/15986/3
    • Artificial intelligence

  • [[arch]] [[linux]] [[i3]] [[bar]] [[position]] 状态栏位置(底部或顶部)
    • 语法
    • position top|bottom
    • 例子
    bar {
        position top
    }
    
    • 参考资料
    • https://zjuyk.site/i3wm-userguide-zh/%E9%85%8D%E7%BD%AEi3bar/%E4%BD%8D%E7%BD%AE.html
  • [[i3]] [[hotkey]]layout toggle split
    • mod + shift + up/down/left/right //切换分裂布局
  • 虚拟机 vmware-workstation 在 archlinux 中,与 qemu 一样折腾 #Idea

  • Decompress a ".gz" file

    • gzip -d testData.gz
  • Notes
    • -d # Decompress
  • References
    • man gzip
    • https://medium.com/secttp/overthewire-bandit-level-12-439f655f6fd5

  • [[linux]] [[i3]]网络代理([[proxy]])
    • sudo vim /etc/environment //添加以下三行:export http_proxy="127.0.0.1:7890" export https_proxy="127.0.0.1:7890" export no_proxy="localhost,127.0.0.1"
    • 下载 clash-for-windows //2022-08-22 在用 aur 中的 clash-for-windows-bin
    • source /etc/environment //重载 /etc/environment 配置
    • 注意事项
    • i3 搜索 cfw 才能在 dmenu 中找到并打开软件
    • 参考资料
    • https://www.ahdark.com/som/1643.shtml
  • Use "chromium"

    • Prevent transparent borders on pop-up menus
      • about:flags
      • Search 'Preferred Ozone platform'
      • Set it to 'Wayland'
      • Restart the browser
    • Set dark mode in Chromium
      • about:flags
      • Type "Auto Dark Mode for Web Contents"
      • Select "Enable with selective inversion of non-image elements"
    • Disable smooth scrolling in Chromium
      • about:flags
      • Type "Smooth Scrolling"
    • Set a keyboard shortcut for extensions (e.g. Google Translate) in Chromium
      • about:extensions/shortcuts
      • Alt-t # Open or close
      • energized # Replace it with what you want and type in the extension bar
      • Tab # Press the Tab key to select the section you want to select
      • Shift-Tab # Select previous section
  • Notes
    • Another way in Gentoo Linux
      • doas vim /etc/chromium/default
        CHROMIUM_FLAGS="--force-dark-mode --enable-features=WebContentsForceDark"
        
    • In Arch Linux
      • vim ~/.config/chromium-flags.conf
        --force-dark-mode
        --enable-features=WebUIDarkMode
        
    • Another way in Gentoo Linux
      • doas vim /etc/chromium/default
        CHROMIUM_FLAGS="--disable-smooth-scrolling"
        
    • nix profile install nixpkgs#chromium # Install dependencies
  • References
    • https://blog.imlast.top/2024/12/18/2nd-hyprland/
    • https://safereddit.com/r/Fedora/comments/rkzp78/make_chrome_run_on_wayland_permanently/hyvicuy/
    • https://wiki.archlinux.org/title/Chromium#Dark_mode
    • https://wiki.gentoo.org/wiki/Chromium#Enable_dark_theme_for_pages_.28prefers-color-scheme.29
    • image.png
    • https://www.majorgeeks.com/content/page/how_to_enable_or_disable_smooth_scrolling_in_google_chrome.html
    • image.png
    • image.png
    • image.png
    • https://www.makeuseof.com/open-browser-extensions-keyboard-shortcut/

  • 我的 i3 网络代理之路
    • chromium 成功代理 2022-08-22 16-15-32.png
    • 浏览器 终端 成功代理 2022-08-22 16-40-25.png
  • [[arch]] [[linux]] [[i3]]文件管理器
    • sudo pacman -S thunar //安装文件管理器(轻量)
  • Download a file using a magnet link

    • transmission-qt
    • deluge
    • qbittorrent
  • References
    • nix-shell --packages deluge

  • [[linux]] [[i3]] [[配置]]问题 (please search something in English)
    • youtube //质量高(google: 时效性(保质期)问题; archwiki: 新手不友好问题)
  • 虚拟机需求
    1. 自动调整窗口大小
    2. 剪贴板共享
    3. 文件共享(例如:拖拽)
    • 总结:qemu 暂时放弃 //上面三点,在 archlinux 中,非常折腾 #Idea
  • [[virtualbox]]解决自动调节窗口大小问题
    1. virtualbox-ext-oracle //从aur中,安装这个包
    2. host + c //自动调节窗口大小 (使用快捷键 right + ctrl + c)
  • Extract a ".tar.gz" file in Linux

    • tar -xf chezmoi_2.28.0_linux_amd64.tar.gz -C ~/chezmoi/
  • Notes
    • mkdir ~/chezmoi/ # Make a directory before using the tar command
    • -x # Extract
    • -f # File
    • -C # Change
  • References
    • man tar
    • 2022-12-25_15-22.png
    • 2022-12-25_15-08.png
    • https://linuxize.com/post/how-to-extract-unzip-tar-gz-file/

  • [[linux]] [[arch]] [[更新]]命令
    • sudo pacman -Sy //同步(更新)库(也可以测试源速度)
    • sudo pacman -Syu //同步(更新)库并更新包

  • Use "grep"

    • grep --line-number fgpt ~/.bashrc # Get the line number (Use sed command to delete the line)
    • grep -x "$current_wallpaper" -A 1 "$wallpaper_list" | tail -1 # Get next wallpaper
    • grep -A 10 "Artificial" note/pages/Future.md # Show the next 10 lines after the line
  • Notes
    • -x # Exactly match
    • -A # After
  • References
    • 2023-04-30_19-58.png
    • man grep # /-x /-A /-B
    • ChatGPT

  • Install "virtualbox" in Arch Linux

    • doas pacman -S virtualbox virtualbox-host-modules-arch # Install packages
    • doas modprobe vboxdrv vboxnetadp vboxnetflt # Load modules
    • doas gpasswd --add yaoniplan vboxusers # Use USB
  • Notes
    • doas reboot # Make all changes effective
    • New install
      # Preferences of File
      ## General
      /home/yaoniplan/.config/virtualbox/ # Default Machine Folder
      
      ## Input
      Auto Capture Keyboard # Extended Features (Turn it off)
      
  • References
    • https://wiki.archlinux.org/title/VirtualBox

  • [[linux]] [[arch]] [[i3]] [[wm]] [[hotkey]](alt: mod1; super: mod4)
    • mod + enter //终端
    • mod + d //搜索
    • mod + number //工作区
    • mod + shift + q //关闭窗口 (q: quit)
    • mod + shift + number //移动窗口到工作区(在 manjaro-i3 中,这里的 shift 是 ctrl)
    • mod + j/k/l/; //移动焦点
    • mod + shift + e //退出 i3 (e: exit)
    • mod + h/v //水平化/垂直化窗口(在新建一个窗口之前,h: horizontal; v: vertical)
    • mod + shift + r //重启 i3 (r: reboot)(mod + shift + c //重载 i3 配置在 archlinux-i3 中没有什么用)
    • sudo vim ~/.config/i3/config //设置 i3 配置文件 (在 manjaro-i3 中,配置文件在 ~/.i3/config)
    • 参考资料
    • i3wm 的使用说明
    • manjaro i3 安装配置全记录
  • [[Git]] [[manual]]一般做好准备步骤后,手动常用命令
    1. git add . //添加到缓存区(在同步的目录下)
    2. git commit -m 'remark' //提交到版本区(remark 可以换成其他备注信息)
    3. git push //推送到远程仓库
  • Use "redshift"

    • redshift -O 1500 # One-shot
  • Notes
    • redshift -x # Reset
    • nix shell nixpkgs#redshift # Install dependencies temporarily
  • References
    • man redshift

  • [[Vim]] 快速跳转到某 [[行]] (这里的 n 为数字)
    1. ngg(nG)
    2. :n
  • [[linux]] df (disk free)显示[[磁盘]] 使用情况命令
    参考资料
    df命令-显示磁盘空间使用情况
  • 灭六国者六国也,非秦也。族秦者秦也,非天下也。(应用场景:某垄断被成功反垄断之时) #quote

  • [[鼠标]] 中键(三击)
    1. 复制粘贴 //选择后,中键(三击)
    2. 关闭浏览器标签
  • [[linux]] 一切皆文件
  • [[math]] 科学记数法
    一个数被写成一个实数a与一个10的n次幂的积
    Screenshot from 2022-08-17 18-21-28.png
    在计算机中用e来表示10的幂
    Screenshot from 2022-08-17 18-23-26.png
    Q: 怎么用?
    A: 3e5
    (3e5=3*$10^5$)
    参考资料
    科学记数法
  • [[Markdown]] 次方(上标)
    写法
    Screenshot from 2022-08-17 18-34-05.png
    预览
    Screenshot from 2022-08-17 18-34-17.png
    参考资料
    Markdown数学公式语法

  • The punctuation of "dollar sign" is "$".

  • Notes
    • Because the Shell language needs to use dollar sign to reuse variables.
  • References
    • https://en.wikipedia.org/wiki/Dollar_sign
  • [[linux]] 折腾 [[dwm]] 好累啊(主要是资源质量太低、时效性短,虽然 [[dwm]] 简洁高效,但是要配置的东西太多了,比如:显示亮度、没声音、网络代理、截图(据说 grim 可用)、笔记本触摸板……)

  • Modify brightness or backlight in Linux

    • doas vim /sys/class/backlight/intel_backlight/brightness
  • Notes
    • View maximum brightness
      • cat /sys/class/backlight/intel_backlight/max_brightnes
    • intel_backlight # Replace it your graphics card model
  • References
    • ChatGPT

  • Use "mv"

    • for f in *; do mv "$f" "230317$f"; done # Add string "230317" to the beginning of each file name
    • mv ~/Download/Trash/ ~/.trash # Rename to hidden directory
  • Notes
    • f # A variable
    • for f in *; do mv "$f" "${f:6}"; done # Remove the first 6 letters
    • for f in *; do mv "$f" "${f:0:-6}"; done # Remove the last 6 letters
  • References
    • 2023-03-23_22:32:46.png
    • ChatGPT

  • [[linux]] 安装全套教程
    1. https://github.com/LucasWang474/Arch-Configurations
    2. https://www.youtube.com/c/EFLinuxMadeSimple/playlists
    3. [archinstall-简单脚本安装]
  • [[python]] 四则运算(简便 [[计算器]] )
    1. *(乘号,举例:1386*768,回车即可得到运算结果)
  • [[linux]] [[触摸板]] 手势与鼠标的关系
    1. 单击(左键)
    2. 双击(右键)tip: 双指移动(滚轮)
    3. 三击(中键)
  • Use "readlink"

    • readlink $(which tree) # Read the hard link
  • Notes
    • Because to replace ls -l $(which tree).
  • References
    • https://nixos.asia/en/nix-first # /readlink

  • [[linux]]基础命令
    • passwd 用户名 //为用户设置密码(password 的简称)
    • useradd 用户名 //添加用户
    • 命令 -h 或 man 命令 //查看命令帮助(-h 参数的意思是 help,更加详细请使用 man 命令)
    • cd 目录 //切换目录(cd 是 change directory,tips: 目录也叫路径)
    • ls 目录 //列出目录下的文件(ls 是 list)
    • ls -l 目录 //用列表的方式列出目录下的文件(l 是 listing) Screenshot from 2022-08-16 17-44-49.png
    1. 第一个字段的第一个字符是文件类型 //-表示文件;d表示目录
    2. 第一个字段剩下的9个字符是模式(权限位) //3个一组,每组 rwx 表示 “read(读)” “write(写)” “execute(执行)”。(字母表示有这个权限;横线表示没有这个权限)
    3. 第一个字段的三组分别:所属的用户权限、所属的组权限、其他用户的权限 //比如:-rw-r--r-- 是一个文件,对于所属用户,可读可写不可执行;对于所属组,仅仅可读;对于其他用户,仅仅可读
    4. 第二个字段是硬链接数目
    5. 第三个字段是所属用户,第四个字段是所属组,第五个字段是文件大小,第六个字段是文件被修改的日期,最后是文件名
    • ls -la //以列表的形式显示全部文件(a 是 all)
    • vim hello //文本编辑器 vim 打开(若没有,则创建)一个名叫 hello 的文件
      (移动光标:上下左右键;
    1. 编辑:将光标移动到相应位置,输入 i (insert);
    2. 退出编辑模式:按 esc 键;
    3. 写入:输入 : ,在 : 后面输入 w (write),写入(保存);
    4. 退出:在 : 后面输入 q (quit),退出文件; 强制退出:在 : 后面输入 q! )

  • Use "shutdown" in Linux

    • shutdown -h 23:00 # Shut down at 23:00 today
    • shutdown -h +30 # Shut down after thirty minutes
  • Notes
    • -h # Halt
    • shutdown -h now # The same as poweroff
    • shtdown -r now # The same as reboot
    • -r # Reboot
  • References
    • man shutdown
    • image.png
    • ChatGPT

  • #linux Shell
    su 新用户名 #切换成新用户
    sudo pacman -S zsh #安装 zsh
    chsh -s /bin/zsh #修改默认的 Shell(chsh -l 可以查看已有 shell)
    git clone https://github.com/romkatv/powerlevel10k.git //下载 powerlevel10k
    sudo vim /home/用户名/.zshrc //编辑 .zshrc 并添加 source ~/powerlevel10k/powerlevel10k.zsh-theme
    

  • Use "pacman"

    • doas pacman --sync mplayer # Install a package
  • Notes
    • Switch to the previously installed version of the software
      • ls /var/cache/pacman/pkg/yt-dlp* # Check the package version available in the cache
      • doas pacman --upgrade /var/cache/pacman/pkg/yt-dlp-2024.04.09-1-any.pkg.tar.zst # Install the older version
      • doas downgrade yt-dlp # Install automatically if you don't want to install it manually (Independencies: yay -S downgrade)
    • doas pacman --remove --recursive mplayer # Remove a package with dependencies
    • doas pacman --sync --refresh --sysupgrade # Upgrade the system
      • Solve a problem that command not found
    • doas pacman --sync archlinux-keyring
      • Solve a problem that package is marginal trust
    • doas pacman --sync --refresh # Sync package databases
      • Solve a problem that the package cannot be installed
    • Use "archlinuxcn"
      • doas vim /etc/pacman.conf
        [archlinuxcn]
        Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
        
      • doas pacman --sync --refresh archlinuxcn-keyring
      • doas pacman-key --lsign-key "farseerfc@archlinux.org" # Locally sign trusted key to solve the problem
        error: archlinuxcn-keyring: signature from "Jiachen YANG (Arch Linux Packager Signing Key) <farseerfc@archlinux.org>" is marginal trust
        
      • doas pacman --sync --refresh archlinuxcn-keyring # Reinstall
      • Because to use additional packaged executable software.
  • References
    • https://mirrors.ustc.edu.cn/help/archlinuxcn.html
    • https://bbs.archlinux.org/viewtopic.php?id=267364
    • man pacman
    • ChatGPT

  • [[notion]] 工具太杂,不像是使用工具,反而是被工具使用 #Idea
  • [[vscode]] 打开 [[终端]]
    1. 查看(View)-终端(Terminal)
    2. ctrl + 单引号(快捷键)
  • 造谣成本太低(一句话的事) #quote -- in the [[future]] ,开发临时发送接受 [[邮箱]] (需求:国内网络能发送)#idea

  • 这种“只许州官放火,不许百姓点灯”的双重标准,实在是……

  • [[vscode]] 实时预览 [[Markdown]] :
    1. Ctrl + Shift + P(输入Markdown,选择Markdown:Open Preview to the Side)
    2. Ctrl + K再按v(快捷键) -- >人为刀俎我为鱼肉,这便是寻常百姓家 #quote
  • 你所谓的消息,只是传言,而非情报,要想打听到关于xxx的准确情报,必须依靠专业的情报机构,这样我们才能更快的发展自己,集中优势资源,早日将目的达成 #quote

  • Syncthing [[sync]] 文件
    1. 安装syncthing(手机、电脑端都要)
    2. 文件夹路径:/home/ss/Sync(/storage/emulated/0/Sync);文件夹标签:Sync(尽量统一)
    3. 添加设备(手机扫电脑端二维码)
    4. 版本控制-设置为保留5个版本数量(手机、电脑端都要)
  • |竖线 [[symbol]]- 今天,刚入门 [[Git]],为了同步笔记 #Idea
  • 经测试, [[Logseq]] 本地仓库能自动commit,但是需要手动push(如果能自动push的话,那就更好了)
  • 今天,清理了浏览器书签(将不常用的网站放入了 [[future]] )
  • 对我而言,米斯特软的教授了我如何更好地使用[[Logseq]]来管理生活和笔记
    在互联网上,据说
    1. ta退过学,退学前,就已经写了7年代码
    2. 退学原因:没有办法同时兼顾ta喜欢的和ta不喜欢的课程,疲于应付功课
    3. 总结:学历很重要,且不建议退学,除非已经铺好后路、拥有解决问题的能力
  • The punctuation of "caret" is "^".

    • Use in programming (e.g. Python) and mathematics
  • References
    • https://github.com/Clouder0/ClouderBlog/blob/0327eebac74220d3cb9a32851d5a3ca1bccfba0e/content/zh-cn/post/python-tutorial.md#操作符operators
    • https://en.wikipedia.org/wiki/Caret

  • 我认为,手机端开源输入法并不怎么方便(大概是我不会配置的原因,然后Gboard-Google键盘凑合用了) #Idea
  • 我认为,初步 [[study]] 管理系统由以下部分组成:
    1. 笔记([[Logseq]])
    2. 代办事项([[teambition]])
    3. 中转站([[flomo]])(可以是临时笔记、代办事项、时间日志) -- #### Add an alias email for Outlook
    • Click the icon in the upper right corner - My profile
    • Click the 'Sign-in preferences' in 'Account info'
    • Click 'Add email'
  • Notes
    • Can only add two aliases per week

  • 淡定淡定,我只是做了我该做的事 #quote

  • 动宾+有什么好处吗?
    例:参加篮球队有什么好处吗? #quote

  • 都是同行衬托的好 #quote

  • Git
    • 分布式
    • 日常使用
    • 系统管理

  • Move spam to inbox automatically in Gmail

    • Click "Create a new filter" in "Settings"
    • Type "is:spam" in the "Has the words"
    • Click "Create filter" and "OK"
    • Click "Never send it to Spam" checkbox
    • Click "Create filter"
  • Notes
    • Because to unify all mail.

  • 我认为, [[Logseq]] 只适合用来做笔记,不适合用来 [[时间管理]]#idea
  • 提问之前 在你准备要通过电子邮件、新闻群组或者聊天室提出技术问题前,请先做到以下事情:

    1. 尝试在你准备提问的论坛的旧文章中搜索答案。
    2. 尝试上网搜索以找到答案。
    3. 尝试阅读手册以找到答案。
    4. 尝试阅读常见问题文件(FAQ)以找到答案。
    5. 尝试自己检查或试验以找到答案。
    6. 向你身边的强者朋友打听以找到答案。
    7. 如果你是程序开发者,请尝试阅读源代码以找到答案。 当你提出问题的时候,请先表明你已经做了上述的努力;这将有助于树立你并不是一个不劳而获且浪费别人的时间的提问者。如果你能一并表达在做了上述努力的过程中所学到的东西会更好,因为我们更乐于回答那些表现出能从答案中学习的人的问题。 #quote
  • [[ventoy]]测试(环境:usb2.0电脑 和 usb3.0u盘)
    速度(gpt):$\overline{33}$MB/s
    速度(dos):$\overline{100}$MB/s
    结论:在这种情况下,以root权限处理文件,u盘格式dos的速度更快 #Idea
  • [有效学习:处理知识的20条规则([[anki]])](https://www.yuque.com/supermemo/wiki/20rules)
  • 我陷入了沉思:(关于壁纸)
    1. 理论上,找壁纸和欣赏壁纸都需要花费时间和精力成本(所以,我决定放弃跟壁纸有关的事情)
    2. 但是,我有时有一种壁纸能促进生产力的感觉(in the [[future]] ,调查研究实验壁纸)
  • in the [[future]] ,专业大概率选择 [[计算机科学与技术]]
  • 虽千万人吾往矣(即使面对千万人的阻止,我也要勇往直前) #quote


  • The abbreviation of "Objectives and key results" is "OKR"

    • A framework
      • Goal-setting
  • References
    • https://en.wikipedia.org/wiki/Objectives_and_key_results

  • in the [[future]] 自己制作适合自己的 winpe(别人的不放心)
    1. wepe
    2. edgeless
    3. firpe
    4. hotpe

  • in the [[future]] 笔记本电脑电池,询问注意事项(充不了电,真的难受) #Idea

  • notion的docx文件导入失败,网络不稳定,决定放弃使用,而且同步的文件没有保障[[notion]] #Idea
  • 添加 [[Google]] 账户
      1. 手机打开Google设置
      2. 点击xxx@gmail.com
      3. 点击再添加一个账号(等待核对信息)
      4. 点击创建账号 - 为我自己创建
      5. 输入名字
      6. 完善基本信息 - 下一步
      7. 点击创建您自己的 Gmail 地址-输入名字-下一步
      8. 输入密码-下一步
      9. 大致就ok了
  • mp4转mp3
    1. 下载 [[vlc]]
    2. 找到转换
    3. 添加 mp4 文件
    4. 选择转换类型 Audio-MP3
    5. 接着选择目标地址
    6. 点击start
  • 现在先优化 [[Logseq]]到这种程度,在未来的使用中,再继续优化调整 #Idea
  • in the [[future]] 自建网盘。原因:可以实现webdav服务 #Idea
  • 时间如逆旅,我亦是行人 #quote

  • average of five(五人平均值) #quote

  • 我认为,关于 [[study]] 的工具,[[Logseq]]和[[flomo]]笔记软件同时使用效果会更好 #Idea
  • 我今天听到[[Logseq]]的一个节目,他里面提到如何更好的使用 [[Logseq]] 来管理他的生活和笔记 #Idea
  • 贫穷与自由罢了 #quote

  • 把它扁平化的记下来(而不是有刻意组织地把它记下来),然后通过backthink(回想),通过tag,让它们在将来的某一天,被你查询,被你发现,那么你的这条笔记就是有意义的 #quote

  • To do
    • Important and urgent
      
      
    • Important not urgent
      
      
    • Urgent not important
      
      
    • Not urgent not important