Skip to content

Instantly share code, notes, and snippets.

@Mr920
Mr920 / Check_Memory.sh
Created October 16, 2025 07:38
WSL2 likes to eat my RAM, this helps to mitigate the issue somewhat, throw it in bashrc and let it run every time we open a window or re-source our bash
#!/bin/bash
BOOL_TRUE=0;
BOOL_FALSE=1;
IS_SCRIPT_DRYRUN=${BOOL_FALSE};
RECOVERY_THRESHOLD=1800; # When the memory exceeds this many megabytes, recovery will be attempted (as long as we are not in dryrun mode)
RESULT_DIFF_THRESHOLD=5; # The two programs often report different numbers. At what point is that divergence enough to be a concern?
FREE_PAGECACHE=1;
@Mr920
Mr920 / check-browser-locks.sh
Created October 16, 2025 07:36
fix a little issue caused by force-kills of a desktop with open browsers
#!/bin/bash
RED=$'\e[0;31m';
LIGHTRED=$'\e[1;31m';
GREEN=$'\e[0;32m';
LIGHTGREEN=$'\e[1;32m';
BLUE=$'\e[0;34m';
LIGHTBLUE=$'\e[1;34m';
YELLOW=$'\e[1;33m';
PURPLE=$'\e[0;35m';
@Mr920
Mr920 / start_xserver.bat
Created October 16, 2025 07:33
Start X11 on Windows - VcXSrv
@ECHO ON
:: I've left ECHO'ing on, because I don't want to suppress the info, user might want to know what is going on
:: However it looks really annoying because it still displays the windows prompt, so let's set a custom prompt
:: which will end with an extra \r\n so that the ECHO'd command will be on a separate line from the prompt
:: We will remove that part at the end of the script
::
:: Scratch what I said above, the output is ugly. Too ugly. Let's just try an empty prompt
:: prompt $E[1;31m[$T]$E[0m$E[1;33m[$P]$E[0m$S$$$S$_
::
:: The prompt shall be 1 space followed by 1 backspace. So it will APPEAR to the user as though there is no prompt.
@Mr920
Mr920 / FancyProcessList.ps1
Created October 16, 2025 07:31
Trying to practice my powershell again
class Lita_ObjectGrouper {
[System.String] $TrackingProp
[System.Type] $MapType
[System.String] $HashKey
[System.String] $NextGroupMapType
[System.String] $customMethodCall
@Mr920
Mr920 / ParseLog.sh
Created October 16, 2025 07:29
Script to parse a certain strace output i'm using to try to fix a KDE <--> X Server instability issue
#!/bin/bash
SCRIPT_FILE="${BASH_SOURCE[@]}";
SCRIPT_EXEC="${0}";
PROCESS_FILE="/home/clentz/.KDE-MORE_TROUBLESHOOTING/pertinent-calls-no-errors";
DEFAULT_IFS=$'\x20\x09\x0a';
@Mr920
Mr920 / .xinitrc.sh
Created October 16, 2025 07:25
xinit - work in progress
#!/bin/bash
clentz_xinitrc_minimal_kde(){
kwin_x11 --replace --no-kactivities &
konqueror "${HOME}" &
konsole &
kcachegrind &
}
clentz_xinitrc_full_kde_plasma(){
@Mr920
Mr920 / LITA_BASHRC.sh
Created October 16, 2025 07:23
My ever-evolving bashrc, full of shit I think I can't live without
#!/bin/bash
PYTHONPATH="${HOME}/.local/lib/python3.8/site-packages/";
RED='\[\e[0;31m\]'
LIGHTRED='\[\e[1;31m\]'
GREEN='\[\e[0;32m\]'
LIGHTGREEN='\[\e[1;32m\]'
BLUE='\[\e[0;34m\]'
LIGHTBLUE='\[\e[1;34m\]'
YELLOW='\[\e[1;33m\]'
@Mr920
Mr920 / colors.sh
Created October 16, 2025 07:19
Remind me of the ANSI codes that I always forget...
#! /bin/bash
declare CHAR_ESC=$'\x1b';
declare -i LTA_COL_SIZE=7;
declare LTA_TEST_STR='x11';
declare -i LTA_CURR_COL=0;
declare -i LTA_CURR_ROW=0;
declare -i LTA_IS_BOLD=0;
declare -i LTA_FG_NUM=0;
@Mr920
Mr920 / pprintenv.sh
Created October 16, 2025 07:18
Print the environment in a human friendly manner
#! /bin/bash
DEFAULT_IFS="${IFS}";
CHAR_ESC=$'\x1b';
declare -a LTA_COLOR_KEYS=("RED" "GREEN" "BLUE" "YELLOW" "PURPLE" "CYAN" "WHITE" "NORMAL" "CLEAR");
readarray -t LTA_ENV_LINES <<<"$(printenv | sort)"
declare -i LTA_LINENO=0;
@Mr920
Mr920 / youtube-download.js
Created February 7, 2016 18:02
Copy-Paste this into the console to download youtube videos. (if you're already in playlist mode)
function downloadPlaylistItems($x){
var VidList = [];
$x('//@data-video-id').forEach(function(vid){
VidList.push('https://www.youtube.com/watch?v='.concat(vid.nodeValue));
});
var downloadAnchor = document.createElement('a');
var date = new Date();
var utcStr = date.toUTCString();
downloadAnchor.setAttribute('download', 'YouTube_Links--'.concat(utcStr, '.txt'));
var data = btoa(VidList.join("\n"));