Skip to content

Instantly share code, notes, and snippets.

View kuzhao's full-sized avatar
🚛
Working

andrewblue1988@gmail.com kuzhao

🚛
Working
View GitHub Profile
@kuzhao
kuzhao / example.txt
Last active July 26, 2025 15:46
Useful JMESPath filter for AzCLI
az network nsg list --query '[?!not_null(subnets[])&&!not_null(networkInterfaces[])].{Name:name,RG:resourceGroup,net:subnets}' -o table
Name RG
------------------------------------------ ----------------------------------------------------
aks-agentpool-31494826-nsg MC_rg-northcentral_cni-overlay-736875_northcentralus
labvnet-aci-nsg-northcentralus rg-northcentral
labvnet-apisvr-nsg-northcentralus rg-northcentral
labvnet-test-vnetapisvr-nsg-northcentralus rg-northcentral
aks-agentpool-35655542-nsg mc_rg-eastus_lab-aks-cni_eastus2
## Remove content after '.' in the --query expression. az list -o table then keeps all default fields
@kuzhao
kuzhao / Entrepreneurship.mermaid
Last active March 24, 2025 19:49
Quantic curriculum outlines
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuzhao
kuzhao / bcc-bpftrace.csv
Last active May 12, 2025 23:55
Executive summary on all available bcc/bpftrace tools (programs)
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 5 columns, instead of 3 in line 7.
tool_name,bcc/bpf,synopsis,descr,kind
argdist.py,bcc,https://github.com/iovisor/bcc/blob/master/tools/argdist_example.txt,Trace a function and display a distribution of its parameter values as a histogram or frequency count,function
bashreadline.bt,bpftrace,https://github.com/iovisor/bpftrace/blob/master/tools/bashreadline_example.txt,Print entered bash commands from all running shells,process
bashreadline.py,bcc,https://github.com/iovisor/bcc/blob/master/tools/bashreadline_example.txt,Print entered bash commands from all running shells,process
bindsnoop.py,bcc,https://github.com/iovisor/bcc/blob/master/tools/bindsnoop_example.txt,Trace IPv4 and IPv6 binds()s,network
biolatency.bt,bpftrace,https://github.com/iovisor/bpftrace/blob/master/tools/biolatency_example.txt,Block I/O latency as a histogram,disk
biolatency.py,bcc,https://github.com/iovisor/bcc/blob/master/tools/biolatency_example.txt,Summarize block device I/O latency as a histogram,disk
biolatpcts.py,bcc,https://github.com/iovisor/bcc/blob/master/tool
@kuzhao
kuzhao / Package Control.sublime-settings
Last active September 1, 2025 18:37
Useful jons/yaml config
"installed_packages":
[
"Compare Side-By-Side",
"Expand Selection to Quotes",
"Filter Lines",
"HighlightWords",
"InsertDate",
"JSON Reindent",
"Kubernetes Manifest autocomplete",
"Markdown Table Formatter",
@kuzhao
kuzhao / CertSign.ps1
Last active April 20, 2024 11:46
CA & PKI
# Generate a self-signed certificate for signing client cert
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature -Subject "CN=JaishP2SRootCert" -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign -KeyUsage CertSign
# Generate one and use above cert to sign
New-SelfSignedCertificate -Type Custom -DnsName P2SChildCert -KeySpec Signature -Subject "CN=JaishP2SChildCert" -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My" -Signer $cert -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2")
# Convert pfx content to base64 string
$fileContentBytes = get-content 'C:\users\preet\downloads\wildcard.klwines.com.pfx' -Encoding Byte
[System.Convert]::ToBase64String($fileContentBytes) | Out-File ‘pfx-encoded-bytes.txt’
@kuzhao
kuzhao / Set-AppGW.ps1
Last active July 27, 2025 00:19
Useful powershell cmdlet
# Prepare the env
$publicip = Get-AzPublicIpAddress -ResourceGroupName Default -name mypublicip
$vnet = Get-AzVirtualNetwork -ResourceGroupName Default -name testlinuxvnet
$gwSubnet = Get-AzVirtualNetworkSubnetConfig -Name "appgwSubnet" -VirtualNetwork $vnet
# Set AGW elements
$gipconfig = New-AzApplicationGatewayIPConfiguration -Name "AppGwIpConfig" -Subnet $gwSubnet
$fipconfig01 = New-AzApplicationGatewayFrontendIPConfig -Name "fipconfig" -PublicIPAddress $publicip
$pool = New-AzApplicationGatewayBackendAddressPool -Name "pool1"
$fp01 = New-AzApplicationGatewayFrontendPort -Name "port1" -Port 443
@kuzhao
kuzhao / azure.sh
Last active August 5, 2025 20:12
Useful bash command
# Download selected publishers' marketplace images for VM
for i in MicrosoftWindowsDesktop MicrosoftWindowsServer SUSE RedHat Canonical; do
az vm image list --publisher $i --location eastus --all -o tsv > "$i.tsv"
done
# az vmss run-command with "pretty" output
az vmss run-command invoke -g mc_msh-azuredigitalproducts-riskcommand-prod_aks-riskcommand-prod_eastus -n aks-system1-40580845-vmss --instance-id 5 --command-id RunShellScript --scripts "ps -o pid,user,%mem,command ax | sort -b -k3 -r" --query value[0].message -o tsv
# This cmdlet decrypts protectedSettings inside config of an extension. Run it under /var/lib/<ExtensionHandlerFolder>
# src: https://github.com/Azure/azure-linux-extensions/tree/master/Diagnostic
SETTINGS='config/5.settings';thumbprint=$(jq -r '.runtimeSettings[].handlerSettings.protectedSettingsCertThumbprint' $SETTINGS)
jq -r '.runtimeSettings[].handlerSettings.protectedSettings' $SETTINGS | base64 --decode | openssl smime -inform DER -decrypt -recip ../$thumbprint.crt -inkey ../$thum