Windows VPN Hotspot
With VPN enabled on Windows, how to share it with mobile device like Quest 2?
Windows hotpot with SSTap, no need for proxy setting on mobile device:
- V2Ray
- SSTap
- Connecity Hotspot
Workspace Setup
Steps to set up my personal workspace.
V2Ray Server - Ubuntu
How to set up v2ray server on Ubuntu.
https://github.com/v2fly/fhs-install-v2ray
v2fly
1 | // 安裝執行檔和 .dat 資料檔 |
ufw
1 | ufw allow http |
config
1 | vi /usr/local/etc/v2ray/config.json |
server
1 | { |
Note: remember to set the value inbounds.settings.clients.id correctly.
tls (acme.sh)
1 | DOMAIN_NAME=songzy.cc |
install
1 | apt install socat |
register
1 | acme.sh --register-account -m songzy_thu@163.com |
issue & installcert
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 |
renew
1 | acme.sh --renew -d $DOMAIN_NAME --force --ecc --debug |
vmess aead
1 | env v2ray.vmess.aead.forced=false /usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json |
ip check
WSL HTTP Proxy
Set up http/https proxy inside WSL.
https://learn.microsoft.com/en-us/windows/wsl/networking
Port
If the v2ray has the following setting:
1 | 本地:[socks:10808] | [http:10809] |
Then:
1 | PROXY_PORT=10811 |
NAT
1 | WINDOWS_HOST=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'` |
Mirrored
In C:\Users\songz\.wslconfig of Windows host:
1 | [experimental] |
Then in WSL2:
1 | WINDOWS_HOST=localhost |
Code Server
How to install and use Code Server.
Motivation
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.
Install
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 |
SSH Port Forwarding
Remote Host
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 |
Local Client
1 | set -x |
Then, you can visit http://localhost:8080 in your local machine to access the code server started in remote machine.
Extensions
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”.
Alternatives
- vscode.dev: This is a lightweight vscode running in browser to manipulate local files.
- GitHub Codespaces: This is not free, and has network connection issue (you know it) from time to time.
Laptop Collection
A collection of my personal laptop devices.
OMEN 9 Slim (2023)
- CPU: Intel Core i9-13900HX
- GPU: NVIDIA GeForce RTX 4060 8G
- Memory: 16G
- Storage: 1T SSD
MacBook Air M1 (2020)
- Chip: M1
- Memory: 16G
- Storage: 1T SSD
ThinkPad T470 (2017)
- CPU: Intel Core i5-7200U
- GPU: NVIDIA GeForce 940MX 2GB
- Memory: 16G
- Storage: 128G SSD + 500G HDD
V2Ray Client - Mac
Prefer to use V2rayN for Mac.
GitBook
GitHub Repo Index
An index of my GitHub repositories.
Cloudtop Collection
A collection of my personal cloudtop devices.
- songzy.cc
- US
- DigitalOcean
- NameCheap
- songzy.xyz
- Japan
- Vultr
- NameCheap
- songzy.cool
- Korean
- Vultr
- NameCheap
- maomaosenlin.cc
- China
- Tencent Cloud
- Tencent Cloud
Octopress 3.0
Basic usage of Octopress.
ZSH
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 |
T470 Ubuntu GPU
Enable GPU on ThinkPad T470, which runs Kubuntu.
V2Ray Client - Windows
Set up v2ray client on Windows.
V2Ray Client - Ubuntu
Set up v2ray client on Ubuntu.
ChatGPT
大陆如何注册使用 ChatGPT,并将其升级到 Plus.
- 首先需要翻墙,其次要用不那么著名的vps提供商。
- 随机试了两个 vultr 的日本区和美区的ip都提示 blocked
- 据说 bandwagon 也会 blocked
- 解决法案:使用了 digitalocean 的美区机器成功访问
注册:
- 使用了 Gmail 邮箱
- 国外手机号收验证码
- 据说 Google Voice 提供的虚拟手机号是不行的
- 解决法案:使用了 sms activate 成功收到了验证码
- 可以支付宝充值2美元
- 使用了印度尼西亚区的号码
升级 Plus:
- 国内银行发行的 visa, AE 似乎都不行
- 测试了中国银行的 visa 和招商银行的 AE 都提示 denied
- 解决方案:下载 ChatGPT 的 iOS App 使用 Apple Pay 充值
- iOS 设备也需要翻墙,并在设置中修改所在地区为美国
- 需要美区的 Apple ID
- 下载 Shadowrocket 用于翻墙
- 下载 ChatGPT
- 要求 iOS 版本 >16.1:也就是 iPad Air 2 不行的意思
- 美区 Apple ID 需要绑定美区 Paypal
- 美区 Paypal 可以绑定国内银行发行的 visa,AE 卡
VSCode
https://github.com/microsoft/vscode
Settings
1 | { |
Wear OS
Google Pixel Watch app will crash on Honor 20 Pro with HarmonyOS 2.0.0.
Windows Env Var
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 |
WSL Export/Import
WSL2 export and import.
1 | PS C:\Users\songzy> wsl --list |
Config Default User
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 |
OMEN WSL GPU
Enable GPU on OMEN, which runs Win11 and WSL2.
WSL vDisk
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.
ncdu
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.
- https://en.wikipedia.org/wiki/Ncdu
- https://en.wikipedia.org/wiki/Ncurses
- https://en.wikipedia.org/wiki/Curses_(programming_library)
detail vdisk
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 |
compact vdisk
1 | # DISKPART> attach vdisk readonly |
expand vdisk
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 |
Windows Terminal Font
Fixing font/color issue I came across when using Windows terminals.
Vim
Basic usage of vim.
.vimrc
1 | set ignorecase |
Apache
Basic usage of apache2.
https://ubuntu.com/tutorials/install-and-configure-apache
Install
1 | sudo apt update |
Web Page
1 | ls /var/www/html/index.html |
Config
1 | cd /etc/apache2/sites-available/ |
Start Server
1 | sudo a2ensite gci.conf |
Log
1 | tail -f /var/log/apache2/error.log |
School Projects
A summary of what I have learnt in university.
- 2013夏
- 汇编
- Bomb lab, Buf lab
- MIPS (Microprocessor without Interlocked Pipeline Stages)
- 汇编
- 2013秋(大二)
- 程序设计与算法基础
- 虚拟宠物
- 程序设计与算法基础
- 2014春(大二)
- 计算机组成与系统结构
- Y86流水线处理器
- 计算机组成与系统结构
- 2014夏
- 安卓
- 计步器
- 安卓
- 2014秋(大三)
- 高等计算机图形学
- 光线追踪
- 网格简化
- 机器学习
- 广告 CTR 预测
- 大数据算法与模型
- Randomness Extractor
- 编译原理
- Decaf (Decaf is a Java-like object-oriented programming language)
- 高等计算机图形学
- 2015春(大三)
- 操作系统
- Nachos (Not Another Completely Heuristic Operating System)
- Paxos
- 操作系统
- 2015夏
- SRT
- Topic Model
- SRT
- 2015秋(大四)
- 软件工程
- 安卓车载蓝牙
- 软件工程
- 2016秋(研一)
- 分布式数据库系统
- EtherLend
- 分布式数据库系统
- 2017春(研一)
- 分布式系统导论
- Raft
- 计算几何
- 平面最大空凸点集
- 高级机器学习
- 论文引用数预测
- 计算机网络安全技术
- Eternal Blue - Wanna Cry
- 分布式系统导论
Xiaomi
Xiaomi 刷系统。
DiskPart
Basic usage of diskpart on windows.
EFI
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
Windows 查看磁盘分区格式
- 按下
Win+R打开运行,输入cmd,打开命令提示符; - 输入
diskpart按回车执行,切换到 DISKPART 命令,输入list disk,按回车; - 查看最后一列的GPT,如果有*号则为GPT,如果没有则为MBR。
Nexus6P
Nexus 6P 刷系统。
Ubuntu Service Management
Service/Job management on Ubuntu.
supervisor
- reread - Reread supervisor configuration. Do not update or restart the running services.
- update - Restart service(s) whose configuration has changed. Usually run after ‘reread’.
- reload - Reread supervisor configuration, reload supervisord and supervisorctl
- restart - Restart service(s)
service
1 | service ssh status |
tee
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.
xnheulpb
http://www.flypy.com/bbs/forum.php?mod=viewthread&tid=166
xnheulpb.reg
1 | Windows Registry Editor Version 5.00 |
LaTeX
Basic usage of LaTeX.
Tencent SNG
腾讯 SNG 校招面试分享。
- 项目中的有趣点或难点
- xgboost 和 lr 的优缺点
- C++ 虚函数的实现
- 线程和进程的区别
- 在模型中哪些 feature 最有用
- 算法题:将 1 到 m*n 按照螺旋方式填满 m * n 的矩阵。
Google 暑期实习电话面算法题。
Phone Interview
Compare keyboard events sequences
1 | # abc123\b123\b -> abc1212 |
WAP
WAP 校招面试算法题。
Round 0
Round 1
Round 2
Strobogrammatic Number I, II, III
Round 3
- 勾股定理
grep,find
Round 4
- Small Chat
Tencent IEG
腾讯互娱校招面试算法题。
这个也是 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$)
下面我们介绍两种解法,一种是使用动态规划的编程解,另一种是直接手算出答案的数学解。
Ubuntu Package Management
Random Variable Expectation
一枚硬币, 扔出 H 的概率为 $p$, T 的概率为 $q$, 计算首次扔出 $T\underbrace{H\dots H}_{k}$ 所需投掷次数的数学期望。
Poison and Prisoner
10000桶酒,其中1桶是毒酒;48小时后要举行酒会;毒酒喝下去会在之后的第23-24小时内毒死人。
国王决定用囚犯来试酒,不介意囚犯死多少,只要求用最少的囚犯来测试出哪一桶是毒酒。
问最少需要多少囚犯才能保证找出毒酒?
Bash
Basic usage of Bash.
Docker
Basic usage of Docker.
Git
Basic usage of git.
Tmux
Basic usage of tmux.
Apktool
Android RE.