Skip to content

Instantly share code, notes, and snippets.

View CN-CODEGOD's full-sized avatar
😏
share my thought

CN-CODEGOD

😏
share my thought
View GitHub Profile
@CN-CODEGOD
CN-CODEGOD / gist:f4317bd634bdd5acf42ba5780a22b733
Created March 16, 2025 09:21
如何在powershell 上传个人模组
1.register
Register-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2"
2.获取API
访问 PowerShell Gallery 网站。https://www.powershellgallery.com/
点击 "Sign in" 并使用 Microsoft 账号登录。
进入 "API Keys" 页面,创建一个新的 API Key(建议权限为 Push-Only 以提高安全性)。
复制 API Key,稍后会用到。
3.在模组中创建psd 包含作者名字,描述,模组名字
New-ModuleManifest -Path .\console.psd1 -Description "console grid using out-consolegridview for series occasion" -Author 'cn_codegod' -ModuleVersion "1.0" -RequiredModules "Microsoft.PowerShell.ConsoleGuiTools"
基本命令
oh-my-posh init pwsh --config $env:homedir\theme3.json|Invoke-Expression
模板一:添加文字
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"version": 3,
"blocks": [
{
按下 Win + R 键打开运行对话框,输入 taskschd.msc,然后按回车。
在任务计划程序中点击“创建基本任务...”或“创建任务...”。
输入任务的名称和描述,选择触发任务的条件。
设置触发器信息,如特定时间、登录时等。
设置操作,例如运行某个程序。
查看设定好的任务。
@CN-CODEGOD
CN-CODEGOD / gist:6de8206df2c7d38e2dfab4a58bacd6b6
Created April 16, 2025 03:47
powershell psreadline key handler
Description
The Set-PSReadLineKeyHandler cmdlet customizes the result when a key or sequence of keys is pressed. With user-defined key bindings, you can do almost anything that's possible from within a PowerShell script.
Examples
Example 1: Bind the arrow key to a function
This command binds the up arrow key to the HistorySearchBackward function. This function searches command history for command lines that start with the current contents of the command line.
PowerShell
Copy
@CN-CODEGOD
CN-CODEGOD / gist:e7f65abf875f7476d80cc13546985d89
Created April 22, 2025 09:37
powershell export class from modules
# Define the types to export with type accelerators.
$ExportableTypes =@(
[DefinedTypeName]
)
# Get the internal TypeAccelerators class to use its static methods.
$TypeAcceleratorsClass = [psobject].Assembly.GetType(
'System.Management.Automation.TypeAccelerators'
)
# Ensure none of the types would clobber an existing type accelerator.
# If a type accelerator with the same name exists, throw an exception.
npm config set proxy=http://127.0.0.1:7890
利用flask简单做一个API 网页
1.
pip install flask
2.
from flask import Flask
import subprocess
app = Flask(__name__)
1.sudo apt install python3.12-venv
2.python3 -m venv /var/www/server/
# Python 3
python3 -m http.server 8000
pip install pyinstaller
pyinstaller --onefile main.py