Skip to content

Instantly share code, notes, and snippets.

@Zorono
Last active March 19, 2023 23:35
Show Gist options
  • Save Zorono/c5f986305984282e8b83902a83e991de to your computer and use it in GitHub Desktop.
Save Zorono/c5f986305984282e8b83902a83e991de to your computer and use it in GitHub Desktop.
whatever...
#!/usr/bin/env bash
if [[ ! $EUID -eq 0 ]]; then
echo "ERROR: You're not running as root!"
exit 1
fi
echo "Clearing snapd Cache..."
rm -rvf /var/lib/snapd/cache/**
echo "Clearing Disabled Snaps..."
snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision
do
snap remove "$snapname" --revision="$revision";
done
echo "Clearing old Snapshots..."
declare -i snapInt=0;
while [ $snapInt -ne 100 ];
do
snapInt=$((snapInt+1))
snap forget $snapInt
done
snap save
echo "Clearning Unused Flatpaks..."
flatpak uninstall --unused
echo "Clearing old journals..."
journalctl --vacuum-time=3d
echo "Clearing old logs..."
echo "Erasing log files which wasn't accessed last 3 days nor modified last 7 days!"
find /var/log -mtime +7 -atime +3 -type f -exec rm -iv {}
echo "Rotating log files which is bigger than 1GB!"
find /var/log -size +1G -type f -exec logrotate -v --log={}
echo "Clearing temporary resources..."
rm -rvf /tmp/**
rm -rvf /var/tmp/**
echo "Clearing global caches..."
rm -rvf /var/cache/**
echo "Clearing apt cache..."
rm -rvf /var/cache/apt/archives/**
mkdir -p /var/cache/apt/archives/partial
rm -rvf /var/cache/apt/apt-fast/**
mkdir -p /var/cache/apt/apt-fast/partial
echo "Clearing junk apt resources..."
apt-get autoremove
apt-get autoclean
apt-get clean
echo "Clearing Homebrew's Junk cache..."
brew cleanup
echo "Clearing Local(USER=$USER) Cache..."
rm -rvf /home/*/.cache/**
echo "Cleaning Trash..."
rm -rvf /home/*/.local/share/Trash/*/**
rm -rvf /root/.local/share/Trash/*/**
echo "Cleanup is completed!"
#!/usr/bin/env bash
Args=$1
#/opt/lampp/bin/php
#/opt/lampp/composer.phar
if [[ -n "$Args" ]]; then
/usr/bin/php "/opt/composer.phar" $Args
else
/usr/bin/php "/opt/composer.phar"
fi
#!/usr/bin/env bash
if [[ $EUID -eq 1000 ]]; then
echo "ERROR: You're not running as root!"
exit 1
fi
if [ -e "/run/user/1000/dconf/user" ]
then
rm -f /run/user/1000/dconf/user
fi
#!/usr/bin/env bash
#
# Copyright 2011 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Let the wrapped binary know that it has been run through the wrapper.
#export CHROME_WRAPPER="`readlink -f "/usr/bin/google-chrome"`"
export CHROME_WRAPPER="/opt/google/chrome/chrome"
HERE="`dirname "$CHROME_WRAPPER"`"
# We include some xdg utilities next to the binary, and we want to prefer them
# over the system versions when we know the system versions are very old. We
# detect whether the system xdg utilities are sufficiently new to be likely to
# work for us by looking for xdg-settings. If we find it, we leave $PATH alone,
# so that the system xdg utilities (including any distro patches) will be used.
if ! command -v xdg-settings &> /dev/null; then
# Old xdg utilities. Prepend $HERE to $PATH to use ours instead.
export PATH="$HERE:$PATH"
else
# Use system xdg utilities. But first create mimeapps.list if it doesn't
# exist; some systems have bugs in xdg-mime that make it fail without it.
xdg_app_dir="${XDG_DATA_HOME:-$HOME/.local/share/applications}"
mkdir -p "$xdg_app_dir"
[ -f "$xdg_app_dir/mimeapps.list" ] || touch "$xdg_app_dir/mimeapps.list"
fi
# Always use our versions of ffmpeg libs.
# This also makes RPMs find the compatibly-named library symlinks.
if [[ -n "$LD_LIBRARY_PATH" ]]; then
LD_LIBRARY_PATH="$HERE:$HERE/lib:$LD_LIBRARY_PATH"
else
LD_LIBRARY_PATH="$HERE:$HERE/lib"
fi
export LD_LIBRARY_PATH
export CHROME_VERSION_EXTRA="stable"
# We don't want bug-buddy intercepting our crashes. http://crbug.com/24120
export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME
# Sanitize std{in,out,err} because they'll be shared with untrusted child
# processes (http://crbug.com/376567).
exec < /dev/null
exec > >(exec cat)
exec 2> >(exec cat >&2)
#####
echo "Starting a limited google-chrome process..."
#
/usr/bin/env cpulimit --limit=200 --include-children /usr/bin/env nice --adjustment=19 /usr/bin/env ionice --classdata 5 --class 2 $HERE/chrome
#!/usr/bin/env bash
echo "Current Directory: $PWD";
find "$PWD" -maxdepth 2 -type d | while read dirN;
do
if [ ! -L "$dirN" ]; then
if [ -f "$dirN/.git/config" ]; then
echo "Current SubDirectory: $dirN";
cd "$dirN";
git pull --recurse-submodules $(git config --get $(echo remote.$(git remote | head -n 1).url) | grep -o 'https://[^"]*');
git submodule foreach git pull --recurse-submodules $(git config --get $(echo remote.$(git remote | head -n 1).url) | grep -o 'https://[^"]*') HEAD; #$(git branch --list | grep -Eiw 'main|master' | awk '{ print substr( $0, 2) }')
git submodule update --init --recursive;
git fetch --all;
git fetch --prune --tags;
fi
fi
done;
#!/bin/dash
if [ $# -lt 3 ]; then
echo "Usage: $0 tempo freq dur [freq dur freq dur...]" >&2
exit 1
fi
tempo=$1; shift
tmpdir=$(mktemp -d)
while [ -n "$*" ]; do
freq=$1; shift
dur=$1; shift
dur=$(echo "$dur*(60/$tempo)"|bc -l)
sox -e mu-law -r 8000 -n -t raw - synth $dur sine $freq >>$tmpdir/grubtune.ul 2> /dev/null
done
play -q -c1 -r 8000 $tmpdir/grubtune.ul
rm -r $tmpdir
#!/usr/bin/env bash
find /usr/bin -type f | while read fileN;
do
if [[ $(file --mime-type -b $fileN) == 'text/x-shellscript' ]]; then
echo "$fileN";
fi
done;
#!/usr/bin/env bash
Args=$1
FileName="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
if [[ -n "$Args" ]]; then
if [[ -f $Args ]]; then
HTMLoutput=$(pandoc "$Args")
HTMLFileName="/tmp/tmp_$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1).html"
touch $HTMLFileName
echo $HTMLoutput >> $HTMLFileName
/usr/bin/google-chrome $HTMLFileName
#sleep 10
#rm $HTMLFileName
else
echo "$FileName: $Args: No such file or directory"
fi
else
echo "$FileName: missing file operand"
echo "USAGE: '$FileName mdfile1.md'
'mdfile1.md | $FileName'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment