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 April 8, 2025 12:22
Analyse Netflix viewing activity by profile

This script allows you to analyse the ViewingActivity.csv file included in your Netflix data and outputs a list of shows watched by a particular profile ordered by frequency (i.e. number of times viewed and number of episodes viewed).

Usage

You will first need to request your Netflix data, download it and extract the zip file. You can do this by going to Account -> Security -> Personal information access

You will also need to install xsv or a similar tool.

Adjust the grep and awk expressions as appropriate. The grep expression will exclude lines where those strings are found (e.g. exclude teasers/trailers). The awk expression is necessary for specifying a cutoff for the show title to allow grouping of shows, e.g. Stranger Things: Stranger Things 2: Chapter One: MADMAX (Episode 1) will be transformed to Stranger Things to allow accurate counting of each shows views.

@alimbada
alimbada / Powershell.md
Created March 12, 2025 00:02
Powershell Cheat Sheet

Windows/Powershell Cheat Sheet

Get Windows Product Key

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform").BackupProductKeyDefault
@alimbada
alimbada / Proxmox.md
Last active March 12, 2025 00:02
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
@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 April 8, 2025 11:15
Send commands for switching HDMI input to an LG (webOS) 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"