misc improvements
authorIan Kelling <ian@iankelling.org>
Sat, 1 Feb 2025 03:33:43 +0000 (22:33 -0500)
committerIan Kelling <ian@iankelling.org>
Sat, 1 Feb 2025 03:33:43 +0000 (22:33 -0500)
brc
brc2
filesystem/etc/mysql/mariadb.conf.d/80-iank.cnf
fsf-script-lib

diff --git a/brc b/brc
index cbc1b76ac4c70b1100cd038bcf30cf8db0f5be88..355edb22d3f907be8d50df57c4cdba6bf889b48c 100644 (file)
--- a/brc
+++ b/brc
@@ -2254,6 +2254,8 @@ lowr() {
   done
 }
 
+# note: this does not work for EOL chars.
+# aka chomp in perl. note this doesn't work as you would want because its not a variable reference. todo: think about improving it.
 strips() {
   # remove leading whitespace characters
   var="${var#"${var%%[![:space:]]*}"}"
@@ -3002,7 +3004,7 @@ sk-p() {
 sk() {
   # see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications
   local quotes others ret
-  quotes=2048,2068,2086,2119,2206,2254
+  quotes=2048,2068,2086,2119,2206,2254,2231
   others=2029,2032,2033,2054,2164,2317
   shellcheck -x -W 999 -e $quotes,$others "$@" || ret=$?
   if (( ret >= 1 )); then
@@ -3473,7 +3475,7 @@ psoff() {
 # Turn on my prompt hook function.
 pson() {
   PROMPT_COMMAND=(prompt-command)
-  if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+  if [[ $TYPESCRIPT_SHELL != true && $TERM == *(screen*|xterm*|rxvt*) ]]; then
     trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG
   fi
 }
@@ -3970,27 +3972,28 @@ if [[ $- == *i* ]]; then
     # version 211203 does not have this feature, 230805 does.  we can't
     # detect this over ssh. We could copy the var over ssh, but I'd
     # rather just wait until i'm not running the earlier konsole.
-    if [[ $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then
+    if [[ $TYPESCRIPT_SHELL != true && $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then
       # This is from konsole, copied after pressing ctrl-alt-] .
-      # I figured out what it does from reading git clone https://gitlab.freedesktop.org/Per_Bothner/specifications
-      #
-      #proposals/semantic-prompts.md
+      # I figured out what it does from reading
+      # https://gitlab.freedesktop.org/Per_Bothner/specifications/proposals/semantic-prompts.md
+      # locally in /a/opt/freedesktop-specifications/proposals/semantic-prompts.md
       #
       # I tried figuring out what they really do from the konsole source code,
       # but I gave up.
       #
-      # \[\e]133;L\a\] This makes it so the last command is always
+      # This makes it so the last command is always
       # newline terminated. That is kind nice, but I also want to know
       # when they aren't, and this screws up my we() function, so
       # removed. The doc notes that Fish and ZSH both show a specific
       # char to indicate that happened, that sounds nice so I figured
       # out how to do that on my own.
+      #\[\e]133;L\a\]
       #
-      # \[\e]133;D;$?\]
       # This is something to try to show the last exit code. I already do that
       # and colorize it so removed.
+      # \[\e]133;D;$?\]
       #
-
+      # # This creates a think black line between prompts.
       if [[ ! $PS1 =~ 133 ]] ; then
         PS1='\[\e]133;A\a\]'"$PS1"'\[\e]133;B\a\]'
         # shellcheck disable=SC2034 # false positive
@@ -4038,8 +4041,8 @@ if [[ $- == *i* ]]; then
   #
   # for titlebar.
   # condition from the screen man page i think.
-  # note: duplicated in tx()
-  if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+  # note: duplicated in pson()
+  if [[ $TYPESCRIPT_SHELL != true && $TERM == *(screen*|xterm*|rxvt*) ]]; then
     # 40 chars is plenty.
     trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG
   else
@@ -4412,47 +4415,33 @@ xd() {
   "${cmd[@]}" "${files[@]}"
 }
 
-
-# Save some for loop typing. Run COMMAND on each of FILES, striping any
-# leading paths.
-#
-# CD_DIRECTORY is assumed if FILES exist in the current directory.
-#
-# usage: [ CD_DIRECTORY ] COMMAND... FILES..
+# for f in *; do hr $f; some command $f; done
+# forf some command *
 forf() {
-  local cdto f
   local -a cmd files
   while [[ $1 ]]; do
     if [[ -e $1 ]]; then
-      if [[ $1 == */* ]]; then
-        for arg; do
-          files+=( "${arg##*/}" )
-        done
-      else
-        if [[ -d $1 ]]; then
-          cdto="${cmd[0]}"
-          shift
-        fi
-        files=("$@")
-      fi
+      for arg; do
+        files+=( "${arg##*/}" )
+      done
       break
     fi
     cmd+=("$1")
     shift
   done
-  if [[ $cdto ]]; then
-    {
-      cd "$cdto"
-      for f in "${files[@]}"; do
-        "${cmd[@]:1}" "$f"
-      done
-    }
-  else
-    for f in "${files[@]}"; do
-      "${cmd[@]}" "$f"
-    done
-  fi
+  for f in "${files[@]}"; do
+    e "$f"
+    "${cmd[@]}" "$f"
+  done
 }
+# Historical side note. For some reason, I kept having to write a pattern like:
+# some_data=(*)
+# cd /some/other/place
+# for f in ${some_data[@]}; do some_command $f; done
+# So, I wrote a function to do it quicker, but I have no idea
+# what was causing me to have to keep doing that. So, I
+# deleted it. it is in git history.
+
 
 # exists or print. aka exists predicate.
 #
diff --git a/brc2 b/brc2
index db85357d143f509ad2e317bf6dcca09d9bb5065b..47d71c75dac8b97faf85df34b90aac27f81a3a3a 100644 (file)
--- a/brc2
+++ b/brc2
@@ -2302,7 +2302,11 @@ feh() {
 
 
 fw() {
-  firefox -P default "$@" >/dev/null 2>&1
+  count=$1
+  shift
+  for ((i=0; i<count; i++)); do
+    "$@"
+  done
 }
 
 gitian() {
@@ -3063,7 +3067,7 @@ mns-no-setup() {
   local ns
   ns=$1
   shift
-  m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
+  m sudm /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
 }
 
 mns() { # mount namespace
@@ -3071,16 +3075,37 @@ mns() { # mount namespace
   ns=$1
   shift
   mns-setup $ns
-  m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
+  m sudm /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
 }
 
 
 mnsr() { # mns run (as normal user)
-  local ns=$1
+  local ns pre_check tmpf user
+  user=$USER
+  while [[ $1 ]]; do
+    case $1 in
+      -p)
+        # note: this must call mns-setup
+        pre_check="$2"
+        shift 2
+        ;;
+      *)
+        break
+        ;;
+    esac
+  done
+  ns=$1
   shift
+
   env-tmpf "$@"
-  mns-setup $ns
-  m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns sudo -u iank -i bash -c ". $tmpf"
+
+  if [[ $pre_check ]]; then
+    sudm $pre_check
+  else
+    mns-setup $ns
+  fi
+
+  m sudm nsenter --mount=/root/mount_namespaces/$ns sudo -u iank -i bash -c ". $tmpf"
 }
 
 mnsd() { # mount namespace + systemd network namespace
@@ -3126,19 +3151,6 @@ mnsd() { # mount namespace + systemd network namespace
   m sudm nsenter -t $pid -n --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}"
 }
 
-
-mnsr() { # mns run (as normal user)
-  local ns=$1
-  local -a cmd
-  shift
-  if [[ $1 ]]; then
-    cmd=("$@")
-  else
-    cmd=(bash)
-  fi
-  mns $ns sudo -u iank -E env "PATH=$PATH" "${cmd[@]}"
-}
-
 mnsnonetroot() {
   ns=$1
   lomh
index 04bcfd4e2f50a12256d51ef0b415a27a1bc14ea4..110969d71d67a1e1763a913ed880aa19a4df0e55 100644 (file)
@@ -82,14 +82,14 @@ skip_name_resolve
 
 # === InnoDB Settings ===
 default_storage_engine          = InnoDB
-innodb_buffer_pool_instances    = 4     # Use 1 instance per 1GB of InnoDB pool size - max is 64
-innodb_buffer_pool_size         = 4G    # Use up to 70-80% of RAM
+innodb_buffer_pool_instances    = 16     # Use 1 instance per 1GB of InnoDB pool size - max is 64
+innodb_buffer_pool_size         = 16G    # Use up to 70-80% of RAM
 innodb_file_per_table           = 1
 innodb_flush_log_at_trx_commit  = 0
 innodb_flush_method             = O_DIRECT
 innodb_log_buffer_size          = 16M
 innodb_log_file_size            = 1G
-innodb_sort_buffer_size         = 4M    # UPD - Defines how much data is read into memory for sorting operations before writing to disk (default is 1M / max is 64M)
+innodb_sort_buffer_size         = 16M    # UPD - Defines how much data is read into memory for sorting operations before writing to disk (default is 1M / max is 64M)
 innodb_stats_on_metadata        = 0
 #innodb_use_fdatasync           = 1     # Only (!) for MySQL v8.0.26+
 
@@ -99,17 +99,16 @@ innodb_stats_on_metadata        = 0
                                         # the overall load produced by MySQL/MariaDB.
 innodb_read_io_threads          = 64
 innodb_write_io_threads         = 64
-innodb_io_capacity             = 2000  # Depends on the storage tech - use 2000 for SSD, more for NVMe
+#innodb_io_capacity             = 10000  # Depends on the storage tech - use 2000 for SSD, more for NVMe
 #innodb_io_capacity_max         = 4000  # Usually double the value of innodb_io_capacity
 
 # === MyISAM Settings ===
-# The following 3 options are ONLY supported by MariaDB & up to MySQL 5.7
 # Do NOT un-comment on MySQL 8.x+
 #query_cache_limit              = 4M    # UPD
 #query_cache_size               = 64M   # UPD
 #query_cache_type               = 1     # Enabled by default
 
-key_buffer_size                 = 16M   # UPD
+key_buffer_size                 = 64M   # UPD
 
 low_priority_updates            = 1
 concurrent_insert               = 2
@@ -122,7 +121,11 @@ thread_cache_size               = 100
 thread_stack                    = 192K
 
 interactive_timeout             = 180
-wait_timeout                    = 180
+# iank. this caused digikam to get into a useless state when it timed out when i was not using it.
+# default is 8 hours, per
+# SELECT variable_name, default_value FROM information_schema.system_variables ORDER BY variable_name
+# https://stackoverflow.com/questions/48830212/mariadb-default-my-cnf-in-sources
+# wait_timeout                    = 180
 
 # For MySQL 5.7+ only (disabled by default)
 #max_execution_time             = 90000 # Set a timeout limit for SELECT statements (value in milliseconds).
@@ -142,10 +145,10 @@ wait_timeout                    = 180
 # Other options will also add up to RAM consumption (e.g. tmp_table_size). So don't go switching your "join_buffer_size" to 1G, it's harmful & inefficient.
 # Use one of the database diagnostics tools mentioned at the top of this file to count your database's potential total RAM usage, so you know if you are within
 # reasonable limits. Remember that other services will require enough RAM to operate properly (like Apache or PHP-FPM), so set your limits wisely.
-join_buffer_size                = 4M    # UPD
-read_buffer_size                = 3M    # UPD
-read_rnd_buffer_size            = 4M    # UPD
-sort_buffer_size                = 4M    # UPD
+join_buffer_size                = 8M    # UPD
+read_buffer_size                = 6M    # UPD
+read_rnd_buffer_size            = 8M    # UPD
+sort_buffer_size                = 32M    # UPD
 
 # === Table Settings ===
 # In systemd managed systems like Ubuntu 16.04+ or CentOS 7+, you need to perform an extra action for table_open_cache & open_files_limit
@@ -154,7 +157,7 @@ sort_buffer_size                = 4M    # UPD
 # and for MariaDB check: https://mariadb.com/kb/en/library/systemd/
 table_definition_cache          = 50000 # UPD
 table_open_cache                = 50000 # UPD
-open_files_limit                = 60000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
+open_files_limit                = 600000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
                                         # open files limit usually set in /etc/sysctl.conf and /etc/security/limits.conf
                                         # In systemd managed systems this limit must also be set in:
                                         # - /etc/systemd/system/mysql.service.d/override.conf (for MySQL 5.7+ in Ubuntu) or
@@ -169,16 +172,17 @@ open_files_limit                = 60000 # UPD - This can be 2x to 3x the table_o
                                         # Finally merge the changes with:
                                         # $ systemctl daemon-reload; systemctl restart mysql (or mysqld or mariadb)
 
-max_heap_table_size             = 128M  # Increase to 256M, 512M or 1G if you have lots of temporary tables because of missing indices in JOINs
-tmp_table_size                  = 128M  # Use same value as max_heap_table_size
+max_heap_table_size             = 256M  # Increase to 256M, 512M or 1G if you have lots of temporary tables because of missing indices in JOINs
+tmp_table_size                  = 256M  # Use same value as max_heap_table_size
 
 # === Search Settings ===
 ft_min_word_len                 = 3     # Minimum length of words to be indexed for search results
 
 # === Binary Logging ===
-disable_log_bin                 = 1     # Binary logging disabled by default
-#log_bin                                # To enable binary logging, uncomment this line & only one of the following 2 lines
+#disable_log_bin                 = 1     # Binary logging disabled by default
+log_bin                                # To enable binary logging, uncomment this line & only one of the following 2 lines
                                         # that corresponds to your actual MySQL/MariaDB version.
                                         # Remember to comment out the line with "disable_log_bin".
 #expire_logs_days               = 1     # Keep logs for 1 day - For MySQL 5.x & MariaDB before 10.6 only
-#binlog_expire_logs_seconds     = 86400 # Keep logs for 1 day (in seconds) - For MySQL 8+ & MariaDB 10.6+ only
+binlog_expire_logs_seconds     = 86400 # Keep logs for 1 day (in seconds) - For MySQL 8+ & MariaDB 10.6+ only
+log_bin_trust_function_creators = 1
index 6392b742c59f82d2b370c970fd024c18a96bd1ae..9876c104863ccf52f7367515f917dc1290419d82 100644 (file)
@@ -60,7 +60,7 @@ slog() {
     fi
   fi
 
-  script -t $log_path.s 2> $log_path.t
+  TYPESCRIPT_SHELL=true script -t $log_path.s 2> $log_path.t
 }