From e513ed8c1adbf9a3ce31fa7b244cee336dee6ed9 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 31 Oct 2023 21:43:50 +0800 Subject: [PATCH 01/16] .vimrc: 3: Fix#2 for an empty chunk 1 --- .vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index b1a399f..31f765b 100644 --- a/.vimrc +++ b/.vimrc @@ -113,7 +113,7 @@ noremap # :let ic_save=&ic:set noic#:let &ic=ic_save noremap :w:!aspell --check '%':e noremap gq] gq/^. \?$ noremap 1 :w:make -j1 -noremap 3 /^ddkV/^k:w! 1gvxddV/^=======k:w! 2gvxddV/^k:w! 3/^dd''0:!diff -u 2 1 +noremap 3 /^ddVk/^k:w! 1gvxddV/^=======k:w! 2gvxddV/^k:w! 3/^dd''0:!diff -u 2 1 noremap m :w:set makeprg=make:make noremap n :w:set makeprg=ninja:make -- 1.8.3.1 From a7d2a95739783e143b94e931eb04e6a2c7513cf3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 9 Nov 2023 12:00:17 +0800 Subject: [PATCH 02/16] .bashrc: +alias date --- .bashrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index 0ead09c..82e5139 100644 --- a/.bashrc +++ b/.bashrc @@ -216,7 +216,9 @@ export GDBHISTFILE="$HOME/.gdb_history" export CVS_RSH="ssh" export TZ="Asia/Manila" #export TZ="Europe/Prague" -#export TZ="Canada/Eastern" +if [ "$TZ" = Asia/Manila ];then + alias date='TZ=Asia/Manila date;TZ=Europe/Prague date' +fi export PYTHONUNBUFFERED=1 export ASAN_OPTIONS=detect_leaks=0 export GTK_OVERLAY_SCROLLING=0 -- 1.8.3.1 From a0fd0c6bef233024e2c8fdfe7b39cdde86f35813 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 9 Nov 2023 12:00:34 +0800 Subject: [PATCH 03/16] .ssh/config: Updates --- .ssh/config | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.ssh/config b/.ssh/config index e1a2065..f9eeff1 100644 --- a/.ssh/config +++ b/.ssh/config @@ -4,6 +4,7 @@ IdentityFile ~/.ssh/id_rsa-old IdentityFile ~/.ssh/identity IdentityFile ~/.ssh/koji-id_rsa IdentityFile ~/.ssh/id_dsa-sourceware +IdentityFile ~/.ssh/id_ed25519 Host localhost #Cipher none @@ -101,7 +102,7 @@ Host download-stock HostName vps2.jankratochvil.net HostKeyAlias vps2.jankratochvil.net -Host cosmo8 cosmo8.jankratochvil.net cosmo8t.jankratochvil.net +Host cosmo8 cosmo8.jankratochvil.net cosmo8t.jankratochvil.net p20 Port 8022 # Cosmo: @@ -134,13 +135,7 @@ ControlPersist 60 # OpenWrt # https://bugzilla.redhat.com/show_bug.cgi?id=1881301#c38 Host 192.168.66.13 ap13 -PubkeyAcceptedKeyTypes ssh-rsa -User root - -Host jane -HostName jane.jankratochvil.net -HostKeyAlias jane.jankratochvil.net -Host jane jane.jankratochvil.net +#PubkeyAcceptedKeyTypes ssh-rsa User root Host dev? dev?.azulsystems.com -- 1.8.3.1 From dad452786a850180c4fa2897013bb56a681abfb3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 10 Nov 2023 22:46:51 +0800 Subject: [PATCH 04/16] .ssh/config: +zulu-dev --- .ssh/config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ssh/config b/.ssh/config index f9eeff1..e7d34ff 100644 --- a/.ssh/config +++ b/.ssh/config @@ -156,6 +156,9 @@ Host rpi4-06 HostName rpi4-06.azulsystems.com Host rpi4-* rpi4-*.azulsystems.com User jenkins +Host zulu-dev +User ubuntu +HostName 10.10.164.222 Host * Compression yes -- 1.8.3.1 From 7ce1484636644daf7e0974c17fc0b32581114d2c Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 10 Nov 2023 22:47:23 +0800 Subject: [PATCH 05/16] +bin/vi-git-both-modified --- bin/vi-git-both-modified | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 bin/vi-git-both-modified diff --git a/bin/vi-git-both-modified b/bin/vi-git-both-modified new file mode 100755 index 0000000..8f47892 --- /dev/null +++ b/bin/vi-git-both-modified @@ -0,0 +1,15 @@ +#! /bin/bash +fis="" +for fi in $(git status|sed -n 's/^ both modified: *//p');do + if ! grep -q '^<<<<<<< ' $fi;then + git add $fi + continue + fi + fis="$fis $fi" +done +if [ -z "$fis" ];then + echo done + exit 0 +fi +set -x +exec vim $fis -- 1.8.3.1 From 33d6beda5548a0c13807ba735b3d1c89df06934a Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 2 Dec 2023 19:35:07 +0800 Subject: [PATCH 06/16] bin/psu: +check Starlink --- bin/psu | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/psu b/bin/psu index f5dc004..51cdf90 100755 --- a/bin/psu +++ b/bin/psu @@ -1,2 +1,4 @@ #! /bin/bash -acpi|&grep -Eq 'Battery 0: Not charging|Battery 0: Charging|No support for device type: power_supply' +acpi|&grep -Eq 'Battery 0: Not charging|Battery 0: Charging|No support for device type: power_supply' || exit 1 +grpcurl -v -plaintext -d '{"get_status":{}}' 192.168.1.1:9000 SpaceX.API.Device.Device/Handle &>/dev/null || exit 1 +exit 0 -- 1.8.3.1 From 5626e9468c2843d6eb4b32080be30f6cbb90f048 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 12 Dec 2023 19:18:39 +0800 Subject: [PATCH 07/16] .vimrc: 3: More rework/fixes. --- .vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index 31f765b..e3dd08e 100644 --- a/.vimrc +++ b/.vimrc @@ -113,7 +113,7 @@ noremap # :let ic_save=&ic:set noic#:let &ic=ic_save noremap :w:!aspell --check '%':e noremap gq] gq/^. \?$ noremap 1 :w:make -j1 -noremap 3 /^ddVk/^k:w! 1gvxddV/^=======k:w! 2gvxddV/^k:w! 3/^dd''0:!diff -u 2 1 +noremap 3 /^kmajd$V/^k:w! 1gvxd$V/^=======k:w! 2gvxd$V/^k:w! 3gvxdd'a0:!diff -u 2 1;diff -u 2 3 noremap m :w:set makeprg=make:make noremap n :w:set makeprg=ninja:make -- 1.8.3.1 From 6a8b49a9c2bf3dafa999d8d9e6a3726b581eb8bb Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 15 Dec 2023 15:57:10 +0800 Subject: [PATCH 08/16] .muttrc.addons: +set abort_noattach=ask-yes --- .muttrc.addons | 1 + 1 file changed, 1 insertion(+) diff --git a/.muttrc.addons b/.muttrc.addons index b44943c..7205f18 100644 --- a/.muttrc.addons +++ b/.muttrc.addons @@ -60,6 +60,7 @@ macro index m "l~N|~O\n" macro pager f ":set pager_index_lines=0\n macro pager g ":set pager_index_lines=10\n" set user_agent +set abort_noattach=ask-yes # https://unix.stackexchange.com/a/42714/296319 auto_view text/html # view html automatically -- 1.8.3.1 From 1ea922510816fff90f9f239f99b67f925c3398c2 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 27 Dec 2023 09:26:06 +0800 Subject: [PATCH 09/16] src/streamfer*: Fix timestamps. --- src/streamfer-client.C | 66 ++++++++++++++++++++++++++++++++------------------ src/streamfer-server.C | 5 ++++ 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/streamfer-client.C b/src/streamfer-client.C index e998ffd..ce4e923 100644 --- a/src/streamfer-client.C +++ b/src/streamfer-client.C @@ -18,11 +18,25 @@ static string get_string(FILE *f,const char *fn,const char *what) { return buf; } -// https://stackoverflow.com/a/8615450/2995591 -#include // glob(), globfree() -#include // memset() -#include -#include +static void last_stored_write(const char *last_stored_fn,const string &filename,uint64_t offset) { + int last_stored_fd(open(last_stored_fn,O_WRONLY|O_CREAT|O_TRUNC,0644)); + if (last_stored_fd==-1) + fatal("Error storing filename to %s: %m",last_stored_fn); + write_safe(last_stored_fd,filename.c_str(),filename.length()); + write_safe(last_stored_fd,'\n'); + string offsetstr(stringf("%zu",(size_t)offset)); + write_safe(last_stored_fd,offsetstr.c_str(),offsetstr.length()); + write_safe(last_stored_fd,'\n'); + if (close(last_stored_fd)) + fatal("Error closing %s: %m",last_stored_fn); +} + +static string my_basename(const string &path) { + size_t slash(path.find_last_of('/')); + if (slash!=string::npos) + return path.substr(slash+1); + return path; +} int main(int argc,char **argv) { if (argc!=1+3) @@ -54,8 +68,20 @@ int main(int argc,char **argv) { } write_safe(server_fd,last_found); write_safe(server_fd,offset); + { struct stat statbuf; + string last_found_basename(my_basename(last_found)); + if (stat(last_found_basename.c_str(),&statbuf)) { + static const struct timespec mtim_zero{}; + write_safe(server_fd,mtim_zero); + } else + write_safe(server_fd,statbuf.st_mtim); + } string last_got; - read_safe(server_fd,last_got); + try { + read_safe(server_fd,last_got); + } catch (SafeIOError) { + fatal("SafeIOError reading from the server %s",argv[1]); + } if (last_got.empty()) { warning("No more files to transfer"); exit(EXIT_SUCCESS); @@ -63,12 +89,7 @@ int main(int argc,char **argv) { struct timespec mtim; read_safe(server_fd,mtim); int file_fd; - string file_name; - size_t slash(last_got.find_last_of('/')); - if (slash!=string::npos) - file_name=last_got.substr(slash+1); - else - file_name=last_got; + string file_name(my_basename(last_got));; if (last_found==last_got) { file_fd=open(file_name.c_str(),O_WRONLY); if (file_fd==-1) @@ -82,9 +103,15 @@ int main(int argc,char **argv) { if (file_fd==-1) fatal("Error creating %s: %m",file_name.c_str()); } + last_stored_write(last_stored_fn,last_got,offset); uint64_t transferred(transfer(server_fd,"server fd",file_fd,file_name.c_str())); - if (!transferred) - return EXIT_FAILURE; + if (!transferred) { + struct stat statbuf; + int err(fstat(file_fd,&statbuf)); + assert(!err); + if (memcmp(&mtim,&statbuf.st_mtim,sizeof(mtim))==0) + return EXIT_FAILURE; + } offset+=transferred; struct timespec mtim2[2]; mtim2[0]=mtim; // atime @@ -93,15 +120,6 @@ int main(int argc,char **argv) { fatal("Error setting timestamp of %s: %m",file_name.c_str()); if (close(file_fd)) fatal("Error closing %s: %m",file_name.c_str()); - int last_stored_fd(open(last_stored_fn,O_WRONLY|O_CREAT|O_TRUNC,0644)); - if (last_stored_fd==-1) - fatal("Error storing filename to %s: %m",last_stored_fn); - write_safe(last_stored_fd,last_got.c_str(),last_got.length()); - write_safe(last_stored_fd,'\n'); - string offsetstr(stringf("%zu",(size_t)offset)); - write_safe(last_stored_fd,offsetstr.c_str(),offsetstr.length()); - write_safe(last_stored_fd,'\n'); - if (close(last_stored_fd)) - fatal("Error closing %s: %m",last_stored_fn); + last_stored_write(last_stored_fn,last_got,offset); return EXIT_SUCCESS; } diff --git a/src/streamfer-server.C b/src/streamfer-server.C index dedb9f3..5a0bd8a 100644 --- a/src/streamfer-server.C +++ b/src/streamfer-server.C @@ -145,6 +145,8 @@ int main(int argc,char **argv) { fatal("Requested too new file"); uint64_t offset; read_safe(client_fd,offset); + struct timespec mtim; + read_safe(client_fd,mtim); const string *fnp; int file_fd=-1; struct stat statbuf; @@ -161,6 +163,9 @@ int main(int argc,char **argv) { assert(!err); if (offset<(uint64_t)statbuf.st_size) break; + static const struct timespec mtim_zero{}; + if (memcmp(&mtim,&mtim_zero,sizeof(mtim))!=0&&memcmp(&mtim,&statbuf.st_mtim,sizeof(mtim))!=0) + break; if (offset>(uint64_t)statbuf.st_size) warning("File %s has transferred %zu < %zu which is its size",fn.c_str(),(size_t)offset,(size_t)statbuf.st_size); if (lastix==matched.size()-1&&execname) -- 1.8.3.1 From 870664ea57bb654f26372c1e0ec3b8b6f903b029 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 27 Dec 2023 23:19:05 +0800 Subject: [PATCH 10/16] src/streamfer-client: *.last: Use ".new" + rename - vps2 CIFS did make the *.last files 0-sized --- src/streamfer-client.C | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/streamfer-client.C b/src/streamfer-client.C index ce4e923..b2b9a61 100644 --- a/src/streamfer-client.C +++ b/src/streamfer-client.C @@ -19,16 +19,19 @@ static string get_string(FILE *f,const char *fn,const char *what) { } static void last_stored_write(const char *last_stored_fn,const string &filename,uint64_t offset) { - int last_stored_fd(open(last_stored_fn,O_WRONLY|O_CREAT|O_TRUNC,0644)); - if (last_stored_fd==-1) - fatal("Error storing filename to %s: %m",last_stored_fn); - write_safe(last_stored_fd,filename.c_str(),filename.length()); - write_safe(last_stored_fd,'\n'); + std::string last_tmp_fn(std::string(last_stored_fn)+".new"); + int last_tmp_fd(open(last_tmp_fn.c_str(),O_WRONLY|O_CREAT|O_TRUNC,0644)); + if (last_tmp_fd==-1) + fatal("Error storing filename to %s: %m",last_tmp_fn.c_str()); + write_safe(last_tmp_fd,filename.c_str(),filename.length()); + write_safe(last_tmp_fd,'\n'); string offsetstr(stringf("%zu",(size_t)offset)); - write_safe(last_stored_fd,offsetstr.c_str(),offsetstr.length()); - write_safe(last_stored_fd,'\n'); - if (close(last_stored_fd)) - fatal("Error closing %s: %m",last_stored_fn); + write_safe(last_tmp_fd,offsetstr.c_str(),offsetstr.length()); + write_safe(last_tmp_fd,'\n'); + if (close(last_tmp_fd)) + fatal("Error closing %s: %m",last_tmp_fn.c_str()); + if (rename(last_tmp_fn.c_str(),last_stored_fn)) + fatal("Error renaming %s->%s: %m",last_tmp_fn.c_str(),last_stored_fn); } static string my_basename(const string &path) { -- 1.8.3.1 From f8c542e2fbe5f61421d6e15e333f11156674f746 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 11 Feb 2024 20:24:13 +0800 Subject: [PATCH 11/16] .vimrc: alt-f -> alt-d, alt-f: vim-fugitive --- .vimrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index e3dd08e..8699883 100644 --- a/.vimrc +++ b/.vimrc @@ -99,7 +99,8 @@ endif noremap! [23~ noremap M :cnzz noremap L :cpzz -noremap f "myiw:grep-Ew'm'`git ls-files` +noremap d "myiw:grep-Ew'm'`git ls-files` +noremap f "myiw:Ggrep-Ew'm' noremap g "myiw:grep-rEw'm'. noremap zz noremap zz -- 1.8.3.1 From 1030bd8ae5433ceb966cb6c5e4650dd6a795728c Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 9 Apr 2024 16:18:07 +0800 Subject: [PATCH 12/16] psu: full paths --- bin/psu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/psu b/bin/psu index 51cdf90..c8d9697 100755 --- a/bin/psu +++ b/bin/psu @@ -1,4 +1,4 @@ #! /bin/bash -acpi|&grep -Eq 'Battery 0: Not charging|Battery 0: Charging|No support for device type: power_supply' || exit 1 -grpcurl -v -plaintext -d '{"get_status":{}}' 192.168.1.1:9000 SpaceX.API.Device.Device/Handle &>/dev/null || exit 1 +/usr/bin/acpi|&grep -Eq 'Battery 0: Not charging|Battery 0: Charging|No support for device type: power_supply' || exit 1 +/usr/bin/grpcurl -v -plaintext -d '{"get_status":{}}' 192.168.1.1:9000 SpaceX.API.Device.Device/Handle &>/dev/null || exit 1 exit 0 -- 1.8.3.1 From cd036efe8a69554046316164f39228852fb4d673 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 9 Apr 2024 16:19:17 +0800 Subject: [PATCH 13/16] +bin/hog --- bin/hog | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/hog diff --git a/bin/hog b/bin/hog new file mode 100755 index 0000000..4dd1017 --- /dev/null +++ b/bin/hog @@ -0,0 +1,19 @@ +#! /usr/bin/perl +use strict; +use warnings; +my $psu=system($ENV{"HOME"}."/bin/psu")==0; +local *F; +open F,"/usr/bin/top -b -n2 -d1|" or die; +my $top=0; +while () { + /^top / && $top++; + /^$/ && $top++; + next if $top!=5; + /^(?:\s*\S+){8}\s*(\S+)\s*\S+\s*([^:\s]*):/ or next; + next if $1<90; # CPU % + next if $2<($psu?30:1); # minutes it has run + tr/'//d; + system "DISPLAY=:0 xmessage -timeout 30 -default okay -center '$_' 2>/dev/null"; + exit 0; +} +close F or die; -- 1.8.3.1 From 439761a7db17dfe7b885cf0aab32ddac6a2fee06 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 11 Apr 2024 16:28:35 +0800 Subject: [PATCH 14/16] +bin/nn --- bin/nn | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 bin/nn diff --git a/bin/nn b/bin/nn new file mode 100755 index 0000000..d8ce7f4 --- /dev/null +++ b/bin/nn @@ -0,0 +1,9 @@ +#! /bin/sh +if [ -z "$*" ];then + echo >&2 "No PID" +elif [ "$1" = "-p" ];then + shift + exec chrt -i -p 0 "$@" +else + exec chrt -i 0 "$@" +fi -- 1.8.3.1 From 5cf634f6c41697a312fad143ce20fb408fd81b66 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 11 Apr 2024 18:19:12 +0800 Subject: [PATCH 15/16] .vimrc: +vim-fugitive --- .vimrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index 8699883..2322696 100644 --- a/.vimrc +++ b/.vimrc @@ -99,8 +99,9 @@ endif noremap! [23~ noremap M :cnzz noremap L :cpzz -noremap d "myiw:grep-Ew'm'`git ls-files` +" dnf install vim-fugitive noremap f "myiw:Ggrep-Ew'm' +noremap F "myiw:grep-Ew'm'`git ls-files` noremap g "myiw:grep-rEw'm'. noremap zz noremap zz -- 1.8.3.1 From 27637408d0d1104f5fe06f13ee71c4310171aad2 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 19 Apr 2024 21:39:16 +0800 Subject: [PATCH 16/16] +.config/yt-dlp.conf --- .config/yt-dlp.conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 .config/yt-dlp.conf diff --git a/.config/yt-dlp.conf b/.config/yt-dlp.conf new file mode 100644 index 0000000..ce0622d --- /dev/null +++ b/.config/yt-dlp.conf @@ -0,0 +1 @@ +--restrict-filenames -- 1.8.3.1