Skip to content

Commit

Permalink
dumb commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonbosa committed Oct 11, 2024
1 parent 93253e3 commit 80855a8
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 18 deletions.
4 changes: 2 additions & 2 deletions moshell.sh/custom/andersonbosa/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ alias wit="cd $HOME/witchcrafts ; l"
alias doti="~/dotfiles/cli.sh"
alias tbu="nc termbin.com 9999"
alias tat="tmux attach"
alias hosts="sudo $EDITOR /etc/hosts"
alias hosts="sudo vim /etc/hosts"

alias zshreload="source ~/.zshrc"
alias zshconfig="$EDITOR ~/.zshrc && zshreload"
alias zshconfig="vim ~/.zshrc && zshreload"

alias copy="clipcopy"
alias tf=terraform
Expand Down
65 changes: 62 additions & 3 deletions moshell.sh/custom/andersonbosa/docker.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
postgresql_docker() {
local database_name="$1"
docker run --rm \
-e POSTGRES_USER=psql_user \
-e POSTGRES_PASSWORD=psql_pass \
-e POSTGRES_DB="${database_name:-postgres}" \
-p 5432:5432 \
bitnami/postgresql:14
}


dev_docker() {
dcdn && dcup --build
}

docker_watch_ps() {
local cmd="docker ps $@"
watch -n1 $cmd
}

docker_grep_exec() {
local container_name=$1
local shelltype=$2
local shelluser=$3

local container_to_enter=$(docker ps -a | grep "$container_name" | awk '{print $1}')

if [[ -z "$container_to_enter" ]]; then
echo "Container not found."
return 1
fi

if [[ -z "$shelltype" ]]; then
shelltype="sh"
fi

if [[ -n "$shelluser" ]]; then
docker exec -it --user "$shelluser" "$container_to_enter" "$shelltype"
else
docker exec -it "$container_to_enter" "$shelltype"
fi
}


docker_prune_none() {
for IMG in $(docker images | grep none | awk '{print $3}'); do
Expand All @@ -12,15 +55,17 @@ docker_get_ip() {
}

redis_up() {
docker run --rm -p 6379:6379 --name redis -d redis:latest
docker run --rm -p 6379:6379 --name redis -d redis/redis-stack:latest
}

redis_up_verbose() {
docker run --rm -p 6379:6379 --name redis redis:latest
docker run --rm -p 6379:6379 --name redis redis/redis-stack:latest
}

docker_stop_all() {
for i in $( docker ps -q ); docker stop $i
for container_id in $(docker ps -q); do
docker stop $container_id
done
}

_docker_logs_all_cleanup() {
Expand All @@ -36,3 +81,17 @@ docker_logs_all() {
done
wait
}

mariadb_up() {
docker run --rm \
-p 3306:3306 \
-v ephemeral_mariadb:/bitnami/mariadb \
--user 1001 \
--network external-net \
-e MARIADB_DATABASE=ephemeral_mariadb \
-e MARIADB_USER=bitnami_user \
-e MARIADB_PASSWORD=bitnami_pass \
-e MARIADB_ROOT_USER=admin \
-e MARIADB_ROOT_PASSWORD=admin \
bitnami/mariadb:11.4.2
}
16 changes: 15 additions & 1 deletion moshell.sh/custom/andersonbosa/randoms.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# -*- coding: utf-8 -*-
pinga() {
ping -c 1 8.8.8.8 -w 1 &>/dev/null
if [ $? -eq 0 ]; then
echo "INFO: internet OK"
return 0
else
echo "INFO: internet NOK"
return 1
fi
}


generate_strong_password() {
openssl rand -base64 64 | tr -d '==\n'
}

translate() {
sr translate -from="portugues" -to="en" "$@"
Expand Down
23 changes: 11 additions & 12 deletions moshell.sh/custom/andersonbosa/workrounds.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/usr/bin/env bash


function fix-ssh-key-permissions() {
# fix permissions on ssh dir.
# @param {string} $1 [default="$HOME/.ssh"]

fix-ssh-key-permissions () {
local SSHPath="$1"
if [[ -z "$SSHPath" ]]; then # if string empty
SSHPath="$HOME/.ssh"

if [[ -z "$SSHPath" ]]
then
SSHPath="$HOME/.ssh"
fi

sudo chown -R "$USER:$USER" "$HOME/.ssh"
chmod -R 700 "$HOME/.ssh/"
chmod 600 $HOME/.ssh/*
chmod 644 $HOME/.ssh/*.pub
sudo chown -R "$USER:$USER" $SSHPath
chmod -R 700 $SSHPath
chmod 600 $SSHPath/*
chmod 644 $SSHPath/*.pub

unset SSHPath
}

Expand Down
34 changes: 34 additions & 0 deletions moshell.sh/plugins/howtos/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,37 @@ sudo systemctl start systemd-journald
```
'''
}

howto_clear_cached_memory() {
sudo sync; sudo echo 1 >/proc/sys/vm/drop_caches
}

howto_debug_linux() {
cat <<EOF
Why does kworker hog your CPU (cont.)? As an alternative to my other answer here, Perf is a more professional way to analyse what kernel tasks are hogging your CPU:
Install perf:
sudo apt-get install linux-tools-common linux-tools-3.11.0-15-generic
(The second package must match your kernel version. You can first install just linux-tools-common and call perf to let it tell you which package it needs.)
Record some 10 seconds of backtraces on all your CPUs:
sudo perf record -g -a sleep 10
Analyse your recording:
sudo perf report
(Navigate the call graph with ←, →, ↑, ↓ and Enter.)
EOF
}


howto_replace_all_occourrences_of_x_by_y_in_dir() {
cat <<EOF | cat
find ../pathdir/ -type f -exec sed -i 's/"text":/"name":/g' {} +
EOF
}

0 comments on commit 80855a8

Please sign in to comment.