Skip to content

Instantly share code, notes, and snippets.

@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 [email protected]
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
@davidliyutong
davidliyutong / test-0.py
Created June 15, 2022 16:09
Japanese Spelling Test
import random
import re
import numpy as np
import time
from pyrsistent import b
prononciation = ['a',
'i',
'u',
import os
import os.path as osp
import glob2
from typing import List, Dict
import argparse
import difflib
from io import StringIO
import coloredlogs, logging
import tqdm
import re
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import os
from credentials import USER_EMAIL, USER_PASSWD, PROJECT_URL
download_path = os.getcwd()
options = webdriver.EdgeOptions()
options.use_chromium = True