Front end APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## date: 2021-11-11 | |
## author: duruyao@vimicro.com | |
## desc: automatically restore for omnibus gitlab installations from backups at 14:00 | |
set -euo pipefail | |
script_path="/home/duruyao/bin/gitlab-tools/restore-gitlab.sh" | |
auto_tasks=("0 14 * * * root ${script_path} CRON=1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## date: 2021-11-11 | |
## author: duruyao@vimicro.com | |
## desc: automatically backup omnibus gitlab packages to local and remote at 2:00 | |
set -euo pipefail | |
script_path="/home/duruyao/bin/gitlab-tools/backup-gitlab.sh" | |
auto_tasks=("0 2 * * * root ${script_path} CRON=1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -u | |
set -o pipefail | |
# usage: bash docker-run.sh [OPTIONS] IMAGE [COMMAND] [ARG...] | |
function get_valid_port() { | |
local random_port |
I have an Ubuntu system that uses two wired networks simultaneously (PCI Ethernet, USB Ethernet). I would like it to use the USB wired network for internet access and the PCI wired network for accessing the internal network (e.g., 10.0.13.120
, 10.0.13.134
, 10.0.12.1
, 10.0.10.16
, 10.0.10.17
, etc).
1.
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.100.1 0.0.0.0 UG 101 0 0 usb0
0.0.0.0 192.168.31.1 0.0.0.0 UG 102 0 0 enp4s0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @date 2022-06-19 | |
* @author duruyao@gmail.com | |
* @desc print different levels of logs in the console | |
*/ | |
#ifndef CONSOLE_PRINT_H | |
#define CONSOLE_PRINT_H | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @author duruyao | |
* @date 2023-03-14 | |
* @desc save files to and load files from protobuf messages | |
* @usage EXECUTABLE <SRC_FILENAME> <DST_FILENAME> | |
*/ | |
#include <cstdio> | |
#include <string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
import os | |
import re | |
import sys | |
import glob | |
from distutils.core import setup | |
from distutils.extension import Extension | |
from Cython.Distutils import build_ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def have_wining_strategy(*bags: int) -> bool: | |
if 0 == sum(bags): | |
return False | |
for i in range(len(bags)): | |
for n in range(bags[i]): | |
if not have_wining_strategy(*bags[:i], n, *bags[i + 1:]): | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from typing import Union, Optional, Dict | |
def multiply(arg1: Union[int, float, str, None] = 0.0, | |
arg2: Union[int, float, str, None] = 0.0) -> Optional[Dict[str, Union[int, float, str]]]: | |
""" | |
Calculate the product of two numbers. | |
:param arg1: a factor (default: 0.0) |
NewerOlder