Skip to main content

· One min read

ldd hehe

objdump

#显示所可用的头信息,包括符号表、重定位入口。-x 等价于-a -f -h -r -t 同时指定。
objdump -x ota
#显示文件的符号表入口
objdump -t ota

hexdump

hexdump -C config.json  # 16进制查看
xdd config.json # 二进制查看

.so func list

nm -D libSP.so
objdump -T libSP.so # --dynamic-syms 显示文件的动态符号表入口,仅仅对动态目标文件意义

strip 压缩 脱衣服

#iot-echo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
#iot-echo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
#iot-echo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
# nm iothub-echo # strip后就没有了
strip iothub-echo

· One min read

https://ci.apache.org/projects/flink/flink-docs-stable/zh/

tar -xzf flink-1.13.0-bin-scala_2.11.tgz cd flink-1.13.0

https://ci.apache.org/projects/flink/flink-docs-stable/zh/

./bin/flink run -m flink.cc5ee3108d340437b956b5d18bf1a9ba7.cn-shanghai.alicontainer.com -py asdf.py ./bin/flink run -m flink.cc5ee3108d340437b956b5d18bf1a9ba7.cn-shanghai.alicontainer.com:80 examples/streaming/WordCount.jar

./bin/flink run -pyfs ./examples/python/table/batch -pym word_count

