Skip to content

Instantly share code, notes, and snippets.

@davidliyutong
davidliyutong / NUS-EE6934-AI-DECLARATION.txt
Created February 9, 2026 09:26
NUS-EE6934-AI-DECLARATION
I used Gemini to improve expression of the paragraphs.
@davidliyutong
davidliyutong / surge_no_ssh_module.txt
Created February 8, 2026 03:04
surge_no_ssh_module.txt
#!name=davidliyutong surge no ssh module
#!desc=This is a custom module for Surge5 that sets direct routes for ssh
[Rule]
PROCESS-NAME,/usr/bin/ssh,DIRECT
#!/bin/bash
# 检查参数个数
if [ "$#" -lt 3 ]; then
echo "Usage:"
echo "./tool backup <volume> <output-file>"
echo "./tool restore <input-file> <volume>"
exit 1
fi
@davidliyutong
davidliyutong / surge_personal_module.txt
Last active February 8, 2026 03:02
surge_personal_module.txt
#!name=davidliyutong personal module
#!desc=This is a custom module for Surge5 that sets direct routes for specific IP CIDRs.
[MITM]
hostname = %APPEND% 100.100.100.0/24, 100.99.0.0/16, 192.168.0.0/16, 10.0.0.0/8
[Rule]
IP-CIDR,100.112.0.0/16,DIRECT
IP-CIDR,100.100.100.0/24,DIRECT
IP-CIDR,100.99.0.0/16,DIRECT
@davidliyutong
davidliyutong / light_cycle_v2.sh
Created January 23, 2024 15:41
Scirpt to change color of RGB LED on Unifi U6-Mesh
#!/bin/sh
# This function takes RGB values and writes them to the LED device
set_led_color() {
echo -n "$1,$2,$3" > /proc/ubnt_ledbar/custom_color
}
# This function smoothly transitions from one color to another
transition_color() {
local startR=$1
@davidliyutong
davidliyutong / realsense_capture.py
Created January 19, 2024 14:00
Capture PointCloud with Realsense Cameras
import logging
from typing import List, Optional, Tuple
import numpy as np
import pyrealsense2 as rs
from pydantic import BaseModel
import open3d as o3d
import cv2
import py_cli_interaction
import datetime
@davidliyutong
davidliyutong / RateLimitedCaller.py
Last active September 18, 2023 05:34
Python helpler class to call api under rate limit
import asyncio
import heapq
from time import monotonic
from typing import Iterable, Dict, Any, List, Callable, Optional
import datetime
import inspect
class RateLimit:
def __init__(self, num: int, duration: datetime.timedelta):
@davidliyutong
davidliyutong / download-cpptools.sh
Created September 9, 2023 13:30
Download microsoft cpptools to ~/Downloads
#!/bin/bash
# download version
VERSION=$(curl -sL https://api.github.com/repos/microsoft/vscode-cpptools/releases/latest | jq -r ".tag_name")
VERSION=${VERSION:1} # Remove character 'v'
echo "VERSION: $VERSION"
# prepare download destination
DOWNLOAD_DESTINATION="$HOME/Downloads"
if [[ ! -d $DOWNLOAD_DESTINATION ]]; then
@davidliyutong
davidliyutong / macos_m1_vscode_lldb.json
Last active April 25, 2023 16:10
macos_m1_vscode_lldb.json
{
"version": "0.2.0",
"configurations": [
{
"name": "clang - 生成和调试活动文件",
"type":"cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
@davidliyutong
davidliyutong / install_graspit.sh
Created April 11, 2023 18:43
install_graspit.sh
#!/bin/bash
# On ubuntu:18.04
echo "-------- I am $(whoami) --------"
HOME_DIR=$(eval echo ~$USER)
sudo apt-get update
sudo apt-get install -y \
libsoqt4-dev \
libcoin80-dev \