]> Freerunner's - dotfiles.git/commitdiff
bin: recover lost file data from btrfs snapshot
authorAndre Ramnitz <tux.rising@gmail.com>
Sun, 10 Dec 2023 20:17:58 +0000 (21:17 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Sun, 10 Dec 2023 20:17:58 +0000 (21:17 +0100)
13 files changed:
bin/.local/bin/16.c [new file with mode: 0644]
bin/.local/bin/16c [new file with mode: 0755]
bin/.local/bin/256colors2.pl [new file with mode: 0755]
bin/.local/bin/_emergeworld [new file with mode: 0644]
bin/.local/bin/best_makeopts.sh
bin/.local/bin/colors [new file with mode: 0755]
bin/.local/bin/colr
bin/.local/bin/deadlib
bin/.local/bin/foot
bin/.local/bin/loadcolors.sh [new file with mode: 0755]
bin/.local/bin/mkchroot
bin/.local/bin/tasks_redirect.sh
bin/.local/bin/winecleaner

diff --git a/bin/.local/bin/16.c b/bin/.local/bin/16.c
new file mode 100644 (file)
index 0000000..325f2d0
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+static void aput( char* c, char bg_col, char fg_col )
+{  int bg, fg;
+   if( bg_col > 7 ) bg = 100 + bg_col-8;
+   else             bg =  40 + bg_col;
+   if( fg_col > 7 ) fg =  90 + fg_col-8;
+   else             fg =  30 + fg_col;
+   printf( "\033[%i;%im%s\033[0;0m", fg, bg, c );
+}
+
+int main( void )
+{  int bg, fg;
+   
+   for( fg = 0; fg <  8; fg += 1 ) aput("    ", fg, 0); putchar('\n');
+   for( fg = 8; fg < 16; fg += 1 ) aput("    ", fg, 0); putchar('\n');
+   putchar('\n'); 
+   for( bg = 0; bg < 16; bg += 1 )
+   {  for( fg = 0; fg < 16; fg += 1 )
+      {   aput( "10", bg, fg );  }
+      putchar('\n');
+   }
+}
+
diff --git a/bin/.local/bin/16c b/bin/.local/bin/16c
new file mode 100755 (executable)
index 0000000..76c10fb
Binary files /dev/null and b/bin/.local/bin/16c differ
diff --git a/bin/.local/bin/256colors2.pl b/bin/.local/bin/256colors2.pl
new file mode 100755 (executable)
index 0000000..2a880bd
--- /dev/null
@@ -0,0 +1,129 @@
+#!/usr/bin/perl
+# $XTermId: 256colors2.pl,v 1.10 2009/10/10 14:45:26 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2007,2009 by Thomas E. Dickey
+# Copyright 2002 by Steve Wall
+# Copyright 1999 by Todd Larason
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+use strict;
+
+use Getopt::Std;
+
+our ($opt_h, $opt_q, $opt_r);
+&getopts('hqr') || die("Usage: $0 [-q] [-r]");
+die("Usage: $0 [options]\n
+Options:
+  -h  display this message
+  -q  quieter output by merging all palette initialization
+  -r  display the reverse of the usual palette
+") if ( $opt_h);
+
+our ($red, $green, $blue);
+our ($gray, $level, $color);
+
+sub map_cube($) {
+       my $value = $_[0];
+       $value = (5 - $value) if defined($opt_r);
+       return $value;
+}
+
+sub map_gray($) {
+       my $value = $_[0];
+       $value = (23 - $value) if defined($opt_r);
+       return $value;
+}
+
+printf("\x1b]4") if ($opt_q);
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+       for ($blue = 0; $blue < 6; $blue++) {
+           printf("\x1b]4") unless ($opt_q);
+           printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+                  16 + (map_cube($red) * 36) + (map_cube($green) * 6) + map_cube($blue),
+                  ($red ? ($red * 40 + 55) : 0),
+                  ($green ? ($green * 40 + 55) : 0),
+                  ($blue ? ($blue * 40 + 55) : 0));
+           printf("\x1b\\") unless ($opt_q);
+       }
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = (map_gray($gray) * 10) + 8;
+    printf("\x1b]4") unless ($opt_q);
+    printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+          232 + $gray, $level, $level, $level);
+    printf("\x1b\\") unless ($opt_q);
+}
+printf("\x1b\\") if ($opt_q);
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 6x6x6:\n";
+for ($green = 0; $green < 6; $green++) {
+    for ($red = 0; $red < 6; $red++) {
+       for ($blue = 0; $blue < 6; $blue++) {
+           $color = 16 + ($red * 36) + ($green * 6) + $blue;
+           print "\x1b[48;5;${color}m  ";
+       }
+       print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 232; $color < 256; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
diff --git a/bin/.local/bin/_emergeworld b/bin/.local/bin/_emergeworld
new file mode 100644 (file)
index 0000000..b924b08
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+case "$1" in
+    "start")
+        date +%s > $HOME/.cache/emergestart && emerge -e --keep-going @world
+        ;;
+    "resume")
+       starttime=$(cat $HOME/.cache/emergestart)
+
+       eix '-I*' --format '<installedversions:DATESORT>' | cut -f1,3 >tmplist
+       echo $starttime >>tmplist
+       sort -n tmplist | sed -e/$starttime/q | sed -e'/[0-9]*\t*/s///' | sort | comm -23 - <(sort omitlist) | comm -23 - <(sort /etc/portage/profile/package.provided) >buildlist
+       rm tmplist
+       emerge -a `cat buildlist` --keep-going
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..865e283fe4ee4a02b50347502458ec2292c8433f 100755 (executable)
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+cpupower frequency-set -g performance -r
+
+PACKAGE="kde-frameworks/plasma"
+
+DISTDIR="/tmp/" emerge -f ${PACKAGE}
+
+for i in {1..32}
+do
+       echo 1 > /proc/sys/vm/drop_caches
+       time DISTDIR="/tmp" EMERGE_DEFAULT_OPTS="" MAKEOPTS="-j${i}" emerge -q1OB ${PACKAGE}
+       echo -ne "\n\n\n"
+done
+
+cpupower frequency-set -g schedutil -r
+
diff --git a/bin/.local/bin/colors b/bin/.local/bin/colors
new file mode 100755 (executable)
index 0000000..b6b7132
--- /dev/null
@@ -0,0 +1,62 @@
+#! /bin/bash
+set -e
+
+
+mainFunction () {
+    echo
+    printColors
+    printGuidelines
+}
+
+
+printColor () {
+    local color="${1}"
+
+    printf "\033[1;4%sm     " "${color}"
+    printf "\033[0m    "
+    printf "\033[1;3%smSampleText  " "${color}"
+    printf "\033[0;3%smSampleText  " "${color}"
+    printf "\033[0m\n"
+}
+
+
+printColors () {
+    local color
+    # 0 black
+    # 1 red
+    # 2 green
+    # 3 yellow
+    # 4 blue
+    # 5 magenta / orange
+    # 6 cyan / purple
+    # 7 white
+
+    for color in 0 7; do
+        printColor "${color}"
+    done
+    echo
+
+    for color in 4 5 6; do
+        printColor "${color}"
+    done
+    echo
+
+    for color in 2 3 1; do
+        printColor "${color}"
+    done
+    echo
+}
+
+
+printGuidelines () {
+    echo "A good palette has:"
+    echo "- All colors easy to read."
+    echo "- Similar eye catchiness within the same group, except for monochromes."
+    echo "- Similar or greater eye catchiness in upper groups, including this text."
+    echo "- Similar color within the same line."
+    echo "- The last group as: green yellow red."
+    echo
+}
+
+
+mainFunction
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..90c0b0592c68377fadb52ff9ce8a2943133e26c6 100755 (executable)
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+case $1 in
+    1)
+        set -e
+
+
+        mainFunction () {
+            echo
+            printColors
+            printGuidelines
+        }
+
+
+        printColor () {
+            local color="${1}"
+
+            printf "\033[1;4%sm     " "${color}"
+            printf "\033[0m    "
+            printf "\033[1;3%smSampleText  " "${color}"
+            printf "\033[0;3%smSampleText  " "${color}"
+            printf "\033[0m\n"
+        }
+
+
+        printColors () {
+            local color
+            # 0 black
+            # 1 red
+            # 2 green
+            # 3 yellow
+            # 4 blue
+            # 5 magenta / orange
+            # 6 cyan / purple
+            # 7 white
+
+            for color in 0 7; do
+                printColor "${color}"
+            done
+            echo
+
+            for color in 4 5 6; do
+                printColor "${color}"
+            done
+            echo
+
+            for color in 2 3 1; do
+                printColor "${color}"
+            done
+            echo
+        }
+
+
+        printGuidelines () {
+            echo "A good palette has:"
+            echo "- All colors easy to read."
+            echo "- Similar eye catchiness within the same group, except for monochromes."
+            echo "- Similar or greater eye catchiness in upper groups, including this text."
+            echo "- Similar color within the same line."
+            echo "- The last group as: green yellow red."
+            echo
+        }
+
+
+        mainFunction;;
+
+    2)
+        echo -e "\033[0mNC (No color)"
+        echo -e "\033[1;37mWHITE\t\033[0;30mBLACK"
+        echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE"
+        echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN"
+        echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN"
+        echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED"
+        echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE"
+        echo -e "\033[0;33mYELLOW\t\033[1;33mLIGHT_YELLOW"
+        echo -e "\033[1;30mGRAY\t\033[0;37mLIGHT_GRAY";;
+    3)
+        # Description:
+        #
+        #    Prints a color table of 8bg * 8fg * 2 states (regular/bold)
+        #
+        # Copyright:
+        #
+        #    (C) 2009 Wolfgang Frisch <xororand@unfoog.de>
+        #
+        # License:
+        #
+        #    This program is free software: you can redistribute it and/or modify
+        #    it under the terms of the GNU General Public License as published by
+        #    the Free Software Foundation, either version 3 of the License, or
+        #    (at your option) any later version.
+        #
+        #    This program is distributed in the hope that it will be useful,
+        #    but WITHOUT ANY WARRANTY; without even the implied warranty of
+        #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        #    GNU General Public License for more details.
+        #
+        #    You should have received a copy of the GNU General Public License
+        #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+        echo
+        echo Table for 16-color terminal escape sequences.
+        echo Replace ESC with \\033 in bash.
+        echo
+        echo "Background | Foreground colors"
+        echo "---------------------------------------------------------------------"
+        for((bg=40;bg<=47;bg++)); do
+            for((bold=0;bold<=1;bold++)) do
+                echo -en "\033[0m"" ESC[${bg}m   | "
+                for((fg=30;fg<=37;fg++)); do
+                    if [ $bold == "0" ]; then
+                        echo -en "\033[${bg}m\033[${fg}m [${fg}m  "
+                    else
+                        echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m"
+                    fi
+                done
+                echo -e "\033[0m"
+            done
+            echo "--------------------------------------------------------------------- "
+        done
+
+        echo
+        echo;;
+    4)
+        for colour in {1..225}
+            do echo -en "\033[38;5;${colour}m38;5;${colour} \n"
+            done | column -x;;
+    *)
+        colr 1
+        echo "Enter a number [1-4] to specify, which demo to run.";;
+esac
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1ccf188414c950b6d71bb087d45c4358356615e0 100755 (executable)
@@ -0,0 +1,3 @@
+#!/bin/bash
+lsof | grep 'DEL.*lib' | cut -f 1 -d ' ' | sort -u;
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d02110ac200f7cda470a65973f418164bedc6652 100755 (executable)
@@ -0,0 +1,2 @@
+#!/bin/sh
+foot -L /usr/bin/fish
diff --git a/bin/.local/bin/loadcolors.sh b/bin/.local/bin/loadcolors.sh
new file mode 100755 (executable)
index 0000000..5a4a1dd
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+openrgb -p simple
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6a5f0b24eef9a7fd240a30ae0c5b6ea1468edcd3 100755 (executable)
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+if [ "$UID" != "0" ]
+then
+     echo "You have to be root" >&2
+     exit 1
+fi
+
+CHROOT=$1
+
+if [ ! -f $CHROOT.in ]
+then
+     for mnt in /dev /dev/pts /proc /sys
+     do
+          echo "-- Mounting $mnt on $CHROOT/$mnt"
+          mount -o bind $mnt $CHROOT/$mnt || exit 1
+     done
+
+     if [ -f $CHROOT.shared ]
+     then
+          cat $CHROOT.shared | while read entry
+          do
+               folder=${entry%:*}
+               mnt=${entry#*:}
+
+               echo "-- Mounting $folder on $CHROOT/$mnt"
+               mkdir -p $CHROOT/$mnt || exit 1
+               mount -o bind $folder $CHROOT/$mnt || exit 1
+          done
+     fi
+
+     echo "1" > $CHROOT.in
+else
+     n=`cat $CHROOT.in`
+     let n=$n+1
+     echo "$n" > $CHROOT.in
+fi
+
+echo "-- Entering chroot"
+chroot $CHROOT /usr/bin/env HOME=/root TERM=$TERM /bin/bash --login +h || exit 1;
+
+n=`cat $CHROOT.in`
+let n=$n-1
+
+if [ "$n" = "0" ]
+then
+     for umnt in /sys /proc /dev/pts /dev
+     do
+          echo "-- Umounting $CHROOT/$umnt"
+          umount $CHROOT/$umnt || exit 1
+     done
+
+     if [ -f $CHROOT.shared ]
+     then
+          cat $CHROOT.shared | while read entry
+          do
+               mnt=${entry#*:}
+
+               echo "-- Umounting $CHROOT/$mnt"
+               umount $CHROOT/$mnt || exit 1
+          done
+     fi
+
+     rm $CHROOT.in
+else
+     echo "$n" > $CHROOT.in
+fi
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..904b071f262af4dd6b52f1bbd54ce2d1561adf91 100755 (executable)
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+echo "mounting the cpuset filesystem"
+if ! [ -d /dev/cpuset ]; then
+  mkdir /dev/cpuset
+  mount -t cpuset cpuset /dev/cpuset
+fi
+
+_prefix=""
+
+if [ -f /dev/cpuset/cpuset.cpus ];then
+  _prefix="cpuset."
+fi
+
+if ! [ -d /dev/cpuset/theUgly ]; then
+  echo "Creating theUgly"
+  mkdir /dev/cpuset/theUgly
+fi
+
+echo "Assigning CCX0's cores to the ugly cpu set"
+/bin/echo 8-15,24-31 > /dev/cpuset/theUgly/${_prefix}cpus
+
+echo "Giving the Ugly memory node 0"
+/bin/echo 0 > /dev/cpuset/theUgly/${_prefix}mems
+
+echo "Making the Ugly cpu exlusive"
+/bin/echo 1 > /dev/cpuset/theUgly/${_prefix}cpu_exclusive
+
+echo "Redirecting Processes"
+while read p; do
+  echo "Redirecting PID $p"
+  /bin/echo $p > /dev/cpuset/theUgly/tasks
+done < /dev/cpuset/tasks
+
+if ! [ -d /dev/cpuset/theGood ]; then
+  echo "Creating theGood"
+  mkdir /dev/cpuset/theGood
+fi
+
+echo "Assigning CCX1's cores to the Good cpu set"
+/bin/echo 0-7,16-23 > /dev/cpuset/theGood/${_prefix}cpus
+
+echo "Giving the Good memory node 0"
+/bin/echo 0 > /dev/cpuset/theGood/${_prefix}mems
+
+echo "Making the Good cpu exlusive"
+/bin/echo 1 > /dev/cpuset/theGood/${_prefix}cpu_exclusive
+
+read -p "Redirect Lutris to theGood ? y/n: "
+if [ "$REPLY" = "y" ];then
+  echo "Redirecting Lutris to theGood"
+  for i in  `pgrep lutris`; do echo $i > /dev/cpuset/theGood/tasks; done
+fi
+
+
+read -p "Redirect Steam to theGood ? y/n: "
+if [ "$REPLY" = "y" ];then
+  echo "Redirecting Lutris to theGood"
+  for i in  `pgrep steam`; do echo $i > /dev/cpuset/theGood/tasks; done
+fi
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3a28176cd2e2e32afd35bc86d14758be6bb9847f 100755 (executable)
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+function yes_or_no {
+    while true; do
+        read -rp "$* [y/n]: " yn
+        case $yn in
+            [Yy]*) return 0  ;;
+            [Nn]*) echo "Aborted" ; return  1 ;;
+        esac
+    done
+}
+
+PSOUTPUT="$(pgrep -l exe)"
+
+echo "Grepping ps for wine executables..."
+if [ -n "$PSOUTPUT" ]; then
+    echo "The following processes have been found:"
+    echo "$PSOUTPUT"
+    yes_or_no "Would you like to send sigkill to all processes?" && pgrep exe | xargs kill
+    echo "Verifying that all processes have been cleaned..."
+    sleep 7
+    PSOUTPUT="$(pgrep -l exe)"
+    if [ -n "$PSOUTPUT" ]; then
+        echo "Still some processes around. Please remove them manually..."
+        echo "$PSOUTPUT"
+    else
+        echo "All processes have been cleaned!"
+    fi
+else
+    echo "No wine executables found"
+fi