Skip to content

Instantly share code, notes, and snippets.

@davidliyutong
davidliyutong / surge_personal_module.txt
Last active June 21, 2024 15:19
surge_personal_module.txt
#!name=davidliyutong personal module
#!desc=This is a custom module for Surge5 that sets direct routes for specific IP CIDRs.
[Rule]
IP-CIDR,100.100.100.0/24,DIRECT
IP-CIDR,100.99.0.0/16,DIRECT
IP-CIDR,192.168.0.0/16,DIRECT
IP-CIDR,10.0.0.0/8,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 \
@davidliyutong
davidliyutong / run_multical.py
Last active February 23, 2023 09:00
Prepare ${CALIBRATION_ROOT}/${CAMERA_NAME}/[0-9]*.jpg, then run `python run_multical.py ${CALIBRATION_ROOT}`
import glob
import json
import logging
import os
import os.path as osp
import shutil
import subprocess
from typing import Optional, Dict, Tuple
#!/usr/bin/env bash
set -e
if [ -z $DBENCH_MOUNTPOINT ]; then
DBENCH_MOUNTPOINT=/tmp
fi
if [ -z $FIO_SIZE ]; then
FIO_SIZE=2G
fi
@davidliyutong
davidliyutong / migrate.configmap.yaml
Created November 23, 2022 13:27 — forked from deefdragon/migrate.configmap.yaml
Migrating Kubernetes PVC/PVs from one storage class to another
apiVersion: v1
kind: ConfigMap
metadata:
# any name can be used; Velero uses the labels (below)
# to identify it rather than the name
name: change-storage-class-config
# must be in the velero namespace
namespace: velero
# the below labels should be used verbatim in your
# ConfigMap.