Skip to content

Instantly share code, notes, and snippets.

View alimbada's full-sized avatar

Ammaar Limbada alimbada

View GitHub Profile
@alimbada
alimbada / README.md
Last active February 26, 2025 20:30
Proxmox Cheat Sheet

Migrate a Proxmox VM from SeaBIOS to OVMF (UEFI)

  • Under the VM's Hardware tab, change BIOS from Default (SeaBIOS) to OVMF (UEFI) in the Proxmox web UI
  • Click Add at the top and select EFI Disk. Select a location and click OK.
  • Boot the VM using Boot Repair Disk. Alternatively, boot any live CD and install the Boot Repair tool. Instructions for Ubuntu here: https://help.ubuntu.com/community/Boot-Repair
  • Use Gparted or your favourite partitioning tool to create an EFI partition. Note: You may need to resize your disk and adjust your partition layout.
  • Run the Boot Repair tool and choose the recommended option. Follow the instructions

NB: This works on a disk partitioned using MBR.

@alimbada
alimbada / SMB.md
Last active February 11, 2025 15:47
SMB/samba Cheat Sheet

Mount SMB share as non-root user with write permissions

sudo mount -t cifs -o "uid=$local_user,username=$smb_user,addr=$host,vers=1.0" //$host/$share $mount_path

Note

vers=1.0 only applies because I have a very old NAS running SMB 1.0.
Yes, it's insecure. No, it can't be updated. Yes, it's in the process of being retired.

For errors:

@alimbada
alimbada / Networking.md
Last active February 11, 2025 00:09
Networking Cheat Sheet

Get WAN IP

nslookup myip.opendns.com resolver1.opendns.com
@alimbada
alimbada / Add-WslRoute.ps1
Created October 11, 2024 11:09
Add a route for WSL to connect to the Internet when connected to VPN using GlobalProtect
$wslAddress = wsl ip -4 a show eth0 | wsl grep -Po 'inet \K[0-9.]*'
# This assumes you only have one interface containing 'WSL' in its name
$ifId = (Get-NetIPInterface -InterfaceAlias "*WSL*" -AddressFamily IPv4).ifIndex
route add -p $wslAddress mask 255.255.255.255 $wslAddress metric 256 if $ifId
@alimbada
alimbada / Install-GitHubMsi.ps1
Last active December 12, 2024 18:43
Download and install the latest release of an app from a GitHub repo
$repo = $args[0];
$outdir = $args[1]
$release = (curl -s https://api.github.com/repos/scito/extract_otp_secrets/releases/latest | ConvertFrom-Json).assets | where { $_.name -like "*.msi" -or $_.name -like "*.exe" }
# TODO: check there's only one item
$outFile = "$outdir\$($release.name)";
curl -L $release.browser_download_url --output $outFile;
& $outFile
#Requires AutoHotkey v2.0
#SingleInstance
Run "powershell -NoExit C:\Users\Ammaar.Limbada\Register-KvmEvents.ps1", , "Hide"
Persistent
@alimbada
alimbada / Restart-Gpu.ps1
Created August 8, 2024 22:07
Restart GPU
# Use Get-PnpDevice with no parameters to get the name of the device
Get-PnpDevice -FriendlyName "AMD Radeon RX 6700" | Disable-PnpDevice -Confirm:$false ; Sleep -Seconds 5; Get-PnpDevice -FriendlyName "AMD Radeon RX 6700" | Enable-PnpDevice -Confirm:$false
@alimbada
alimbada / Register-KvmEvents.ps1
Last active August 30, 2024 14:08
Send commands for switching HDMI input to TV when WMI events are triggered by KVM switch (connect/disconnect)
Register-WmiEvent -Query "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'win32_PNPEntity' AND TargetInstance.DeviceID like 'USB\\VID_045B&PID_0209%'" -SourceIdentifier KVMConnected -Action { lgtv --name MyTV --ssl setInput HDMI_4 }
Register-WmiEvent -Query "SELECT * FROM __InstanceDeletionEvent WITHIN 1 WHERE TargetInstance ISA 'win32_PNPEntity' AND TargetInstance.DeviceID like 'USB\\VID_045B&PID_0209%'" -SourceIdentifier KVMDisonnected -Action { lgtv --name MyTV --ssl setInput HDMI_3 }
@alimbada
alimbada / settings.json
Last active July 2, 2024 08:26
VS Code Settings
{
"[feature]": {
"editor.defaultFormatter": "alexkrechik.cucumberautocomplete"
},
"[java]": {
"editor.foldingImportsByDefault": true,
"editor.suggest.snippetsPreventQuickSuggestions": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
@alimbada
alimbada / keybindings.json
Last active June 4, 2024 16:48
VS Code Keybindings (mostly inspired by Visual Studio with ReSharper & IntelliJ IDEA)
// Place your key bindings in this file to override the defaultsauto[]
[
// CamelHumps words
{
"key": "ctrl+left",
"command": "cursorWordPartLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+left",