Arterning's Blog and Documentation

website·Indexed 30 days ago

https://arterning.github.io/blogs/

A personal knowledge base and blog featuring technical notes on Git, SSH, Linux, and Windows command-line references, as well as guides on proxy configuration and environment setup using UV and NVM.

Tokens
6.8K
Snippets
55
Records
62
Agent score
68%

What's inside Arterning's Blog

  1. Windows Command Line Environment Overview

    This guide covers common commands for Windows PowerShell 5.1 and CMD. When using PowerShell, you can use Get-Alias to view command aliases and Get-Command <name> to identify the source of a specific command. Note that many commands share the same name across CMD and PowerShell but exhibit different behaviors and parameter requirements. Commands that modify system settings typically require the terminal to be launched with 'Run as Administrator'.
    Get-Alias
    Get-Command <command_name>
  2. Create standalone pages using file-based routing

    To create a standalone page, add a Markdown (.md) or React (.js) file to the src/pages directory. The file path determines the URL path on the site. For example:

    • src/pages/index.js maps to the root /
    • src/pages/foo.md maps to /foo
    • src/pages/foo/bar.js maps to /foo/bar
  3. Get help for Linux commands

    Most Linux commands provide detailed documentation and usage instructions through the manual pages or a help flag. Use man <command> to open the full manual or <command> --help for a concise summary of options.
    man ls
    ls --help
  4. Execute SSH commands in non-interactive scripts

    For automation, use specific options to bypass host key prompts and avoid interactive input.
    # Fully automated execution using a specific key and ignoring host checks
    ssh -i ~/.ssh/deploy -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@host "deploy.sh"
    
    # Using sshpass for password-based automation (Test environments only!)
    sshpass -p 'pass' ssh user@host "uptime"
  5. Initialize and clone Git repositories

    Commands for creating a new local repository or copying an existing remote repository, including options for shallow clones and submodules.
    git init                # Initialize repository
    git clone url           # Clone repository
    git clone --depth 1 url # Shallow clone (only latest commit, faster for large repos)
    git clone --recursive url    # Clone and pull submodules
    git clone -b dev url    # Clone a specific branch
  6. Create SSH tunnels for port forwarding

    SSH tunnels allow you to forward traffic between your local machine and a remote server or its internal network.
    # Local Forwarding (-L): Local port -> Remote target
    # Access http://localhost:8080 to reach http://10.0.0.5:80 via jump-host
    ssh -L 8080:10.0.0.5:80 user@jump-host
    
    # Remote Forwarding (-R): Remote port -> Local target
    # Expose local port 3000 to the remote server's port 9000
    ssh -R 9000:localhost:3000 user@server
    
    # Dynamic Forwarding (-D): SOCKS5 Proxy
    ssh -D 1080 user@host
    # Use with curl: curl --socks5 127.0.0.1:1080 https://www.google.com
    
    # Background tunnel without shell
    ssh -CNfg -L 3306:db.internal:3306 jump
    # -C: compress, -N: no command, -f: background, -g: allow other machines to connect
  7. Manage Git tags

    Create lightweight or annotated tags to mark specific points in history (e.g., releases) and push them to remote servers.
    git tag v1.0.0          # Create lightweight tag
    git tag -a v1.0.0 -m "release 1.0.0"   # Create annotated tag (recommended)
    git tag -l "v1.*"       # List tags matching pattern
    git tag -d v1.0.0       # Delete local tag
    git push origin v1.0.0  # Push specific tag
    git checkout v1.0.0     # Checkout tag (enters detached HEAD state)
  8. Use Git stash for temporary storage

    Temporarily shelf uncommitted changes to clean the working directory without creating a commit.
    git stash               # Stash current changes
    git stash list          # List all stashes
    git stash pop           # Restore and remove latest stash
    git stash apply         # Restore but keep in list
    git stash drop stash@{0}  # Delete specific stash
    git stash save "msg"    # Stash with a description
    git stash -u            # Stash including untracked files
  9. Create a basic document in Docusaurus

    To create a new document, create a Markdown file within the docs directory. Docusaurus automatically generates a route based on the filename. For example, a file at docs/hello.md will be available at /docs/hello.
    # Hello
    
    This is my **first Docusaurus document**!
  10. Add syntax-highlighted code blocks with titles

    Markdown code blocks are supported with syntax highlighting. You can optionally add a title attribute to the language tag to display the filename or a label above the code block.
    ```jsx title="src/components/HelloDocusaurus.js"
    function HelloDocusaurus() {
        return (
            <h1>Hello, Docusaurus!</h1>
        )
    }
  11. Create and organize blog posts in Docusaurus

    Docusaurus blogging features are powered by the @docusaurus/plugin-content-blog plugin. To create blog posts, add Markdown files or folders to the blog directory.

    Post dates are automatically extracted from filenames using the format YYYY-MM-DD-title.md (e.g., 2019-05-30-welcome.md). Alternatively, you can use a folder with an index.md file (e.g., 2019-05-30-welcome/index.md), which is useful for co-locating images with the post content. The blog also supports tags and a dedicated authors.yml file for managing regular blog authors.

  12. Create interactive Docusaurus blog posts using MDX

    Docusaurus blog posts support MDX (Markdown for component era), which allows developers to embed React components directly within markdown files to create interactive content.
    <button onClick={() => alert('button clicked!')}>Click me!</button>