Skip to content

Instantly share code, notes, and snippets.

@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.
EMPTY_SNAPSHOTS=$(zfs list -t snapshot | awk '{print $1," ",$2}' | grep " 0B" | awk '{print $1}')
if test -n "$EMPTY_SNAPSHOTS"; then
echo "Snapshots with name:"
else
echo "No empty snapshot found, exitting..."
exit 0
fi
for snapshot in $EMPTY_SNAPSHOTS;
#!/usr/bin/env bash
CONDA_SCRIPT_PATH="/tmp/"$USER"_miniconda.sh"
echo "You are using $SHELL"
echo "Downloading conda install script to $CONDA_SCRIPT_PATH"
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $CONDA_SCRIPT_PATH > /dev/null
CONDA_INSTALL_PATH=$HOME/miniconda3
echo "Installing conda to $CONDA_INSTALL_PATH"
$SHELL $CONDA_SCRIPT_PATH -b -p $CONDA_INSTALL_PATH > /dev/null
import os
import os.path as osp
import time
import cv2
import pyrealsense2 as rs
import logging
import numpy as np
import json
import yaml
@davidliyutong
davidliyutong / plot-dim-time-relateion.py
Created November 14, 2022 03:31
Python code to plot dim-time relation of four sorting algorithms using matplotlib
import matplotlib.pyplot as plt
plt.rc('font',family='Times New Roman') # 使用Times New Roman
# 定义标题和坐标
titles = ['Selection sort', 'Insertion sort', 'Bubble sort', 'Quick sort']
x_ticks = [10, 100, 1000, 10000, 100000]
x_labels = ['10', '100', '1k', '10k', '100k']
# 填充数据
data_avg = {
#!/bin/bash
# Copyright davidliyutong@sjtu.edu.cn
already_run=$(cat /root/.bashrc | grep "source /openbayes/home/.bashrc")
if test -n "$already_run"; then
echo -e '\n\n################ \n\nYou have already sourced /openbayes/home/.bashrc, no need to run restore-from-shutdown\n\n################ \n\n'
else
echo "source /openbayes/home/.bashrc" >> /root/.bashrc
echo -e '\n\n################ \n\nAppend /openbayes/home/.bashrc to /root/.bashrc, done !\n\n################ \n\n"
fi
@davidliyutong
davidliyutong / rancher-url-change.md
Created August 22, 2022 14:36 — forked from janeczku/rancher-url-change.md
Change the hostname/URL and certificate of an existing Rancher installation

Steps to change the URL of Rancher installation and switch from a self-signed certificate to a certificate signed by recognized CA.

  1. Change the Rancher server-url setting to the new URL:
    • Navigate to https://<old_rancher_hostname>/g/settings/advanced
    • Edit server-url to https://<new_rancher_hostname>
  2. Clear the private CA certificate for the old certificate
    • Navigate to https://<old_rancher_hostname>/g/settings/advanced
    • Next to cacerts click context menu -> View in API
    • Click Edit
    • Clear the content of the value field