小星的编程笔记

  • Cursor使用

    1 、如何关闭多余的工作区

    ctrl+w 关闭

    2、打开或关闭终端显示

    Ctrl+` (tab上面的反引号)

    3、修改标题栏的颜色

    Ctrl + Shift + P
    → Preferences: Open Settings (JSON)

    "workbench.colorCustomizations": {
            "titleBar.activeBackground": "#3c5985",       // 深灰色
            "titleBar.activeForeground": "#fffb00",       // 橙黄色
            "titleBar.inactiveBackground": "#008000",     // 绿色
            "titleBar.inactiveForeground": "#FF8C00"      // 橙色
        }
  • AdGuard Home代理配置

    韩国代理

    [/openai.com/]168.126.63.1
    [/i.ytimg.com/]168.126.63.1
    [/yt3.ggpht.com/]168.126.63.1
    [/accounts.google.co.jp/]168.126.63.1
    [/www.google.co.kr/]168.126.63.1
    [/chatgpt.com/]168.126.63.1
    [/ab.chatgpt.com/]168.126.63.1
    [/google.com/]168.126.63.1
    [/facebook.com/]168.126.63.1
    [/www.facebook.com/]168.126.63.1
    [/youtube.com/]168.126.63.1
    [/google.com/]168.126.63.1
    [/www.google.com/]168.126.63.1
    [/gmail.com/]168.126.63.1
    [/docs.google.com/]168.126.63.1
    [/drive.google.com/]168.126.63.1
    [/outlook.com/]168.126.63.1
    [/office.com/]168.126.63.1
    [/microsoft.com/]168.126.63.1
    [/live.com/]168.126.63.1
    [/fb.com/]168.126.63.1
    [/twitter.com/]168.126.63.1
    [/instagram.com/]168.126.63.1
    [/linkedin.com/]168.126.63.1
    [/tiktok.com/]168.126.63.1
    [/netflix.com/]168.126.63.1
    [/spotify.com/]168.126.63.1
    [/soundcloud.com/]168.126.63.1
    [/vimeo.com/]168.126.63.1
    [/github.com/]168.126.63.1
    [/www.github.com/]168.126.63.1
    [/gitlab.com/]168.126.63.1
    [/bitbucket.org/]168.126.63.1
    [/stackoverflow.com/]168.126.63.1
    [/npmjs.com/]168.126.63.1
    [/docker.com/]168.126.63.1
    [/nodejs.org/]168.126.63.1
    [/python.org/]168.126.63.1
    [/openai.com/]168.126.63.1
    [/chat.openai.com/]168.126.63.1
    [/aws.amazon.com/]168.126.63.1
    [/amazon.com/]168.126.63.1
    [/googleapis.com/]168.126.63.1
    [/cloudflare.com/]168.126.63.1
    [/cloud.google.com/]168.126.63.1
    [/adobe.com/]168.126.63.1
    [/paypal.com/]168.126.63.1
    [/ebay.com/]168.126.63.1
    211.140.13.188
    223.5.5.5
    114.114.114.114

    硅谷代理

    [/openai.com/]8.8.8.8
    [/i.ytimg.com/]8.8.8.8
    [/yt3.ggpht.com/]8.8.8.8
    [/accounts.google.co.jp/]8.8.8.8
    [/www.google.co.kr/]8.8.8.8
    [/chatgpt.com/]8.8.8.8
    [/ab.chatgpt.com/]8.8.8.8
    [/google.com/]8.8.8.8
    [/facebook.com/]8.8.8.8
    [/www.facebook.com/]8.8.8.8
    [/youtube.com/]8.8.8.8
    [/google.com/]8.8.8.8
    [/www.google.com/]8.8.8.8
    [/gmail.com/]8.8.8.8
    [/docs.google.com/]8.8.8.8
    [/drive.google.com/]8.8.8.8
    [/outlook.com/]8.8.8.8
    [/office.com/]8.8.8.8
    [/microsoft.com/]8.8.8.8
    [/live.com/]8.8.8.8
    [/fb.com/]8.8.8.8
    [/twitter.com/]8.8.8.8
    [/instagram.com/]8.8.8.8
    [/linkedin.com/]8.8.8.8
    [/tiktok.com/]8.8.8.8
    [/netflix.com/]8.8.8.8
    [/spotify.com/]8.8.8.8
    [/soundcloud.com/]8.8.8.8
    [/vimeo.com/]8.8.8.8
    [/github.com/]8.8.8.8
    [/www.github.com/]8.8.8.8
    [/gitlab.com/]8.8.8.8
    [/bitbucket.org/]8.8.8.8
    [/stackoverflow.com/]8.8.8.8
    [/npmjs.com/]8.8.8.8
    [/docker.com/]8.8.8.8
    [/nodejs.org/]8.8.8.8
    [/python.org/]8.8.8.8
    [/openai.com/]8.8.8.8
    [/chat.openai.com/]8.8.8.8
    [/aws.amazon.com/]8.8.8.8
    [/amazon.com/]8.8.8.8
    [/googleapis.com/]8.8.8.8
    [/cloudflare.com/]8.8.8.8
    [/cloud.google.com/]8.8.8.8
    [/adobe.com/]8.8.8.8
    [/paypal.com/]8.8.8.8
    [/ebay.com/]8.8.8.8
    211.140.13.188
    223.5.5.5
    114.114.114.114
    

    刷新dns缓存

    ipconfig /flushdns
  • Ubuntu 24快速搭建wireguard

    curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
    chmod +x wireguard-install.sh
    sudo ./wireguard-install.sh
    
    一键搭建脚本  一路ok  即可

    下载 wireguard 软件

    https://www.wireguard.com/install/
    建议选择msi
    https://download.wireguard.com/windows-client/
    找到
    wireguard-installer.exe 下载
    
    配置  客户端
    
    /home/ubuntu/wg0-client-xiao2.conf
    
    创建新用户  选择1
    
    sudo ./wireguard-install.sh 
    Welcome to WireGuard-install!
    The git repository is available at: https://github.com/angristan/wireguard-install
    
    It looks like WireGuard is already installed.
    
    What do you want to do?
       1) Add a new user
       2) List all users
       3) Revoke existing user
       4) Uninstall WireGuard
       5) Exit
    Select an option [1-5]: 
    
    填入名字
    
    
    
    配置 国内  AllowedIPs
    AllowedIPs = 0.0.0.0/8, 1.1.1.1/32, 2.0.0.0/8, 4.0.0.0/8, 5.0.0.0/8, 6.0.0.0/8, 8.8.8.8/32, 9.0.0.0/8, 12.0.0.0/8, 13.0.0.0/8, 15.0.0.0/8, 16.0.0.0/8, 17.0.0.0/8, 18.0.0.0/8, 20.0.0.0/8, 23.0.0.0/8, 24.0.0.0/8, 26.0.0.0/8, 28.0.0.0/8, 31.13.0.0/16, 32.0.0.0/8, 37.0.0.0/8, 38.0.0.0/8, 40.0.0.0/8, 41.0.0.0/8, 44.0.0.0/8, 46.0.0.0/8, 48.0.0.0/8, 50.0.0.0/8, 52.0.0.0/8, 53.0.0.0/8, 54.0.0.0/8, 55.0.0.0/8, 56.0.0.0/8, 57.0.0.0/8, 62.0.0.0/8, 63.0.0.0/8, 64.0.0.0/8, 65.0.0.0/8, 67.0.0.0/8, 68.0.0.0/8, 69.0.0.0/8, 70.0.0.0/8, 71.0.0.0/8, 72.0.0.0/8, 73.0.0.0/8, 74.0.0.0/8, 76.0.0.0/8, 80.0.0.0/8, 81.0.0.0/8, 82.0.0.0/8, 83.0.0.0/8, 84.0.0.0/8, 86.0.0.0/8, 87.0.0.0/8, 88.0.0.0/8, 92.0.0.0/8, 93.0.0.0/8, 94.0.0.0/8, 95.0.0.0/8, 96.0.0.0/8, 100.0.0.0/8, 102.0.0.0/8, 104.0.0.0/8, 105.0.0.0/8, 107.0.0.0/8, 108.0.0.0/8, 109.0.0.0/8, 128.0.0.0/8, 129.0.0.0/8, 130.0.0.0/8, 131.0.0.0/8, 132.0.0.0/8, 133.0.0.0/8, 134.0.0.0/8, 135.0.0.0/8, 136.0.0.0/8, 137.0.0.0/8, 138.0.0.0/8, 139.0.0.0/8, 141.0.0.0/8, 142.0.0.0/8, 143.0.0.0/8, 144.0.0.0/8, 145.0.0.0/8, 146.0.0.0/8, 147.0.0.0/8, 148.0.0.0/8, 149.0.0.0/8, 150.0.0.0/8, 151.0.0.0/8, 152.0.0.0/8, 153.0.0.0/8, 154.0.0.0/8, 155.0.0.0/8, 156.0.0.0/8, 157.0.0.0/8, 158.0.0.0/8, 159.0.0.0/8, 160.0.0.0/8, 161.0.0.0/8, 162.0.0.0/8, 163.0.0.0/8, 164.0.0.0/8, 165.0.0.0/8, 166.0.0.0/8, 167.0.0.0/8, 168.0.0.0/8, 169.0.0.0/8, 170.0.0.0/8, 171.0.0.0/8, 172.0.0.0/8, 173.0.0.0/8, 174.0.0.0/8, 175.0.0.0/8, 176.0.0.0/8, 180.0.0.0/8, 181.0.0.0/8, 182.0.0.0/8, 184.0.0.0/8, 185.60.0.0/16, 188.0.0.0/8, 189.0.0.0/8, 190.0.0.0/8, 193.0.0.0/8, 194.0.0.0/8, 195.0.0.0/8, 196.0.0.0/8, 198.0.0.0/8, 199.0.0.0/8, 200.0.0.0/8, 204.0.0.0/8, 205.0.0.0/8, 206.0.0.0/8, 208.0.0.0/8, 212.0.0.0/8, 213.0.0.0/8, 214.0.0.0/8, 216.0.0.0/8, 224.0.0.0/8
    
    
    注意 Endpoint = 111.222.111.222:62986
    写入公网ip 否则无法上网
    
    
    代理走国内配置dns
    
    下载  AdGuardHome_windows_amd64.zip
    github地址
    https://github.com/AdguardTeam/AdGuardHome/releases
    
    解压后双击打开  AdGuardHome.exe
    
    本地地址
    http://127.0.0.1:3000   后面设置完 可能改为 http://127.0.0.1:80  了
    
    
    
    设置监听地址  选择本地lookback  地址  
    DNS server:
    127.0.0.1:53
    
    
    设置  -->   dns设置
    
    上游dns设置
    国外使用8.8.8.8  其他默认使用国内的
    
    [/openai.com/]8.8.8.8
    [/chatgpt.com/]8.8.8.8
    [/google.com/]8.8.8.8
    [/cursor.com/]8.8.8.8
    [/facebook.com/]8.8.8.8
    [/youtube.com/]8.8.8.8
    [/google.com/]8.8.8.8
    [/gmail.com/]8.8.8.8
    [/docs.google.com/]8.8.8.8
    [/drive.google.com/]8.8.8.8
    [/outlook.com/]8.8.8.8
    [/office.com/]8.8.8.8
    [/microsoft.com/]8.8.8.8
    [/live.com/]8.8.8.8
    [/fb.com/]8.8.8.8
    [/twitter.com/]8.8.8.8
    [/instagram.com/]8.8.8.8
    [/linkedin.com/]8.8.8.8
    [/tiktok.com/]8.8.8.8
    [/netflix.com/]8.8.8.8
    [/spotify.com/]8.8.8.8
    [/soundcloud.com/]8.8.8.8
    [/vimeo.com/]8.8.8.8
    [/github.com/]8.8.8.8
    [/gitlab.com/]8.8.8.8
    [/bitbucket.org/]8.8.8.8
    [/stackoverflow.com/]8.8.8.8
    [/npmjs.com/]8.8.8.8
    [/docker.com/]8.8.8.8
    [/nodejs.org/]8.8.8.8
    [/python.org/]8.8.8.8
    [/openai.com/]8.8.8.8
    [/chat.openai.com/]8.8.8.8
    [/aws.amazon.com/]8.8.8.8
    [/amazon.com/]8.8.8.8
    [/googleapis.com/]8.8.8.8
    [/cloudflare.com/]8.8.8.8
    [/cloud.google.com/]8.8.8.8
    [/adobe.com/]8.8.8.8
    [/paypal.com/]8.8.8.8
    [/ebay.com/]8.8.8.8
    211.140.13.188
    223.5.5.5
    
    选择最快的ip地址
    应用
    
    DNS 缓存配置
    启用
    覆盖最小 TTL 值
    600
    覆盖最大 TTL 值
    86400
    保存
    
    
    
    然后配置  wireguard  
    DNS = 127.0.0.1
    
    
    测试是否成功  这样就对了
    
    nslookup google.com
    服务器:  activate.navicat.com
    Address:  127.0.0.1
    
    非权威应答:
    名称:    google.com
    Addresses:  2404:6800:4012:8::200e
              142.251.218.174
    
    
    
    设置AdGuardHome  自启动  为服务程序
    在安装目录右键  打开终端 powershell
    .\AdGuardHome.exe -s install   安装服务  设置为自动
    .\AdGuardHome.exe -s start   启动服务
    
    
  • Windows安装Redis

    安装Redis-x64-5.0.14.1.msi

    配置文件设置

    找到 安装目录下的 redis.windows-service.conf

    #修改最大内存

    maxmemory 4gb

    #设置出错时允许写入 避免一些报错

    stop-writes-on-bgsave-error no

    #设置端口号

    port 6379

    #设置允许内网和本地访问redis(以空格隔开可以多个)

    bind 192.168.1.150 127.0.0.1

    #设置redis密码

    requirepass your_strong_password

  • Windows定时任务报错原因

    终端程序 对于有空格的需要加上引号 否则报错
    “C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.22.11141.0_x64__8wekyb3d8bbwe\wt.exe”

    运行参数
    -w 0 nt -p “PowerShell” “C:\Users\Administrator\Desktop\fsdownload\venv\Scripts\python.exe” “C:\Users\Administrator\PycharmProjects\pythonProject2\新脚本\ttt.py”

  • git常用命令

    git常用命令

    # 查看提交历史,找到要回退的commit hash

    git log –oneline

    恢复到以前的某个版本

    git reset –hard 93424a2

    # 强制推送,会覆盖远程的提交历史(之前的一些提交)

    git push –force origin master

    强制拉取远程 覆盖本地

    git pull –force origin master

    丢弃所有未提交的修改,回到最近一次提交的状态

    git reset –hard HEAD

    查看分支

    git branch

    切换分支

    git checkout feature-xc

    验证结果

    git branch

    # 查看当前状态

    git status

    ————文件冲突 checkout 文件名 进行覆盖 ——–

    # 方法 A:直接 checkout 覆盖(保留文件但内容变回远程版本)

    git checkout HEAD — .env

    git pull origin master

    —————– 如何忽略文件———–

    git rm –cached .env

    . 确保 .gitignore 已包含 .env

    提交本次修改

    git add .gitignore

    git commit -m “停止监控并忽略 .env文件”

    git push origin master

  • windows镜像下载地址

    server 2025

    server 2022

    win11 24H2

    • ed2k://|file|zh-cn_windows_11_business_editions_version_24h2_updated_aug_2025_x64_dvd_08e70c15.iso|7260784640|46437315738020E5643BF5139395B704|/

    win11 21H2

    • ed2k://|file|zh-cn_windows_11_business_editions_version_21h2_updated_aug_2022_x64_dvd_01ab3d1a.iso|5773361152|E2E979BB3A24CFF03011C6888D4F3C8E|/

    win11 22H2

    • ed2k://|file|zh-cn_windows_11_business_editions_version_22h2_updated_oct_2023_x64_dvd_370ed1b7.iso|6615459840|8F46CEFA55F43404535AF960B4784E67|/

    win11 23H2

    • ed2k://|file|zh-cn_windows_11_business_editions_version_23h2_updated_sep_2024_x64_dvd_22316bf2.iso|7094269952|9437FD5D778E65B27176BA17CF40BC32|/

    win11 LTSC

    • ed2k://|file|zh-cn_windows_11_enterprise_ltsc_2024_x64_dvd_cff9cd2d.iso|5287520256|D6E4FE0BA5FD8A2F22FC9C0326481791|/

    win7

    • ed2k://|file|cn_windows_7_ultimate_with_sp1_x64_dvd_u_677408.iso|3420557312|B58548681854236C7939003B583A8078|/

    win7 英文版

    • ed2k://|file|7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso|5876357120|9C55A020B327AD60CB8A37D0317743F2|/

    xp

    • ed2k://|file|zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_x14-80404.iso|630239232|CD0900AFA058ACB6345761969CBCBFF4|/

    win10 LTSC 2021

    • ed2k://|file|SW_DVD9_WIN_ENT_LTSC_2021_64BIT_ChnSimp_MLF_X22-84402.ISO|5044211712|1555B7DCA052B5958EE68DB58A42408D|/

    win10 LTSB 2016

    ed2k://|file|cn_windows_10_enterprise_2016_ltsb_x64_dvd_9060409.iso|3821895680|FF17FF2D5919E3A560151BBC11C399D1|/

    win10 1909

    • magnet:?xt=urn:btih:CACC1E9EEC070BE56F939863E189EAE3116F98E4&dn=cn_windows_10_business_editions_version_1909_updated_april_2020_x64_dvd_5d3fcf2e.iso&xl=5420953600

    win10 21h2

    • ed2k://|file|zh-cn_windows_10_business_editions_version_21h2_updated_june_2023_x64_dvd_74594186.iso|5992781824|8330E81B21382B195F86EE4CED2320D8|/

    win10 22h2

    • ed2k://|file|zh-cn_windows_10_business_editions_version_22h2_updated_aug_2025_x64_dvd_b6baaad4.iso|6802696192|5D326D747342928B5E5949993FB43249|/

    2016长期版本 32位

    • ed2k://|file|cn_windows_10_enterprise_2016_ltsb_x86_dvd_9057089.iso|2817034240|67C3865D03E765BDD4845BA2CB7649F8|/

    2016长期版本 64位

    • ed2k://|file|cn_windows_10_enterprise_2016_ltsb_x64_dvd_9060409.iso|3821895680|FF17FF2D5919E3A560151BBC11C399D1|/

  • 激活windows常用命令

    比较实用的 使用power shell 运行以下命令

    激活系统

    irm https://get.activated.win | iex

    irm https://massgrave.dev/get | iex

  • 正则表达式

    断言的几种方式
    (1)\b  单词边界    \b并不匹配任何内容,他只是标记文本的位置   整个文本的第一个单词一定是边界 .,|'",。等等也是边界 
    例如
    row tomorrow.haha.
    使用正则表达式
    \b(\w+)  
    可以匹配如下内容
    (2)^  开头后面必须是 ***
    $   结束之前必须是***
    ------------------------------------举例-------------------------
    string = '''hahahha cfldk
    bbbbb sdfdl;
    ccccc sdmflkd
    '''
    print(string)
    #(?m)是多行模式   不加是普通模式匹配整个文本  在多行模式下  一共有4行  最后一行什么都没有是 空‘’
    pattern1 = re.compile(pattern='(?m)^(\w?)')
    pattern2 = re.compile(pattern='^\w?')
    res1 = pattern1.findall(string=string)
    res2 = pattern2.findall(string=string)
    #findall 返回一个列表  ['h', 'b', 'c', '']  里表里面装的字符串
    print(res1)
    print(res2)
    #finditer 返回的是一个迭代器,适合处理大量数据或当只需要部分匹配结果时。
    res = pattern1.finditer(string)
    for i in res:
        print(i)   #默认是整个匹配对象  i 是一个 Match 对象。这个对象包含了关于每一次匹配的所有信息。
        print(i.group())  #打印正则匹配的结果字符串   返回匹配到的文本。
        print(i.group(0))  #打印正则匹配的结果字符串   返回匹配到的文本。
        #print(i.string)  #打印正则匹配的结果字符串   返回整个原始字符串。
        #print(i.start())  #打印正则匹配的开始位置
        #print(i.end())   #打印正则匹配的结束位置
    '''
    import re
    pattern = re.compile(r'(\w+) (\w+)')
    string = "John Doe is a developer"
    res = pattern.finditer(string)
    for i in res:
        print("Entire Match:", i.group(0))  # 等同于 i.group()
        print("First Group:", i.group(1))
        print("Second Group:", i.group(2))
        print("All Groups:", i.groups())   #返回所有子组的文本,以元组的形式返回。在这个例子中,("John", "Doe") 是所有子组的文本。
        print()
        
    i.group(0) 或 i.group():
    返回整个匹配的文本。在这个例子中,"John Doe" 是整个匹配的文本。
    i.group(1):
    返回第一个子组的文本。在这个例子中,"John" 是第一个子组的文本。
    i.group(2):
    返回第二个子组的文本。在这个例子中,"Doe" 是第二个子组的文本。
    i.groups():
    返回所有子组的文本,以元组的形式返回。在这个例子中,("John", "Doe") 是所有子组的文本。
    '''
    --------------------------------------------------------------------------------
    (3)    (?m) 表示多行模式
           (?s) 表示单行模式    默认模式:点号 . 不匹配换行符 \n。单行模式 (?s):点号 . 可以匹配任何字符,包括换行符 \n。
           (?i) 不区分大小写
           
    (4)环视的用法如下图:
    import re
    string = '''
    hahahha cfldk
    bbbbb sdfdl;
    ccccc sdmflkd
    '''
    #前面是bb 后面是字母 的字符串  但是不包含前面的 bb
    pattern1 = re.compile(pattern='(?<=bb)\w+')
    #结果是匹配 bbb  而不是 bbbbb
    #finditer 返回的是一个迭代器,适合处理大量数据或当只需要部分匹配结果时。
    res = pattern1.finditer(string)
    for i in res:
        print(i)   #默认是整个匹配对象  i 是一个 Match 对象。这个对象包含了关于每一次匹配的所有信息。
        print(i.group())  #打印正则匹配的结果字符串   返回匹配到的文本。
        print(i.group(0))  #打印正则匹配的结果字符串   返回匹配到的文本。
  • centos7 安装php7.4

    ✅ 步骤 1:安装 EPEL 和 Remi 仓库

    sudo yum install -y epel-release

    安装 Remi 仓库(提供最新 PHP 版本)

    sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

    ✅ 步骤 2:启用 PHP 7.4 模块

    安装 yum-utils(提供 yum-config-manager 命令)

    sudo yum install -y yum-utils

    禁用默认 PHP 模块(如有)

    sudo yum-config-manager –disable remi-php*

    启用 PHP 7.4 ✅ 这一步是关键!确保系统使用 Remi 的 PHP 7.4 而不是旧版。

    sudo yum-config-manager –enable remi-php74

    ✅ 步骤 3:安装 PHP 7.4 及常用扩展

    sudo yum install -y php php-cli php-fpm php-mysqlnd php-gd php-xml php-mbstring php-json php-opcache php-curl php-zip