· One min read
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{1c4de342-38b7-51cf-b940-2309a097f589}",
"copyOnSelect": false,
"copyFormatting": false,
"profiles": {
"defaults": {},
"list": [
{
"acrylicOpacity": 0,
"closeOnExit": true,
"colorScheme": "Campbell",
"commandline": "C:\\Program Files\\Git\\bin\\bash.exe",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "YaHei Consolas Hybrid",
"fontSize": 13,
"guid": "{1c4de342-38b7-51cf-b940-2309a097f589}",
"historySize": 200,
"icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
"name": "git-bash",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%/Desktop",
"useAcrylic": false
},
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
"schemes": [],
"actions": [
{
"command": {
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "find",
"keys": "ctrl+f"
},
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
]
}

· 2 min read

户名为 pi ,密码为 raspberry ssh root@10.15.202.200

官网 https://www.raspberrypi.org/

download https://alpinelinux.org/downloads

Raspberry Pi OS (previously called Raspbian) Win32DiskImager 硬盘 FAT32 电源 5v 3A

config

sudo raspi-config

windows远程访问的实现

apt-get install xrdp

https://www.instructables.com/id/Install-Alpine-Linux-on-Raspberry-Pi/

wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1
fast_reauth=1
country=CN
network={
ssid="WIFI名称"
psk="WIFI密码"
priority=100
}

repo

https://mirror.tuna.tsinghua.edu.cn/help/raspbian/

buster

vi /etc/apt/sources.list deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi deb http://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os/raspbian/ buster main non-free contrib rpi deb-src http://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os/raspbian/ buster main non-free contrib rpi

/etc/apt/sources.list.d/raspi.list deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

sudo apt-get update

必装

sudo apt install -y vim tree

视频 usb motion

sudo apt install motion sudo motion http://localhost:8081

开机启动

sudo vi /etc/default/motion
#no修改成yes:
start_motion_daemon=yes

remote

sudo vi /etc/motion/motion.conf
# deamon off 改成 on
deamon on
# 设置分辨率
width 800
height 600
# 刷新率
framerate 30
streame_maxrate 30
# 关闭 localhost 的限制
stream_localhost off
webcontrol_localhost off

samba win+linux 文件共享

MJPGStreamer进行实时监控(USB摄像头篇)https://www.bilibili.com/video/BV1bt411c7fC?p=35

sudo apt-get install -y subversion
sudo apt-get install -y libjpeg8-dev
sudo apt-get install -y imagemagick
sudo apt-get install -y libv4l-dev
sudo apt-get install -y cmake
sudo git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
sudo make all
sudo make install
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
./mjpg_streamer -i "./input_uvc.so -f 30 -r 800x600" -o "./output_http.so -w ./www"
http://192.168.100.39:8080/stream.html

· One min read
click.py
import cv2


def draw_rectangle(event, x, y, flags, params):
if event == cv2.EVENT_LBUTTONDOWN:
print(x, y)
cv2.circle(img, center=(x, y), radius=5, color=(87, 184, 237), thickness=-1)
elif event == cv2.EVENT_LBUTTONUP:
cv2.circle(img, center=(x, y), radius=10, color=(87, 184, 237), thickness=1)


img = cv2.imread("./road-line.jpeg")

cv2.namedWindow(winname="my_drawing")
cv2.setMouseCallback("my_drawing", draw_rectangle)

# Step 3. Execution
while True:
cv2.imshow("my_drawing", img)
if cv2.waitKey(10) & 0xFF == 27:
break

cv2.destroyAllWindows()
trend.py
import cv2
import numpy as np

print(np.pi / 180)

img = cv2.imread("trend.png")
height = img.shape[0] # 高度
width = img.shape[1] # 宽度
cut_img = img

gray = cv2.cvtColor(cut_img, cv2.COLOR_BGR2GRAY)
cv2.waitKey(0)
edges = cv2.Canny(gray, 50, 150, apertureSize=3)

result = cut_img.copy()
minLineLength = 30 # height/32
maxLineGap = 10 # height/40
lines = cv2.HoughLinesP(edges, 1, np.pi / 1, 80, 0, 0)

for line in lines:
# for x1, y1, x2, y2 in lines[0]:
for x1, y1, x2, y2 in line:
if int(y2) != int(y1):
cv2.line(result, (x1, y1), (x2, y2), (0, 255, 0), 2)
else:
...

cv2.imshow("result", result)
cv2.waitKey(0)

· One min read

# 所有的 service
systemctl list-units --type=service

# 看日志
journalctl -u k3s -f

service nginx status
service nginx start
service nginx restart
service nginx stop

file list

cd /usr/lib/systemd/system
cd /etc/systemd/system/

k3s.service demo

[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
EnvironmentFile=/etc/systemd/system/k3s.service.env
KillMode=process
Delegate=yes
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \
server \
'--docker' \

· One min read
docker stop lubuntu
docker rm lubuntu

docker run -d --hostname lubuntu --name lubuntu --restart always --privileged -p 9092:5901 -e TZ=Asia/Jakarta vncserver/lubuntu

docker cp /www/navicate lubuntu:/home/developer/navicate
docker cp lubuntu:/home/developer/navicate navicate

docker run -d --hostname lubuntu --name lubuntu --restart always --privileged -p 9092:5901 -e TZ=Asia/Jakarta \
-v /www/navicate/app:/home/developer/app -v /www/navicate/config:/home/developer/.config/navicat \
vncserver/lubuntu

docker exec -u developer -it lubuntu bash

过期删 MySQL rm -rf preferences.json*

vnc

docker run -d --hostname lubuntu --name lubuntu --restart always --privileged -p 9092:5901 -e TZ=Asia/Jakarta vncserver/lubuntu

· One min read

k3s

Lightweight Kubernetes

# start
k3s server --docker --no-deploy=traefik

# systemd /etc/systemd/system/k3s.service
journalctl -u k3s -f # 日志

config

cd /var/lib/rancher/k3s/server/manifests
/etc/rancher/k3s/k3s.yaml

install

curl -sfL https://get.k3s.io | sh -
# images
wget https://github.com/rancher/k3s/releases/download/v1.0.0/k3s-airgap-images-amd64.tar
docker load --input k3s-airgap-images-amd64.tar

# download k3s bin
wget https://github.com/rancher/k3s/releases/download/v1.17.4%2Bk3s1/k3s
cp k3s /usr/local/bin/
chmod 777 /usr/local/bin/k3s
curl -sfL https://get.k3s.io > ~/a.sh

# reinstall
cp /usr/local/bin/k3s ~/k3s
cp ~/k3s /usr/local/bin/k3s
INSTALL_K3S_SKIP_DOWNLOAD=true sh a.sh server --docker --no-deploy=traefik
[INFO]  Finding latest release
[INFO] Using v1.0.0 as release
[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v1.0.0/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v1.0.0/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
which: no kubectl in (/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
which: no crictl in (/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[INFO] Creating /usr/local/bin/crictl symlink to k3s
which: no ctr in (/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink from /etc/systemd/system/multi-user.target.wants/k3s.service to /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s

· 2 min read

Cargo:Rust 的构建工具和包管理器

  • cargo new hello-rust
  • cargo build 可以构建项目
  • cargo run 可以运行项目
  • cargo test 可以测试项目
  • cargo doc 可以为项目构建文档
  • cargo publish 可以将库发布到 crates.io
  • cargo --version

install

# proxy bash
echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup' >> ~/.bash_profile
echo 'export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.bash_profile

# linux macos
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# windows
https://rustup.rs/

# rust update 自更新
rustc -V
rustup update

# dep update
cargo update

交叉编译

win => linux

rustup target list # (installed)
rustup target add x86_64-unknown-linux-musl

# musl 静态编译 lld statically linked
apt install musl-tools -y # 核心
cargo build --target x86_64-unknown-linux-musl
~/.cargo/config.toml
# ~/.cargo/config.toml
[target.x86_64-unknown-linux-musl]
linker = "rust-lld"

wasm

# install wasmtime
curl https://wasmtime.dev/install.sh -sSf | bash

fn main() {
println!("Hello, world!");
}

rustup target add wasm32-wasi
rustc hello.rs --target wasm32-wasi
wasmtime hello.wasm
# Hello, world!

bind clang

vcpkg windows

C++ Library Manager for Windows, Linux, and MacOS

# ~/.vcpkg-clion
# git set https://stackoverflow.com/a/70942119
git clone --progress https://github.com/microsoft/vcpkg vcpkg
# git fetch --unshallow
# run ./bootstrap-vcpkg.sh

export VCPKG_ROOT="C:\Users\106006\.vcpkg-clion\vcpkg"
vcpkg search openssl
vcpkg install openssl