Skip to content

Instantly share code, notes, and snippets.

View jim-liu's full-sized avatar

Jim Liu jim-liu

  • In front of my Xbox
View GitHub Profile
@jim-liu
jim-liu / setting-up-wireguard-on-edgerouter-x.md
Last active March 9, 2025 13:27
Setting up WireGuard on EdgeRouter X

This is presuming the WireGuard has been installed on the EdgeRouter, either by updating it to EdgeOS 3.0 (currenly EA) or by installing WireGuard manually.

Generate the key pair for the router

mkdir /config/auth; cd /config/auth
wg genkey | tee privatekey | wg pubkey > publickey
mv privatekey wg.key
mv publickey wg.pub
@jim-liu
jim-liu / hyper-v-vhdx-permissions.md
Last active March 11, 2025 17:39
Hyper-V VHDX permissions

If a Hyper-V VM failed to start due to access denied errors when accessing the VHDX, it might be due to the VM itself does not have read/write permission to the VHDX.

To grant the VM permission to access to VHDX:

$vmId = (Get-VM "<VM-Name>").VMId
icacls.exe <VHDX-path> /grant "$vmId`:RW"
@jim-liu
jim-liu / set-network-location-in-windows-8-1windows-server-2012-r2.md
Created February 9, 2025 16:05
Set Network Location in Windows 8.1/Windows Server 2012 R2
  1. In Registry Editor, navigate to the location below: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles.

  2. Double click/tap on the Profiles key in the left pane to expand it.

  3. Click/tap on each long GUID number subkey, and look at its ProfileName string value in the right pane to see if it has the current network name.

  4. When you find the correct ProfileName for your network name, double click/tap on the Category DWORD value in the same right pane to modify it.

  5. Type in a new Value data number for the network location you want, and click/tap on OK (Public: 0, Private: 1, Domain: 2).

@jim-liu
jim-liu / remove-unused-kernels-on-ubuntu.md
Created February 9, 2025 15:55
Remove unused kernels on Ubuntu

Running apt-get autoremove will remove all kernels except for the latest one and the one used in the last successful boot.

If /boot is 100% full and apt-get can't run (showing error message 'disk is full'), use rm to remove the oldest kernel in /boot:

cd /boot
sudo rm *-3.16.0-23-generic
@jim-liu
jim-liu / install-lan-driver-on-intel-nuc-running-windows-server-20122012-r2.md
Created February 9, 2025 15:53
Install LAN driver on Intel NUC running Windows Server 2012/2012 R2

The Ethernet chip on Intel NUC (I-218V) is not supported by Windows Server 2012/2012 R2, but it has a identical (?) twin I-218LM that is supported.

  1. Install the driver that came with NUC. It will fail with an error saying no adapter found

  2. Right click the network card in Device Manager and go to Update Driver

  3. Click Let me pick from a list of device drivers on my computer

  4. Select Intel (not Intel Corporation) under manufacturer and Intel(R) Ethernet Connection I218-LM from the list

@jim-liu
jim-liu / launching-remote-desktop-through-rdp-hyperlinks.md
Created February 9, 2025 13:52
Launching Remote Desktop through rdp:// hyperlinks
@jim-liu
jim-liu / change-file-modified-timestamp-with-powershell.md
Last active February 19, 2025 03:24
Change file modified timestamp with PowerShell

To change one file:

(Get-Item ".Pi.bin").LastWriteTime = "2015/3/14 9:26 AM"

To change multiple files:

Get-ChildItems -recurse | where { $_.LastWriteTime.Year -eq "2014" } | foreach { $_.LastWriteTime = "2015/3/14 9:26 AM" }
@jim-liu
jim-liu / make-visual-studio-code-use-visual-studios-built-in-git-client.md
Created February 9, 2025 13:43
Make VS Code use Visual Studio's built-in Git client

Visual Studio 2017 and later comes with a Git client, Git for Windows. However, as it is installed within Visual Studio, VS Code is not aware of its existence and complains about the lack of a Git client.

To make VS Code use the Git client already exists in the system:

  1. Add these two path variables:

    C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin
    C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
    
@jim-liu
jim-liu / resize-ubuntu-vm-disk.md
Created February 9, 2025 13:41
Resize Ubuntu VM disk

Tested on Ubuntu 18.04 VM with a GPT disk on Hyper-V.

  1. Extend the VHD in Hyper-V

  2. Extend the partition:

    1. $ sudo parted

    2. print free It should show a warning:

@jim-liu
jim-liu / powershell-batch-rename-with-a-list.md
Created February 9, 2025 13:40
PowerShell batch rename with a list
  1. Run the following command in PowerShell:

    gci | Select-Object -Property Name | Export-Csv .\rename.csv
  2. Open rename.csv file and delete the first row. Create a second column called NewName and list the new names of files in the column. The final rename.csv should look like the following:

Name,NewName