Midnight Commander终端图形操作界面
月度归档:2020年12月
控制台应用静态库编译
cmake_minimum_required(VERSION 3.14)
project(CommaSdkActivator)
set(CMAKE_CXX_STANDARD 11)
# yum install glibc-static libstdc++-static
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")
endif()
if(MSVC)
# Use the static C library for all build types
foreach(var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if(${var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
endif()
endforeach()
endif(MSVC)
add_executable(CommaSdkActivator main.cpp)
指定ndk的库输出
defaultConfig {
applicationId “com.commaai.facesdkdemo”
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName “1.0”
testInstrumentationRunner “androidx.test.runner.AndroidJUnitRunner”
ndk {
abiFilters “armeabi-v7a”
}
}
Android线程异步处理
private ExecutorService executorService;
private Future mFutureBitmapRunnable;
第一步:
this.executorService = Executors.newSingleThreadExecutor();
第二步:
on camera thread callback,do like below.
public void takePhoto(ImiDevice.ImiFrame frame) {
if (mFutureBitmapRunnable != null && !mFutureBitmapRunnable.isDone()) {
return;
}
ByteBuffer buf = frame.getData();
buf.position(0);
final byte[] rgb24 = new byte[buf.remaining()];
buf.get(rgb24);
final int width = frame.getWidth();
final int height = frame.getHeight();
mFutureBitmapRunnable = executorService.submit(new Runnable() {
@Override
public void run() {
//to do
}
});
}
VT102图形测试whiptail
#!/bin/bash
whiptail --title "K8s, Vision @ 2019" --menu "Choose your option" 20 65 13 \
"1" "Single K8s One-click" \
"2" "Cluste K8s One-click" \
"3" "Cluste K8s add node" \
"4" "Single K8s add node" \
"5" "del node" \
"6" "Uninstall K8s" \
"7" "Quit" 3>&1 1>&2 2>&3
#!/bin/bash
whiptail --title "导入集群IP地址(包含本机ip默认第一个ip对应本机ip作为master)" --yes-button "YES" --no-button "NO" --yesno "批量导入集群IP地址?" 10 60
#!/bin/bash
whiptail --title "#请输入本机Ip(master)并回车#" --inputbox "请检查IP是否一致,确定提交?" 10 60 "$IP" 3>&1 1>&2 2>&3
#!/bin/bash
#---
if ( whiptail --title "Title hylan:yesno" --yesno "Choose between Yes and No." 10 60 ) then
echo "You chose Yes. Exit status was $?."
else
echo "You chose No. Exit status was $?."
fi
#---
if (whiptail --title "Title hylan:yesno" --yes-button "Hylan" --no-button "Candy" --yesno "Which do you like better?" 10 60) then
echo "You chose Hylan. Exit status was $?.";
echo "You Best!"
else
echo "You chose Candy. Exit status was $?.";
fi
#---
whiptail --title "Title hylan:msgbox" --msgbox "Create a message box with whiptail. Choose Ok to continue." 10 60
#---
whiptail --title "Title hylan:inputbox" --inputbox "What is your pet's name?" 10 60 hylancandy 3>&1 1>&2 2>&3
#---
whiptail --title "Title hylan:passwordbox" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3
#---
whiptail --title "Title hylan:menu" --menu "Choose your option" 15 60 4 \
"1" "Grilled Spicy Sausage" \
"2" "Grilled Halloumi Cheese" \
"3" "Charcoaled Chicken Wings" \
"4" "Fried Aubergine" 3>&1 1>&2 2>&3
#---
whiptail --title "Title hylan:checklist" --checklist "Choose preferred Linux distros" 15 60 4 "debian" "Venerable Debian" ON "ubuntu" "Popular Ubuntu" OFF "centos" "Stable CentOS" ON "mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3
{
for (( i=0 ; i<=100 ; i+=20 )); do
sleep 1
echo $i
done
} | whiptail --gauge "Please wait while installing" 6 60 0
#---
whiptail --title "Title hylan:checklist" --radiolist "Choose preferred Linux distros" 15 60 4 "debian" "Venerable Debian" ON "ubuntu" "Popular Ubuntu" OFF "centos" "Stable CentOS" ON "mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3
快速构建istio的测试容器
第一步:以nginx的容器为测试
build.sh脚本内容如下。
#!/bin/sh
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
ver=$1
if [ "$ver" == "" ]; then
echo "should like: build.sh v2"
exit
fi
docker rmi ngtest:${ver}
docker stop mynginx
docker rm mynginx
docker run --name mynginx -d nginx:1.17.8
docker cp ./default.conf mynginx:/etc/nginx/conf.d/default.conf && docker commit mynginx ngtest:${ver}
docker stop mynginx
docker rm mynginx
echo "----------------list ngtest image---------------------"&&docker images|grep ngtest
与脚本同级目录下的default.conf配置文件如下:
server {
listen 80;
listen [::]:80;
server_name localhost;
location /test {
default_type application/json;
return 200 "vm4 - v2 - time:$date_gmt - remote:$remote_addr";
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
第二步:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ngtest-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "mynginx.cn"
-----------------------------------------
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ngtest
spec:
hosts:
- "ngtestsvc"
gateways:
- ngtest-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: ngtestsvc
port:
number: 1080
subset: v1
weight: 90
- destination:
host: ngtestsvc
port:
number: 1080
subset: v2
weight: 10
---------------------
apiVersion: v1
kind: Service
metadata:
name: ngtestsvc
spec:
type: NodePort
ports:
- port: 1080
targetPort: 80
name: http
selector:
app: ngtestapp
-------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: ngtestapp.v1
spec:
replicas: 3
selector:
matchLabels:
app: ngtestapp
version: v1
template:
metadata:
labels:
app: ngtestapp
version: v1
spec:
containers:
- name: ngtest
image: ngtest:v1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
env:
- name: DO_NOT_ENCRYPT
value: "true"
------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: ngtestapp.v2
spec:
replicas: 3
selector:
matchLabels:
app: ngtestapp
version: v2
template:
metadata:
labels:
app: ngtestapp
version: v2
spec:
containers:
- name: ngtest
image: ngtest:v2
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
env:
- name: DO_NOT_ENCRYPT
value: "true"
service的三种类型
Kubernetes的service有三种类型:ClusterIP,NodePort,LoadBalancer
apiVersion: v1
kind: Service
metadata:
name: ngtestsvc
spec:
type: NodePort 【不指定,默认为ClusterIP】
ports:
- port: 1080
targetPort: 80 【不指定时,默认与port一致】
#nodePort: 31080 【该端口被强制划分为30000~50000之间,建议由系统自动分配,因为它会产生冲突的。】
name: http
selector:
app: ngtestapp