2024-10¶
Force display format to PNG
In the VSCode plot panel and fredrikekre/Literate.jl notebooks, PNG images are generally smaller than SVG ones. To force plots to be shown as PNG images, you can use tkf/DisplayAs.jl to show objects in a chosen MIME type.
Get the ODE Function from an ODE system
f = ODEFunction(sys)
could be useful in plotting vector fields.
Plots.jl Tips
Some tips about Plots.jl, the de-facto standard visualization library in Julia.
Windows subsystem for Linux 2 (WSL2)
Set up Windows subsystem for Linux 2 (WSL2) for Linux development experience in Windows 10 and 11.
Instal WSL2
Open powershell with administrator privilege, run the following command in the host.
or install the components manually
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
After reboot, install the Linux distribution
WSL2 post-install (optional) setup
Backup/move the virtual disk
If you want to move the WSL virtual disk file to another disk (in this example, D:\
), run the following commands in Windows12:
wsl --export Ubuntu .\Ubuntu\ext4.tar
wsl --unregister Ubuntu
wsl --import Ubuntu D:\Ubuntu\ .\Ubuntu\ext4.tar
Default login user
Edit /etc/wsl.conf
in the WSL. You may need to set the default user if you have moved the virtual disk file of the WSL distribution.
Host settings
Edit .wslconfig
3 in your Windows home directory (%USERPROFILE%
).
For example,
[wsl2]
memory=20GB # How much memory to assign to the WSL2 VM.
swap=8GB # How much swap space to add to the WSL2 VM. 0 for no swap file.
swapfile=C:\\temp\\wsl-swap.vhdx # Sets swap file path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx. Useful if your C drive has limited disk space.
Auto reclaim RAM and disk space
Edit .wslconfig
3 in your Windows home directory (%USERPROFILE%
). 4
[experimental]
autoMemoryReclaim=gradual # Reclaim RAM usage
sparseVhd=true # Reclaim virtual disk (vhd) usage
Maintenance
Update kernel
To (manually) update the WSL kernel, run the following commands with administrator privileges:
Reclaim virtual disk space
Optimize-VHD
Note
Optimize-VHD
is not available in Windows Home edition.
To reclaim disk space from virtual hard disks (VHDs), run the following commands with administrator privileges 5:
Export and re-import
Alternatively, export the VHD as a tar file and reimport it again.
Caveats about WSL2
Poor filesystem performance across OSes
Cross-OS file access (e.g., accessing /mnt/c
in WSL) is at least one order of magnitude (10x) slower than accessing natively (/home/user/
).6
-
https://learn.microsoft.com/zh-tw/windows/wsl/basic-commands#import-and-export-a-distribution ↩↩
-
https://learn.microsoft.com/zh-tw/windows/wsl/wsl-config ↩↩↩↩
-
https://devblogs.microsoft.com/commandline/windows-subsystem-for-linux-september-2023-update/ ↩↩
-
https://blog.miniasp.com/post/2023/05/14/Shrink-your-WSL2-Virtual-Disks-and-Docker-Images-and-Reclaim-Disk-Space ↩↩
Check battery status
Open Windows Powershell with Administrator rights and run:
See the report at C:\battery-report.html
.
Convert powerpoint slides to TIFF images
How to export high resolution TIFF images from PowerPoint slides.
Windows Postinstall
Things to do after Windows install.
See also The Ultimate Windows Development Environment Guide
Enable MS store and winget in Windows LTSC
Run the following command in admin rights and ignore the error. MS store will be installed after a few minutes.
Click Microsoft.DesktopAppInstaller to install winget.
CTT Windows Utility
The Chris Titus Tech's Windows Utility provides APP installs, fixes and tweaks.
winget apps
winget install Romanitho.Winget-AutoUpdate
winget install Git.Git
winget install Microsoft.WindowsTerminal
winget install Microsoft.PowerShell
winget install Microsoft.VisualStudioCode
winget install qBittorrent.qBittorrent
winget install Mozilla.Firefox
winget install Brave.Brave
winget install Telegram.TelegramDesktop
winget install Bandisoft.Bandizip
winget install M2Team.NanaZip
winget install Bandisoft.Honeyview
winget install Daum.PotPlayer
winget install Nevcairiel.LAVFilters
winget install yt-dlp.yt-dlp
winget install Gyan.FFmpeg
winget install CrystalDewWorld.CrystalDiskInfo
winget install CrystalDewWorld.CrystalDiskMark
winget install Microsoft.DirectX
winget install Starship.Starship
winget install Obsidian.Obsidian
winget install GitHub.GitHubDesktop
Chocolatey package manager
If winget does not work.
Install Chocolatey 🍫, a command-line interface (CLI) package manager for Windows.
Open the powershell prompt with admin privilege (e.g. via the Windows + X
menu):
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Install packages
choco feature enable -n=useRememberedArgumentsForUpgrades
choco install -y git.install --params "'/NoShellIntegration'"
choco install -y vscode qbittorrent firefox brave telegram bandizip nanazip honeyview potplayer lavfilters yt-dlp ffmpeg crystaldiskinfo crystaldiskmark directx vcredist-all sudo starship obsidian nerd-fonts-firacode nerd-fonts-hack github-desktop
choco uninstall -n --skipautouninstaller vscode qbittorrent telegram github-desktop brave
See also the 🍫 Chocolatey package list for more packages.
Disable hibernation
Disabling hibernation saves a lot of disk space (No more C:\hiberfile.sys
). Run this in powershell with admin rights:
Afterward
- Setup WSL2
- Setup environment-variables
Sequence field in MS Word
The Seq (Sequence) field sequentially numbers chapters, tables, figures, and other items in a document.