Git Command

Shows the current status of the working directory and staging area:

git status

Stages all changes in the current directory and its subdirectories:

git add .

Commits the staged changes with a message:

git commit -m "your comment"

Discards any changes in the working directory and resets to the last committed state:

git checkout -- .

Displays the commit history, and shows each commit summary in a single line:

git log --pretty=oneline

View Logs with Graphical Representation:

git log --graph --oneline --all

Hard reset: commits, staging area, and working directory are reverted.

git reset --hard HEAD^

Soft reset: only commits are reverted while staged and working changes stay.

git reset --soft HEAD^	

Check the detailed difference:

git diff

List all branches and highlight the current branch:

git branch

Switch to a Branch:

git checkout <branch-name>

Create and Switch to a New Branch:

git checkout -b <new-branch-name>

Rename master to main:

git branch -m master main

Rename a Remote Repository:

git remote rename origin new-origin

Reset the current branch to match the state of the local feature branch exactly:

git reset --hard feature

Reset the current branch to match the state of the remote new-feature branch exactly:

git reset --hard origin/new-feature

Merge Feature Branch into main:

git merge feature-new-feature

Delete a Local Branch

git branch -d <branch-name>

Delete the Remote master Branch:

git push origin --delete master

Remove a Remote Repository:

git remote remove origin

Show Remote Repositories:

git remote -v

Add a Remote Repository:

git remote add origin <remote-url>

Download changes from the remote branch:

git fetch origin <branch-name>

Pull Latest Changes from Remote to Current Local Branch:

git pull origin <branch-name>

Push Local Branch to Remote:

git push origin <branch-name>

Push the main Branch to Remote(set default upstream branch as origin):

git push -u origin main

Clone the specified GitHub repository via SSH:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/private-key-repository
git clone git@github.com:xxx/yyy.git

How to Install and Use CrewAI in a Virtual Environment

Step 1: Create a virtual environment

python3 -m venv venv

Step 2: Activate the virtual environment

source venv/bin/activate

Step 3: Install CrewAI with additional tools

pip install 'crewai[tools]'

Step 4: Run the Python script using the virtual environment’s Python interpreter

$(which python) 7.xxx.py

Steps to Update Domain DNS Servers to Cloudflare and Verify Google Workspace Ownership

1. Update Domain DNS Servers to Cloudflare

1.1 Login to Your Domain Registrar Account

  • Log in to your domain registrar account (e.g., AWS Route 53 or other registrars).

1.2 Get Cloudflare’s DNS Servers

  • Cloudflare provides two DNS server addresses for your domain:
    • xxx.ns.cloudflare.com
    • yyy.ns.cloudflare.com

1.3 Update DNS Servers at Your Domain Registrar

To make changes in AWS Route 53:

  • Log in to the AWS Management Console: Open the AWS Management Console and log in with your account.
  • Navigate to the Route 53 console: Among the service list, find and select Route 53.
  • Select the “Registered Domains” section: In the left menu, select “Registered Domains.”
  • Find and select your domain zzz.com: Find your domain and click to enter.
  • Update DNS servers: In the domain details page, find the “Name Servers” section and click “Add or edit name servers.” Replace the existing DNS server addresses with the ones provided by Cloudflare:
    • xxx.ns.cloudflare.com
    • yyy.ns.cloudflare.com
  • Save changes.

1.4 Verify DNS Server Update

  • Wait for DNS updates to take effect: DNS server changes can take a few minutes to 24 hours to propagate.
  • Use nslookup or dig tools to verify:
    nslookup -type=ns zzz.com
    or
    dig ns zzz.com
    Confirm that the returned DNS server addresses are those provided by Cloudflare.

Apply for Cloud Identity

  • Before verifying domain ownership, refer to the Apply for Cloud Identity page and follow the guide to apply for Cloud Identity.

2. Verify Google Workspace Domain Ownership

2.1 Get Verification TXT Record

  • Log in to Google Workspace Admin Console: Visit the Google Workspace Admin Console.
  • Log in to your Google Workspace account.
  • Get the verification TXT record: In the setup wizard, Google Workspace will prompt you to verify domain ownership and provide a TXT record value, such as google-site-verification=XXXXXXX.

2.2 Log in to Cloudflare

  • Visit Cloudflare’s website: Open Cloudflare’s website and log in to your account.
  • Select your domain: In the dashboard, select the domain you want to manage, zzz.com.

