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 / ps1
Created October 10, 2025 19:06
powershell key read
for ($i = 0; $i -eq 0) {
#鎸塃nter 鑾峰彇浣犵殑鍏綉IP...
Write-Host "鎸塃nter 鑾峰彇浣犵殑鍏綉IP..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host "姝e湪鑾峰彇鍏綉IP..."
$ip = (Invoke-WebRequest -Uri "http://ipinfo.io/ip").Content
Write-Host "浣犵殑鍏綉IP鏄? $ip"
}
Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ InitialDirectory = [Environment]::GetFolderPath('Desktop') }
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
#选择路径
InitialDirectory = [Environment]::GetFolderPath('Desktop')
#filter 后缀
Filter = 'Documents (*.docx)|*.docx|SpreadSheet (*.xlsx)|*.xlsx'
}
$Null = $FileBrowser.ShowDialog()
import-xml 的类存储在整个系统的类,直接在powershell启动时import
还有一种类是环境类。这种类只在程序/模组里启用
pip install pyinstaller
pyinstaller --onefile main.py
# Python 3
python3 -m http.server 8000
1.sudo apt install python3.12-venv
2.python3 -m venv /var/www/server/
利用flask简单做一个API 网页
1.
pip install flask
2.
from flask import Flask
import subprocess
app = Flask(__name__)
npm config set proxy=http://127.0.0.1:7890
@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.
@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