# Tips
因為我很懶,這邊就當我的筆記本,長話短說,就留下一點點小筆記
- Windows XP 並沒有支援 C++17 的讀寫鎖
- 因為 [AcquireSRWLockExclusive](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-acquiresrwlockexclusive) 是從 Windows 7 才開始支援
- Gnome 43 在 Wayland 的 system tray 幾乎都會失效。解法:appindicator + libappindicator
- GTK 2 跟 3 都要裝
- MSVC17 的 range-base loop 對於 attribute 有 compiler bug
- [細節](https://developercommunity.visualstudio.com/t/compiler-bug-on-parsing-maybe-unused-in-range-base/209488)
- podman (應該說是 user namespace 中的 sub-uid 問題)
- sudo usermod --add-subuids 10000-65536 ${USER}
- sudo usermod --add-subgids 10000-65536 ${USER}
- podman system migrate
- Ubuntu 的 /bin 是 softlink 到 /usr/bin
- 
- 然後我在我 bin 的 app 裡面用到 ../xxx 就跟預期不同 = =
- boost regex 底層疑似有用到 \_\_libc_single_threaded 這讓我移植 alpine 困難
- [\_\_libc_single_threaded](https://www.gnu.org/software/gnulib/manual/gnulib.html#Glibc-sys_002fsingle_005fthreaded_002eh)
- Python generator object 在 one-line for loop 取出來的值有一層 generator 包裝
- 也就是說這兩個不相同:
- `l = [].append(fn for _, fn in getmembers(module, isfunction))`
-
```python
l = []
for _, fn in getmembers(module, isfunction):
l.append(fn)
```
- 
- 寬螢幕英文是 ultrawide screen, 有個可以控制 window 版面的 gnome 工具叫做 gtile
- TLS in Windows before vista
- https://learn.microsoft.com/en-us/windows/win32/dlls/using-thread-local-storage-in-a-dynamic-link-library
- http://www.nynaeve.net/?p=189
- Grub 在 2023 Dec 20, 即 2.12 版,default enable shim-lock 會讓沒有支援 shim-lock 的機器壞掉,[GRUB Manual 2.12](https://www.gnu.org/software/grub/manual/grub/html_node/UEFI-secure-boot-and-shim.html)
- 緩解措施是 `--disable-shim-lock`
- https://bbs.archlinux.org/viewtopic.php?id=287024
- 
- https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot
- https://www.cnblogs.com/wswind/p/archlinux-secure-boot.html
- 有時候 mirror 會爆炸,但我懶的自己敲
- `sudo reflector --verbose --country Taiwan --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist`
- ubuntu 太舊 mirror 沒了
- `sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list`
- 不知道從哪一版開始,Gnome 似乎有對高更新率的螢幕設定有問題,會有「雪花屏」,目前 wordaround 是降低更新率到 60Hz
- 雪花屏是中國用語,但我不知道台灣是怎麼說
- Wayland 沒有辦法使用 xrandr 去設定
- gsettings 我沒找到對應的設定在什麼底下
- 最後解法是用 gnome remote control `grdctl` 去改
- 以前有重開幾幾次就會正常運作,無法穩定重現
- 看起來不限 gnome 有這問題,[KDE 也有](https://gitlab.freedesktop.org/drm/amd/-/issues/2967),[我沒有用 NV 顯卡](https://forums.developer.nvidia.com/t/525-89-02-flickering-when-using-two-screens-at-120hz-on-4090-with-latest-driver/242488/14),用 i5-13500 內顯也會炸
- 類似關鍵字是 [GDM with wayland show black flicker while logging in](https://bbs.archlinux.org/viewtopic.php?id=224664)
- 隔天滾一下系統又可以了,似乎跟 pipewire 有關?
```shell!
$inxi -Fxxc0z
Graphics:
Device-1: Intel AlderLake-S GT1 vendor: ASUSTeK driver: i915 v: kernel
arch: Gen-12.2 ports: active: HDMI-A-2 empty: DP-1,DP-2,HDMI-A-1
bus-ID: 00:02.0 chip-ID: 8086:4680
Device-2: Generalplus GENERAL WEBCAM driver: snd-usb-audio,uvcvideo
type: USB rev: 2.0 speed: 480 Mb/s lanes: 1 bus-ID: 1-3.2:6
chip-ID: 1b3f:2247
Display: unspecified server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.0
compositor: gnome-shell driver: X: loaded: intel
unloaded: fbdev,modesetting,vesa dri: i965 gpu: i915
Monitor-1: HDMI-A-2 model: Gigabyte M27Q res: 2560x1440 dpi: 109
diag: 684mm (26.9")
API: EGL v: 1.5 platforms: device: 0 drv: iris device: 1 drv: swrast
surfaceless: drv: iris wayland: drv: iris inactive: gbm,x11
API: OpenGL v: 4.6 compat-v: 4.5 vendor: mesa v: 24.1.2-arch1.1
note: incomplete (EGL sourced) renderer: Mesa Intel UHD Graphics 770 (ADL-S
GT1), llvmpipe (LLVM 17.0.6 256 bits)
```
- Microsoft 有一些 pointer value 可以協助 debugging
- `0xABABABAB` : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
- `0xABADCAFE` : A startup value to initialize all free memory to catch errant pointers
- `0xBAADF00D` : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialized allocated heap memory
- `0xBADCAB1E` : Error code returned to the Microsoft eVC debugger when connection is severed to the debugger
- `0xBEEFCACE` : Used by Microsoft .NET as a magic number in resource files
- `0xCCCCCCCC` : Used by Microsoft's C++ debugging runtime library to mark uninitialized stack memory
- `0xCDCDCDCD` : Used by Microsoft's C++ debugging runtime library to mark uninitialized heap memory
- `0xDDDDDDDD` : Used by Microsoft's C++ debugging heap to mark freed heap memory
- `0xDEADDEAD` : A Microsoft Windows STOP error code used when the user manually initiates the crash
- `0xFDFDFDFD` : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory
- `0xFEEEFEEE` : Used by Microsoft's HeapFree() to mark freed heap memory
- [Reference 1](https://en.wikipedia.org/wiki/Magic_number_(programming)#Debug_values), [Reference 2](https://stackoverflow.com/questions/127386/what-are-the-debug-memory-fill-patterns-in-visual-studio-c-and-windows)