2.3 Add TXT Record

  • Go to the DNS management page: Click on the “DNS” tab to enter the DNS management page.
  • Add a TXT record: Click the “Add Record” button. In the record type (Type) dropdown menu, select TXT. In the name (Name) field, enter @ (representing the root domain) or as instructed by Google Workspace. In the content (Content) field, enter the verification TXT record value provided by Google Workspace, such as:
    google-site-verification=XXXXXXX
  • Select “Auto” for TTL and click “Save” to save the record.

2.4 Verify Domain Ownership

  • Return to the Google Workspace Admin Console:
    Go back to the domain verification page in Google Workspace.
  • Complete the verification: Click the “Verify” or “Complete Verification” button. Google Workspace will check the TXT record you added to the DNS configuration, and once it finds the record, it will confirm your domain ownership.

2.5 Wait for Verification to Take Effect

  • Wait for DNS records to propagate: DNS record changes may take a few minutes to 48 hours to take effect.
  • Use command-line tools to verify TXT record:
    • Using nslookup tool:
      nslookup -type=txt zzz.com
    • Using dig tool:
      dig txt zzz.com

Deploy OpenDevin

1. pull image:

docker pull ghcr.io/opendevin/opendevin:latest

2. make the installation script setup_opendevin.sh:

echo "Starting OpenDevin setup..."
export WORKSPACE_BASE=/home/yourUserName/dev/opendevin/workspace
echo "WORKSPACE_BASE set to $WORKSPACE_BASE"

echo "Checking .env file..."
cat .env

docker run \
    -it \
    --env-file .env \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -v $WORKSPACE_BASE:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    ghcr.io/opendevin/opendevin:latest

echo "Docker container started."

3. make .env file: eg(Azure OpenAI):

LLM_BASE_URL="https://xxx.openai.azure.com/"
LLM_API_KEY=""
LLM_MODEL="azure/[yourDeployName]"
LLM_API_VERSION="2024-02-01"

4. run installation script

5.access http://localhost:3000/index.html

reference:

💻 OpenDevin

Azure OpenAI LLM

Azure OpenAI

Summary of Common WSL Commands

1.Install WSL with default Ubuntu:

wsl --install

and then reboot.

2.List Available Distributions for Installation:

wsl -l -o

output eg:

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
Ubuntu-24.04                           Ubuntu 24.04 LTS
OracleLinux_7_9                        Oracle Linux 7.9
OracleLinux_8_7                        Oracle Linux 8.7
OracleLinux_9_1                        Oracle Linux 9.1
openSUSE-Leap-15.5                     openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed                    openSUSE Tumbleweed

3. Install a certain distribution:

wsl --install -d Ubuntu-24.04

4. List Installed Linux Distributions and Their WSL Versions:

wsl -l -v

5. Set Default Version for New Linux Installations (WSL 1 or WSL 2):

wsl --set-default-version <Version#>

Replace with 1 or 2 to set the default WSL version for new Linux installations.

6. Set Default Linux Distribution:

wsl -s <DistributionName>

7. Run a Specific Linux Distribution:

wsl -d <DistributionName>

8. Upgrade or Downgrade a Specific Linux Distribution between WSL 1 and WSL 2:

wsl --set-version <distro name> <Version#>

9. Launch the Default Linux Distribution from Command Prompt or PowerShell:

wsl

10. Run Linux Commands without Switching Distributions:

wsl [command]

11. remove an installed Linux distribution in WSL:

wsl --unregister <DistributionName>

12. Default Storage Location:

C:\Users\<YourUsername>\AppData\Local\Packages\CanonicalGroupLimited...Ubuntu..._\LocalState\ext4.vhdx

13. Export an Existing Distribution:

wsl --export <DistributionName> <ExportFilePath>
# eg: wsl --export Ubuntu C:\backups\ubuntu.tar

14. Import to a Custom Location:

wsl --import <NewDistributionName> <TargetFolder> <ImportFilePath>
# eg: wsl --import UbuntuCustom C:\wsl\UbuntuCustom C:\backups\ubuntu.tar

WSL を使用して Windows に Linux をインストールする方法

15. sets up a port proxy from any network interface on a certain port to the local machine’s port. eg:

netsh interface portproxy add v4tov4 listenport=2358 listenaddress=0.0.0.0 connectport=2358 connectaddress=127.0.0.1

just edit /etc/wsl.conf:

[boot]
systemd=true
[user]
default=fsi
[interop]
enabled=true
appendWindowsPath=true

  • Enables systemd
  • Sets default user fsi
  • Lets WSL run Windows apps
  • Adds Windows paths to $PATH

Restart WSL to apply

Steps to Create Users and Assign Databases in PostgreSQL

