From c4e535792c80118074b502e583690e9df0aa23c0 Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Sat, 29 Jun 2024 14:20:02 +0800 Subject: update --- README.md | 31 ++++- mypath/ast.sh | 11 ++ mypath/clang-tidy-check.sh | 13 ++ mypath/compare.sh | 14 --- mypath/compile-tiny.sh | 61 ++++++++++ mypath/compile.sh | 41 +++++++ mypath/count.sh | 30 ----- mypath/gitadd.sh | 68 ++++------- mypath/gitk.sh | 2 - mypath/gui.py | 52 ++++++++ mypath/md2html.sh | 2 +- mypath/runjv.c | 39 ------ mypath/runjv.sh | 17 --- mypath/search.sh | 52 ++++++++ mypath/tokei | Bin 0 -> 7416736 bytes tools/.clang-format | 121 +++++++++++++++++++ tools/compile_vim.sh | 94 +++++++++++++++ vim/vimrc.tiny | 13 -- vim/vimrc_origin | 55 --------- vim/vimrcs/codecmd.vim | 9 +- vim/vimrcs/keybind.vim | 4 +- vim/vimrcs/match.vim | 9 +- vim/vimrcs/plugs.vim | 3 +- vim/vimscript.vim | 295 --------------------------------------------- 24 files changed, 511 insertions(+), 525 deletions(-) create mode 100755 mypath/ast.sh create mode 100755 mypath/clang-tidy-check.sh delete mode 100755 mypath/compare.sh create mode 100755 mypath/compile-tiny.sh create mode 100755 mypath/compile.sh delete mode 100755 mypath/count.sh delete mode 100755 mypath/gitk.sh create mode 100755 mypath/gui.py delete mode 100644 mypath/runjv.c delete mode 100755 mypath/runjv.sh create mode 100755 mypath/search.sh create mode 100755 mypath/tokei create mode 100644 tools/.clang-format create mode 100755 tools/compile_vim.sh delete mode 100644 vim/vimrc.tiny delete mode 100644 vim/vimrc_origin delete mode 100644 vim/vimscript.vim diff --git a/README.md b/README.md index 3fd6798..a52baad 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,30 @@ -[Pardon?] +这里是我自己用的一些小零件的暂存。 -这里是我自己用的一些代码的暂存。 +```plaintext +. +├── mypath # 个人使用内容 +│   ├── ast.sh # 使用clang打印c/cpp的ast树 +│   ├── clang-tidy-check.sh # 使用clang-tidy的指定规则检查代码 +│   ├── compile.sh # 使用ohos ndk进行cmake交叉编译 +│   ├── compile-tiny.sh # 使用ohos ndk对单个c/cpp文件交叉编译 +│   ├── dif.sh # 使用diff工具对比两个文件的差别 +│   ├── exe.sh # 对本路径下的脚本创建无后缀文件,方便日常使用 +│   ├── gitadd.sh # (在服务器上)快速添加一个远程库 +│   ├── gui.py # 在Linux下绘制ohos机器人得到的地图 +│   ├── md2html.sh # 使用pandoc将md文件转换为html文件 +│   ├── search.sh # 在当前路径下所有文件中查找指定内容 +│   └── tokei # 使用tokei统计代码行数 +├── README.md +├── tools +│   ├── compile_vim.sh # 自己编译vim +│   └── .clang-format # clang-format配置文件 +└── vim + ├── vimrc # vim配置文件,放置在/etc/vim/目录下 + └── vimrcs +    ├── codecmd.vim +    ├── keybind.vim +    ├── match.vim +    ├── myset.vim +    ├── plugs.vim +    └── statusline.vim +``` diff --git a/mypath/ast.sh b/mypath/ast.sh new file mode 100755 index 0000000..6ea2adc --- /dev/null +++ b/mypath/ast.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +########################################################################## +# File Name : ast.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2024-06-02 15:00:21 +########################################################################## + +/home/player/app/llvm-project/build/bin/clang -cc1 -ast-dump $1 diff --git a/mypath/clang-tidy-check.sh b/mypath/clang-tidy-check.sh new file mode 100755 index 0000000..cea6e36 --- /dev/null +++ b/mypath/clang-tidy-check.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +########################################################################## +# File Name : clang-tidy-check.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2024-04-28 16:50:37 +########################################################################## + +set -e + +clang-tidy -checks="-*,$2" -header-filter=.* $1 -- -I/usr/include diff --git a/mypath/compare.sh b/mypath/compare.sh deleted file mode 100755 index 2643b42..0000000 --- a/mypath/compare.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -file1="file1.txt" -file2="file2.txt" - -diff_output=$(diff "$file1" "$file2") - -if [ -z "$diff_output" ]; then - echo "两个文件完全一致" -else - echo "两个文件不完全一致" - echo "$diff_output" -fi - diff --git a/mypath/compile-tiny.sh b/mypath/compile-tiny.sh new file mode 100755 index 0000000..2bfdada --- /dev/null +++ b/mypath/compile-tiny.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +########################################################################## +# File Name : compile-tiny.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2024-04-16 13:06:58 +########################################################################## + +set -e +# 如果是root,报错 +if [ $(id -u) -eq 0 ]; then + echo "Do not run as root" + exit 1 +fi + +if [ $# -ne 2 ]; then + echo "Usage: $0 [armv8-a|armv7-a]" + exit 1 +fi + +native=~/app/native +file=$1 +targetFile=${file%.*} +arch=$2 + +case $arch in + armv8-a) + compiler=$native/llvm/bin/aarch64-unknown-linux-ohos + targetPlatform=aarch64-linux-ohos + ;; + armv7-a) + compiler=$native/llvm/bin/armv7-unknown-linux-ohos + targetPlatform=arm-linux-ohos + ;; + *) + echo "Unsupported arch" + exit 1 + ;; +esac + +case ${file##*.} in + c) + compiler=$compiler-clang + ;; + cpp) + compiler=$compiler-clang++ + ;; + *) + echo "Unsupported file type" + exit 1 + ;; +esac + +export CPATH= + +$compiler -o $targetFile $file -Wall \ + --target=$targetPlatform \ + --sysroot=$native/sysroot \ + -march=$arch -mfloat-abi=softfp diff --git a/mypath/compile.sh b/mypath/compile.sh new file mode 100755 index 0000000..2948e8f --- /dev/null +++ b/mypath/compile.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +########################################################################## +# File Name : compile.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2024-02-29 15:19:15 +########################################################################## + +set -e + +if [ $UID -eq 0 ]; then + echo "Please do not run this script as root" + exit 1 +fi + +if [ $# -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +if [ $2 == "v8" ]; then + arch=arm64-v8a +elif [ $2 == "v7" ]; then + arch=armeabi-v7a +else + echo "Usage: $0 " + exit 1 +fi + +link=$1 # static or shared +native_path=~/app/native + +export PATH=$native_path/build-tools/cmake/bin:$PATH +# 清空CPATH,防止影响编译 +export CPATH= + +# 使用cmake编译,编译生成的文件运行在rk3568上 +cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake) +cmake --build build diff --git a/mypath/count.sh b/mypath/count.sh deleted file mode 100755 index 5105b42..0000000 --- a/mypath/count.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -count_lines() { - local filename=$1 - local sum=0 - local buf - - while IFS= read -r buf; do - ((sum++)) - done < "$filename" - - echo "$sum" -} - -extensions=("c" "tex" "cpp" "py" "h") -sum=0 - -for extension in "${extensions[@]}"; do - files=$(find . -type f -name "*.$extension") - for file in $files; do - tmp=$(count_lines "$file") - ((sum+=tmp)) - echo "文件路径: $file" - echo "行数: $tmp" - echo - done -done - -echo "总行数: $sum" - diff --git a/mypath/gitadd.sh b/mypath/gitadd.sh index 79e750f..0ac59fa 100755 --- a/mypath/gitadd.sh +++ b/mypath/gitadd.sh @@ -1,45 +1,27 @@ #!/bin/bash -read -p "Local repo name: " local_name -read -p "Remote repo name: " remote_name - -# 远程仓库创建 -tmp="ssh aliyun-git git init --bare $remote_name.git" -eval "$tmp" - -# 本地仓库创建 -mkdir "$local_name" -cd "$local_name" -git init - -# 本地仓库初始化 -# 编写.gitignore -cat > .gitignore << EOF -*.sh -*.bat -*.exe -*.[oa] -*.pyc -__pycache__ -*.vscode -*.swp -EOF - -# 编写push.sh -cat > push.sh << EOF -git add . -git commit -git push -EOF -chmod +x push.sh - -# 提交初始化commit -git add . -git commit -m "Initial commit" -tmp="git remote add origin aliyun-git:$remote_name.git" -eval "$tmp" -git push --set-upstream origin master -git push - -echo "Success!" - +########################################################################## +# File Name : gitadd.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2024-03-21 19:26:53 +########################################################################## + +set -e + +repo_name="" +# 判断参数个数 +if [ $# -ne 1 ]; then + echo "Input repository name: " + read name + repo_name=$name +else + repo_name=$1 +fi + +sudo -u git -H bash -c "cd ~ && git init --bare $repo_name.git" +echo "Input description for the repository:" +read desc +sudo -u git -H bash -c "echo $desc > ~/$repo_name.git/description" +echo "Repository $1.git created successfully!" diff --git a/mypath/gitk.sh b/mypath/gitk.sh deleted file mode 100755 index aa6e515..0000000 --- a/mypath/gitk.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -git log --oneline --all --graph diff --git a/mypath/gui.py b/mypath/gui.py new file mode 100755 index 0000000..2835e96 --- /dev/null +++ b/mypath/gui.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +import matplotlib.pyplot as plt +from matplotlib.widgets import Button, TextBox +from tkinter.filedialog import askopenfilename +from scipy.ndimage import binary_dilation +import numpy as np +import os + +def load_and_process_image(file_path, structure_size): + with open(file_path, 'r') as f: + f.readline() # 忽略第一行 + lines = f.readlines() + lines = lines[::-1] # 颠倒一下,第一行在最下面 + + image_data = [list(map(int, line.strip().split())) for line in lines] + image_array = np.array(image_data) + structure = np.ones((structure_size, structure_size)) + image_array = binary_dilation(image_array, structure) + return image_array + +def on_button_click(event): + global file_path + file_path = askopenfilename() + structure_size = int(text_box.text) + image_array = load_and_process_image(file_path, structure_size) + ax.cla() + ax.imshow(image_array, cmap='gray', interpolation='nearest') + ax.set_title(file_path) + fig.canvas.draw() + +def update_cursor_position(event): + if event.inaxes == ax: + x, y = event.xdata, event.ydata + x -= 900 + y -= 900 + ax.set_title(f'{file_path} | Cursor: ({x:.2f}, {-y:.2f})') + fig.canvas.draw_idle() + +if __name__ == '__main__': + fig, ax = plt.subplots() + ax_button = plt.axes([0.05, 0.85, 0.1, 0.075]) + button = Button(ax_button, 'Open') + file_path = os.getcwd() + button.on_clicked(on_button_click) + + ax_text_box = plt.axes([0.05, 0.95, 0.1, 0.05]) + text_box = TextBox(ax_text_box, 'Size') + text_box.set_val(1) + + fig.canvas.mpl_connect('motion_notify_event', update_cursor_position) + + plt.show() \ No newline at end of file diff --git a/mypath/md2html.sh b/mypath/md2html.sh index e71f1d3..c520736 100755 --- a/mypath/md2html.sh +++ b/mypath/md2html.sh @@ -28,4 +28,4 @@ sed -i '/