-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a little bit of everyday improvements
Signed-off-by: Egor Kovetskiy <[email protected]>
- Loading branch information
Showing
19 changed files
with
216 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
for container in $(docker ps -q); do | ||
json=$(docker inspect "$container") | ||
name=$(jq <<< "$json" -r '.[0] | .Name') | ||
ip=$(jq <<< "$json" -r '.[0] | .NetworkSettings.Networks | .[] | .IPAddress' \ | ||
| sort | uniq | paste -sd' ') | ||
echo "${name}: ${ip}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ fi | |
|
||
go mod tidy | ||
|
||
sleep 5 | ||
sleep 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
files=() | ||
while [[ "${1:-}" ]]; do | ||
if [[ "$1" =~ .*=.* ]]; then | ||
eval "export $1" | ||
else | ||
files+=("$1") | ||
fi | ||
|
||
shift | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
current=$(efibootmgr | awk '/BootCurrent: /{print $2}') | ||
|
||
sudo efibootmgr -n "${current}" | ||
sudo reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
hosts=() | ||
while [[ "${1:-}" ]]; do | ||
hosts+=("$1") | ||
shift | ||
done | ||
|
||
while :; do | ||
success=true | ||
for host in "${hosts[@]}"; do | ||
if ! host "${host}"; then | ||
success=false | ||
fi | ||
done | ||
|
||
if $success; then | ||
break | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
alloc=$(zpool list -o alloc -H zroot) | ||
size=$(zpool list -o size -H zroot) | ||
|
||
alloc=${alloc//G/} | ||
size=${size//G/} | ||
|
||
free_percent=$(echo "scale=2; 100*${alloc}/${size}" | bc) | ||
|
||
echo " ${free_percent}% ${size}G" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/env python3 | ||
# vim: ft=python | ||
|
||
import os | ||
import os.path | ||
import sys | ||
from pathlib import Path | ||
|
||
def get_prompt(): | ||
cwd = os.getcwd() | ||
if len(sys.argv) > 1: | ||
cwd = sys.argv[1] | ||
|
||
home = Path.home() | ||
|
||
relative = os.path.relpath(cwd, home) | ||
if '../' in relative: | ||
print(cwd) | ||
return | ||
|
||
chunks = relative.split('/') | ||
for i in range(len(chunks) - 1): | ||
chunk = chunks[i] | ||
if chunk.startswith('.'): | ||
continue | ||
|
||
if len(chunk) > 3: | ||
chunk = chunk[:1] | ||
|
||
chunks[i] = chunk | ||
|
||
print('~/' + '/'.join(chunks)) | ||
return | ||
|
||
if __name__ == "__main__": | ||
get_prompt() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.