Skip to content

Instantly share code, notes, and snippets.

View redsfyre's full-sized avatar
:shipit:
There is nothing here -> /dev/null

Yasin İsa YILDIRIM redsfyre

:shipit:
There is nothing here -> /dev/null
View GitHub Profile
@redsfyre
redsfyre / aliases.sh
Created November 5, 2021 14:20
This gist has been updated to include my favorite aliases and funcs.
dls () {
print -l *(/)
}
@redsfyre
redsfyre / psmem20.sh
Created November 5, 2021 14:15
Top 20 processes that consume the most memory
#/bin/bash
ps -e -orss=,args= | sort -b -k1 -nr | head -20
@redsfyre
redsfyre / mem.sh
Last active November 5, 2021 14:13
The command that gives the memory usage of the named application in mb (WIP)
appname= XX;
for line in $(ps -e -orss=,args= | sort -b -k1 -nr | grep $appname | cut -d' ' -f1);
do
declare -i mem; mem="$line/1024"; echo "$mem M";
done
@redsfyre
redsfyre / k8s-all-cron-suspend.sh
Created November 5, 2021 14:05
Script that stops (suspends) all running kubernetes cronjobs
#!/bin/bash
for ns in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do
for cj in $(kubectl get cronjobs -n "$ns" -o name); do
kubectl patch "$cj" -n "$ns" -p '{"spec" : {"suspend" : true }}';
done
done
@redsfyre
redsfyre / basic-parser.sh
Last active August 23, 2021 07:15
An extended yaml parser for bash scripts. Copied from https://stackoverflow.com/a/21189044/13756006 and https://stackoverflow.com/a/51789677/13756006 and https://github.com/mrbaseman/parse_yaml Note: This gist was created so that I can easily access these scripts when needed.
#!/bin/sh
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
@redsfyre
redsfyre / nvfixbl.sh
Created June 9, 2021 19:07
Simple script I wrote for Arch Linux to use Nvidia brightness setting properly
#!/bin/bash
for x in \
nvidia-460.67-5-x86_64.pkg.tar.zst \
nvidia-dkms-460.67-1-x86_64.pkg.tar.zst \
nvidia-settings-460.67-1-x86_64.pkg.tar.zst \
nvidia-utils-460.67-1-x86_64.pkg.tar.zst \
; do
test -f $x || \