Log in to PostgreSQL:

psql -U postgres

Create two new users (user1 and user2):

CREATE USER user1 WITH PASSWORD 'yourPassword';
CREATE USER user2 WITH PASSWORD 'yourPassword';

Create databases for each user:

CREATE DATABASE user1dbshare OWNER user1;
CREATE DATABASE user1dbprivate OWNER user1;
CREATE DATABASE user2dbshare OWNER user2;
CREATE DATABASE user2dbprivate OWNER user2;

Create a common_readonly role and configure it to access shared data for all users:

CREATE ROLE common_readonly NOLOGIN;
GRANT CONNECT ON DATABASE user1dbshare TO common_readonly;
GRANT CONNECT ON DATABASE user2dbshare TO common_readonly;

GRANT USAGE ON SCHEMA public TO common_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO common_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO common_readonly;

GRANT common_readonly TO user1;
GRANT common_readonly TO user2;

Log in to each database and create a table:

For user1dbshare:

\c user1dbshare user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user1dbprivate:

\c user1dbprivate user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbshare:

\c user2dbshare user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbprivate:

\c user2dbprivate user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

Exit:

\q

Linux ACL Management

Assigning Permissions:

This command sets ACL (Access Control List) for the file yourFileName.csv.
-m option indicates modifying the ACL.
u:yourUserName:r assigns read (r) permission to the user yourUserName.

sudo setfacl -m u:yourUserName:r yourFileName.csv

Revoking Permissions

This command removes the ACL entry for the user yourUserName from the file yourFileName.csv.
-x option indicates removing a specified ACL entry.

sudo setfacl -x u:yourUserName yourFileName.csv

Setting Default Permissions (Mask)

This command sets the mask permission for the file yourFileName.csv to read, write, and execute (rwx).
The mask defines the maximum permissions allowed for users other than the owner and the group. Here, setting the mask to rwx allows users to have up to read, write, and execute permissions.

sudo setfacl -m m::rwx yourFileName.csv

Removing All ACL Entries

This command removes all ACL entries from the file yourFileName.csv, resetting it to its default permission state. -b option indicates deleting all ACL entries.

sudo setfacl -b yourFileName.csv

Viewing ACL Settings

This command displays the current ACL settings for the file yourFileName.csv.

getfacl yourFileName.csv

Enable RDP by remote pwsh

# Enable Remote Desktop by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0

# Check if there is any existing firewall rule for port 3389 (RDP)
$ExistingRule = Get-NetFirewallRule -Direction Inbound | Where-Object { $_.LocalPort -eq 3389 }

# Enable the rule if it exists
if ($ExistingRule) {
    $ExistingRule | Enable-NetFirewallRule
    "Existing Remote Desktop firewall rules have been enabled."
} else {
    # Create a new firewall rule if no existing rule is found
    New-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow
    "No existing rule found, a new Remote Desktop firewall rule has been created and enabled."
}

# Enable Network Level Authentication (NLA) by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -value 1

# Check if Remote Desktop service has been enabled
$RDPStatus = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server').fDenyTSConnections
if ($RDPStatus -eq 0) {
    "Remote Desktop is enabled"
} else {
    "Remote Desktop is not enabled"
}

Setting a Static IP in Linux with nmcli

  1. If it uses NetworkManager:
    cat /etc/netplan/01-network-manager-all.yaml :
    # Let NetworkManager manage all devices on this system
    network:
     version: 2
     renderer: NetworkManager
  2. Determine the Default Gateway:
    Use the ip route command to find out the default gateway of your network, which is essential for configuring your static IP.
    ip route | grep default | awk '{print $3}'
  3. Setting a Static IP Address:
    Replace "WifiName" with your actual connection name. Here’s how you can set a static IP address, gateway, DNS, and switch the method to manual:
    nmcli con mod "WifiName" ipv4.addresses 192.168.1.10/24
    nmcli con mod "WifiName" ipv4.gateway 192.168.1.1
    nmcli con mod "WifiName" ipv4.dns "8.8.8.8"
    nmcli con mod "WifiName" ipv4.method manual
  4. Applying the Changes:
    After setting the static IP, you need to restart the network connection to apply these changes:
    nmcli con down "WifiName"
    nmcli con up "WifiName"
  5. Reverting to DHCP (Dynamic IP):
    If you encounter any issues or decide to return to using DHCP, you can reset the configuration as follows:
    nmcli con mod "WifiName" ipv4.method auto
    nmcli con down "WifiName"
    nmcli con up "WifiName"
通过 WordPress.com 设计一个这样的站点
从这里开始