ViveTool
https://github.com/thebookisclosed/ViVe
开启新版右键菜单:
1 | $ vivetool /enable /id:49453572,60813048,61934903 |
1 | $ vivetool /query /priority:User |
1 | $ vivetool /reset /id:49453572,60813048,61934903 |
1 | $ vivetool /query /id:49453572,60813048,61934903 |
https://github.com/thebookisclosed/ViVe
开启新版右键菜单:
1 | $ vivetool /enable /id:49453572,60813048,61934903 |
1 | $ vivetool /query /priority:User |
1 | $ vivetool /reset /id:49453572,60813048,61934903 |
1 | $ vivetool /query /id:49453572,60813048,61934903 |
Configure a Windows Terminal shortcut to toggle Quake mode.
Settings from the drop-down arrow next to the New Tab button.Actions in the left sidebar.Show/hide quake window in the action list. Select its existing keybinding to edit it, or select Add new and choose Show/hide quake window.Win + Backtick.Save.Press the configured shortcut to show or hide the Quake window.
By default, WSL2 automatically terminates its virtual machine when all terminal sessions are closed or after being idle. To keep WSL running continuously in the background (for daemons, background services, Docker, or SSH), you can use the following methods.
.wslconfig (Recommended)In Windows, create or edit %USERPROFILE%\.wslconfig (usually C:\Users\<YourUsername>\.wslconfig):
1 | [wsl2] |
vmIdleTimeout=-1 sets the idle timeout to infinity, preventing WSL2 from shutting down automatically after closing terminal windows.1 | wsl --shutdown |
1 | wsl --list --verbose |
1 | wsl --shutdown |
在 Windows 上将当前的 V2Ray 代理通过网络热点(Wi-Fi 热点)分享给其他设备(如手机、Switch、其他电脑),通常有两种主要方法。
方法一最简单、最推荐,不需要复杂的 Windows 网络配置。
这个方法是通过局域网 IP 和端口进行分享。无论你是用 v2rayN 还是 Clash 等客户端,原理都一样。
10809 或 10811,在客户端主界面底部可以看到)。Win + R,输入 cmd 回车打开命令行。ipconfig 回车。192.168.137.1 或 192.168.xx.x)。192.168.137.1)。10809)。如果你的外接设备(如某些游戏机)不支持手动输入代理端口,或者你想让所有连接热点的流量自动走代理,可以使用虚拟网卡(TUN 模式)。
Win + R,输入 ncpa.cpl 回车,打开“网络连接”窗口。sing-box、Clash、v2ray 或 TAP/TUN 字样)。本地连接* xx 或 Microsoft Wi-Fi Direct Virtual Adapter)。⚠️ 注意:使用方法二时,连接热点的设备不需要在 Wi-Fi 里设置任何代理端口,直接连接就能直接翻墙。
Steps to set up my personal workspace.
How to set up v2ray server on Ubuntu.
https://github.com/v2fly/fhs-install-v2ray
1 | // 安裝執行檔和 .dat 資料檔 |
1 | ufw allow http |
1 | vi /usr/local/etc/v2ray/config.json |
1 | { |
Note: remember to set the value inbounds.settings.clients.id correctly.
1 | DOMAIN_NAME=songzy.cc |
1 | apt install socat |
1 | acme.sh --register-account -m songzy_thu@163.com |
1 | acme.sh --issue -d $DOMAIN_NAME --standalone -k ec-256 --debug |
1 | acme.sh --installcert -d $DOMAIN_NAME --fullchainpath /usr/local/etc/v2ray/$DOMAIN_NAME.cer --keypath /usr/local/etc/v2ray/$DOMAIN_NAME.key --ecc |
1 | acme.sh --renew -d $DOMAIN_NAME --force --ecc --debug |
1 | env v2ray.vmess.aead.forced=false /usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json |
Set up http/https proxy inside WSL.
https://learn.microsoft.com/en-us/windows/wsl/networking
If the v2ray has the following setting:
1 | 本地:[socks:10808] | [http:10809] |
Then:
1 | PROXY_PORT=10811 |
1 | WINDOWS_HOST=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'` |
In C:\Users\songz\.wslconfig of Windows host:
1 | [experimental] |
Then in WSL2:
1 | WINDOWS_HOST=localhost |
How to install and use Code Server.
This way, we can put our project codes in remote cloud machines, and access it from a browser in any other computers.
NOTE: Without the “browser” requirement, you can use vscode directly to access files in remote cloud machine from any computers.
https://coder.com/docs/code-server/install#debian-ubuntu
1 | export VERSION=4.92.2 |
1 | sudo dpkg -i code-server_${VERSION}_amd64.deb |
1 | sudo systemctl enable --now code-server@$USER |
https://coder.com/docs/code-server/guide#port-forwarding-via-ssh
1 | # Replaces "auth: password" with "auth: none" in the code-server config. |
1 | sudo service code-server@$USER status |
1 | set -x |
Then, you can visit http://localhost:8080 in your local machine to access the code server started in remote machine.
Some extensions are not avaliable in the default extension market, you might need to install them manually. Let us use the “C/C++” extension as an example.
First, find the extension download link from the “Version History” tab of the vscode extension marketplace:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools&ssr=false#version-history
Then, in your remote machine, use wget to download the extension:
1 | wget https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/cpptools/1.23.0/vspackage\?targetPlatform\=linux-x64 |
The file downloaded by wget (or curl) cannot be installed directly since it is in a gzip format. So we need to first rename it with suffix .gz and then gunzip it:
1 | mv vspackage\?targetPlatform=linux-x64 ms-vscode.cpptools-1.10.3@linux-x64.vsix.gz |
Then, you can install the ms-vscode.cpptools-1.10.3@linux-x64.vsix either from commandline or search for the “Extensions: Install from VSIX” after typing “Shift-Command-P”.
Prefer to use V2rayN for Mac.
An index of my GitHub repositories.
A collection of my personal cloudtop devices.
Basic usage of Octopress.
Basic usage of zsh.
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
To view all avaliable zsh themes:
1 | ls $ZSH/themes/ |
To set zsh theme:
1 | ZSH_THEME=random |
To view the current selected random theme:
1 | echo $RANDOM_THEME |
To view the config of a specific zsh theme:
1 | vi $ZSH/themes/robbyrussell.zsh-theme |
Set up v2ray client on Windows.
Set up v2ray client on Ubuntu.
大陆如何注册使用 ChatGPT,并将其升级到 Plus.
注册:
升级 Plus:
https://github.com/microsoft/vscode
1 | code serve-web --port 8080 --host 0.0.0.0 --without-connection-token |
No hang up:
1 | nohup code serve-web --port 8080 --host 0.0.0.0 --without-connection-token > vscode_web.log 2>&1 & |
Kill by port:
1 | kill -9 $(lsof -t -i:8080) |
Kill by process name:
1 | pkill -f "code serve-web" |
Step by step:
1 | ps aux | grep "code serve-web" |
1 | { |
Google Pixel Watch app will crash on Honor 20 Pro with HarmonyOS 2.0.0.
Built-in envrionment variables on Windows.
https://en.wikipedia.org/wiki/Environment_variable#Windows
| Variable | Locale specific | Windows XP (CMD) | Windows Vista and later (CMD) |
|---|---|---|---|
| %ALLUSERSPROFILE% | Yes | C:\Documents and Settings\All Users | C:\ProgramData |
| %APPDATA% | Yes | C:\Documents and Settings{username}\Application Data | C:\Users{username}\AppData\Roaming |
| %CommonProgramFiles% | Yes | C:\Program Files\Common Files | C:\Program Files\Common Files |
| %CommonProgramFiles(x86)% | Yes | C:\Program Files (x86)\Common Files (only in 64-bit version) | C:\Program Files (x86)\Common Files (only in 64-bit version) |
| %CommonProgramW6432% | Yes | %CommonProgramW6432% (not supported, not replaced by any value) | C:\Program Files\Common Files (only in 64-bit version) |
| %COMPUTERNAME% | No | {computername} | {computername} |
| %ComSpec% | No | C:\Windows\System32\cmd.exe | C:\Windows\System32\cmd.exe |
| %HOMEDRIVE% | No | C: | C: |
| %HOMEPATH% | Yes | \Documents and Settings{username} | \Users{username} |
| %LOCALAPPDATA% | Yes | %LOCALAPPDATA% (not supported, not replaced by any value) | C:\Users{username}\AppData\Local |
| %LOGONSERVER% | No | \{domain_logon_server} | \{domain_logon_server} |
| %PATH% | Yes | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} |
| %PATHEXT% | No | .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH | .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc |
| %ProgramData% | Yes | %ProgramData% (not supported, not replaced by any value) | %SystemDrive%\ProgramData |
| %ProgramFiles% | Yes | %SystemDrive%\Program Files | %SystemDrive%\Program Files |
| %ProgramFiles(x86)% | Yes | %SystemDrive%\Program Files (x86) (only in 64-bit version) | %SystemDrive%\Program Files (x86) (only in 64-bit version) |
| %ProgramW6432% | Yes | %ProgramW6432% (not supported, not replaced by any value) | %SystemDrive%\Program Files (only in 64-bit version) |
| %PROMPT% | No | Code for current command prompt format, usually $P$G | Code for current command prompt format, usually $P$G |
| %PSModulePath% | %PSModulePath% (not supported, not replaced by any value) | %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\ | |
| %PUBLIC% | Yes | %PUBLIC% (not supported, not replaced by any value) | %SystemDrive%\Users\Public |
| %SystemDrive% | No | C: | C: |
| %SystemRoot% | No | The Windows directory, usually C:\Windows, formerly C:\WINNT | %SystemDrive%\Windows |
| %TEMP% and %TMP% | Yes | %SystemDrive%\Documents and Settings{username}\Local Settings\Temp | %SystemRoot%\TEMP (for system environment variables %TMP% and %TEMP%), %USERPROFILE%\AppData\Local\Temp (for user environment variables %TMP% and %TEMP%) |
| %USERDOMAIN% | No | {userdomain} | {userdomain} |
| %USERNAME% | No | {username} | {username} |
| %USERPROFILE% | Yes | %SystemDrive%\Documents and Settings{username} | %SystemDrive%\Users{username} |
| %windir% | No | %SystemDrive%\WINDOWS | %SystemDrive%\Windows |
WSL2 export and import.
1 | PS C:\Users\songzy> wsl --list |
Method 1:
1 | Function WSL-SetDefaultUser ($distro, $user) { Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq $distro | Set-ItemProperty -Name DefaultUid -Value ((wsl -d $distro -u $user -e id -u) | Out-String); }; |
Method 2:
1 | ubuntu2004 config --default-user songzy |
Enable GPU on OMEN, which runs Win11 and WSL2.
WSL2 vdisk management.
WSL 2 uses a Virtual Hard Disk (VHD) to store your Linux files. In WSL 2, a VHD is represented on your Windows hard drive as a .vhdx file.
The WSL 2 VHD uses the ext4 file system. This VHD automatically resizes to meet your storage needs and has an initial maximum size of 256GB.
1 | du -h --max-depth=1 . | sort -h |
or
1 | sudo apt install ncdu |
Then press ? for shortcuts.
“ncdu” stands for “NCurses Disk Usage”, where “NCurses” stands for “new curses”, where “curses” is a pun on the term “cursor optimization”, which is a library for TUI.
1 | wsl --shutdown |
1 | DISKPART> select vdisk file="C:\Users\songzy\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx" |
Windows use first 5 letters of our e-mail addresses as the name of our user account folders.
1 | DISKPART> detail vdisk |
1 | # DISKPART> attach vdisk readonly |
https://docs.microsoft.com/en-us/windows/wsl/vhd-size
1 | DISKPART> expand vdisk maximum=<sizeInMegaBytes> |
1 | wsl.exe -l -v |
1 | sudo mount -t devtmpfs none /dev |
Fixing font/color issue I came across when using Windows terminals.
Basic usage of vim.
1 | set ignorecase |
Basic usage of apache2.
https://ubuntu.com/tutorials/install-and-configure-apache
1 | sudo apt update |
1 | ls /var/www/html/index.html |
1 | cd /etc/apache2/sites-available/ |
1 | sudo a2ensite gci.conf |
1 | tail -f /var/log/apache2/error.log |
A summary of what I have learnt in university.
Xiaomi 刷系统。
Basic usage of diskpart on windows.
http://linuxbsdos.com/2015/09/05/how-to-delete-grub-files-from-a-boot-efi-partition-in-windows-10/
1 | % These commands are used to identify and select the hard drive |
1 | diskpart |
Windows 查看磁盘分区格式
Win+R 打开运行,输入 cmd,打开命令提示符;diskpart 按回车执行,切换到 DISKPART 命令,输入list disk,按回车;Nexus 6P 刷系统。
Service/Job management on Ubuntu.
1 | service ssh status |
1 | tee |
In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input.
将 Android 上微信的聊天记录导出为 txt.
http://www.flypy.com/bbs/forum.php?mod=viewthread&tid=166
xnheulpb.reg
1 | Windows Registry Editor Version 5.00 |
Basic usage of LaTeX.
腾讯 SNG 校招面试分享。
Google 暑期实习电话面算法题。
Compare keyboard events sequences
1 | # abc123\b123\b -> abc1212 |
WAP 校招面试算法题。
Strobogrammatic Number I, II, III
grep, find腾讯互娱校招面试算法题。
这个也是 LeetCode 原题:Integer Break
给定 $m\in N$,
$\max x_1\cdot x_2\dots x_{n-1}\cdot x_n$
s.t. $x_1+x_2+…+x_n = m$ and $x_i \in N $.
(面试官给的题目里 $m = 25$)
下面我们介绍两种解法,一种是使用动态规划的编程解,另一种是直接手算出答案的数学解。
一枚硬币, 扔出 H 的概率为 $p$, T 的概率为 $q$, 计算首次扔出 $T\underbrace{H\dots H}_{k}$ 所需投掷次数的数学期望。
10000桶酒,其中1桶是毒酒;48小时后要举行酒会;毒酒喝下去会在之后的第23-24小时内毒死人。
国王决定用囚犯来试酒,不介意囚犯死多少,只要求用最少的囚犯来测试出哪一桶是毒酒。
问最少需要多少囚犯才能保证找出毒酒?
Basic usage of Bash.
Basic usage of Docker.
Basic usage of git.
Basic usage of tmux.
Android RE.