Skip to content

Instantly share code, notes, and snippets.

View levihuayuzhang's full-sized avatar

Huayu Zhang levihuayuzhang

View GitHub Profile
@levihuayuzhang
levihuayuzhang / build-mpv_silicon.sh
Last active January 3, 2024 03:29 — forked from dbrookman/build-mpv_silicon.sh
How to build mpv & mpv.app on an Apple silicon (M1 / M2) Mac
#!/usr/bin/env bash
cd mpv
git reset --hard
git clean --force -d -x
git pull origin master
set -x
# use standalone tools, not Xcode's (avoids xcrun errors)
@levihuayuzhang
levihuayuzhang / vscode-cmake-debug-lldb-f5.md
Created December 31, 2022 23:47
MacOS VS Code Debug using CMake extension (Pressing F5)

When I want to use CMake extention of VS Code in MacOS to debug program using LLDB, it requre some set up to use F5 button.

  1. Install VS Code, LLVM, CMAKE and C/C++ extensions.
  1. tasks.json:
@levihuayuzhang
levihuayuzhang / alarm-m1-vm-build.md
Created January 2, 2023 07:20
Arch Linux ARM build for M1 (Apple Silicon) VMs

Arch Linux ARM build for M1 (Apple Silicon) VMs

This guide is for building your own Arch Linux ARM VM image and runnig in QEMU, UTM, Parallels...

Preparations in Linux

What you need in Linux phase:

1. qemu-img
2. fdisk
3. kpartx
4. bsdtar
@levihuayuzhang
levihuayuzhang / google-chrome-linux-dark-mode.md
Last active January 13, 2023 23:13
Linux Google Chrome Dark Mode

Solution 1

  1. copy .desktop file to user directory
cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/google-chrome.desktop
  1. modify that file
sed -i 's;/usr/bin/google-chrome-stable;/usr/bin/google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode;g' ~/.local/share/applications/google-chrome.desktop

Solution 2

@levihuayuzhang
levihuayuzhang / clash.service
Created January 6, 2023 15:26 — forked from akillcool/clash.service
clash auto start and update subcribe configuration
# edit and save this file to /usr/lib/systemd/system/clash.service
[Unit]
Description=clash
After=network.target
[Service]
WorkingDirectory="your home directory"/.config/clash
ExecStart="your home directory"/.config/clash/start-clash.sh
ExecStop="your home directory"/.config/clash/stop-clash.sh
Environment="HOME=your home directory"
@levihuayuzhang
levihuayuzhang / chromium-sync-macOS.md
Last active January 14, 2023 18:15
Use Chromium with google sync service on macOS
@levihuayuzhang
levihuayuzhang / fix-DSD-thinkBook-16p-g4-IRH-linux-6.7.0-rc2.patch
Last active May 27, 2024 16:04
Workaround for Lenovo Thinkbook 16p Gen4 IRH sound issue (Should be fixed in Linux v6.8 or later)
From 86d1cc3e8e024c6776424f09108030fabe67cf5f Mon Sep 17 00:00:00 2001
From: Huayu Zhang <xxxxxxxxx@qq.com>
Date: Thu, 11 Jan 2024 16:18:29 +0800
Subject: [PATCH] add _DSD for SSID 0x17aa38a9 and 38ab (ThinkBook 16p G4 IRH)
the dmseg has following output after patching:
[ 4.401426] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41 (35a40), Revision: B2
[ 4.455038] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41 (35a40), Revision: B2
[ 6.362589] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: CS35L41 Bound - SSID: 17AA38A9, BST: 1, VSPK: 1, CH: L, FW EN: 1, SPKID: 0
@levihuayuzhang
levihuayuzhang / add_clash_proxy_in_WSL2.md
Last active June 7, 2023 04:41
add clash proxy in WSL2
  1. use following alias to proxy one line command in shell e.g. "px wget www.google.com"
alias px="hostip=$(cat /etc/resolv.conf | grep -oP '(?<=nameserver\ ).*') https_proxy=http://${hostip}:7890 http_proxy=http://${hostip}:7890 all_proxy=socks5://${hostip}:7890"
  1. set clash pass the Windows firewall
  2. allow LAN connect
@levihuayuzhang
levihuayuzhang / fix-lldb-mi-macos-vscode-stdin.md
Last active January 8, 2024 03:35
Fix debug C/C++ with lldb-mi in VSCode on MacOS stdin issue

Problem: when debugging the programs with lldb-mi on MacOS with VSCode-cpptools, the buildin terminal of VSCode not used as the stdin&out interface.

Fix:

  1. enable external terminal
  2. use stdin file while debugging and pass the file path using debugger setup command.

Notes:

  1. the "args": ["&lt;", "${fileDirname}/data/${fileBasenameNoExtension}"]will not work (at least for now) on MacOS because it treats the redirect operator as program argument.
@levihuayuzhang
levihuayuzhang / docker-access-host.md
Last active November 2, 2023 07:42
Docker access host IP by resolving specific domain name

Solution:

  1. Docker desktop (tested on Macos): use special DNS name host.docker.internal
  2. Linux:
  • use --network host on docker run, and use localhost. This has same network namespace (better performance but less security)
  • or --add-host=host.docker.internal:host-gateway, so that the containers using NAT can resolve host IP by domain name of host.docker.internal

Use case: docker compose file: