Skip to content

Commit b29b470

Browse files
author
Alexander Rogalskiy
committed
Updates on files
1 parent 774be53 commit b29b470

File tree

5 files changed

+246
-5
lines changed

5 files changed

+246
-5
lines changed

.jsbeautifyrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"js": {
3+
"brace_style": "collapse",
4+
"break_chained_methods": false,
5+
"e4x": false,
6+
"eval_code": false,
7+
"indent_level": 0,
8+
"indent_with_tabs": false,
9+
"indent_size": 4,
10+
"indent_char": " ",
11+
"jslint_happy": true,
12+
"keep_array_indentation": false,
13+
"keep_function_indentation": false,
14+
"max_preserve_newlines": 3,
15+
"preserve_newlines": true,
16+
"space_before_conditional": true,
17+
"space-after-anon-function": true,
18+
"space_in_paren": false,
19+
"unescape_strings": true,
20+
"wrap_line_length": 0,
21+
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"]
22+
}
23+
}

scripts/docker-compose.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ trap cleanup_err ERR
8383
docker_ps() {
8484
echo ">>> Processing status of docker containers..."
8585

86-
$DOCKER_COMPOSE_CMD -f docker-compose.yml ps "$@"
86+
$DOCKER_COMPOSE_CMD -f $(BASE_DIR)/docker-compose.yml ps "$@"
8787
}
8888

8989
docker_logs() {
9090
echo ">>> Logging docker containers..."
9191

92-
$DOCKER_COMPOSE_CMD -f docker-compose.yml logs -t --follow "$@"
92+
$DOCKER_COMPOSE_CMD -f $(BASE_DIR)/docker-compose.yml logs -t --follow "$@"
9393
}
9494

9595
docker_pull() {
9696
echo ">>> Pulling docker containers..."
9797

98-
$DOCKER_COMPOSE_CMD -f docker-compose.yml pull --include-deps --quiet "$@"
98+
$DOCKER_COMPOSE_CMD -f $(BASE_DIR)/docker-compose.yml pull --include-deps --quiet "$@"
9999
}
100100

101101
docker_start() {
102102
echo ">>> Starting docker containers..."
103103

104-
$DOCKER_COMPOSE_CMD -f docker-compose.yml up --detach --build --force-recreate --renew-anon-volumes "$@"
104+
$DOCKER_COMPOSE_CMD -f $(BASE_DIR)/docker-compose.yml up --detach --build --force-recreate --renew-anon-volumes "$@"
105105
}
106106

107107
docker_stop() {
108108
echo ">>> Stopping docker containers..."
109109

110-
$DOCKER_COMPOSE_CMD -f docker-compose.yml down --remove-orphans --volumes "$@"
110+
$DOCKER_COMPOSE_CMD -f $(BASE_DIR)/docker-compose.yml down --remove-orphans --volumes "$@"
111111
}
112112

113113
main() {

scripts/git_view.sh

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
# Copyright (C) 2022 SensibleMetrics, Inc. (http://sensiblemetrics.io/)
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Usage example: /bin/sh ./scripts/git_view.sh
17+
18+
set -o nounset
19+
set -o pipefail
20+
21+
HASH="%C(yellow)%h%Creset"
22+
RELATIVE_TIME="%Cgreen(%ar)%Creset"
23+
AUTHOR="%C(bold blue)<%an>%Creset"
24+
REFS="%C(red)%d%Creset"
25+
SUBJECT="%s"
26+
27+
FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
28+
29+
usage() {
30+
read -r -d '' MESSAGE <<- EOM
31+
Usage: ${0} [operation]
32+
33+
where [operation] is one of the following:
34+
[head]: to show git head commit
35+
[tree]: to show git commit tree
36+
[fat]: to show git fat files
37+
[branch]: to show git branches (ahead/behind)
38+
EOM
39+
echo
40+
echo "$MESSAGE"
41+
echo
42+
exit 1
43+
}
44+
45+
show_git_head() {
46+
show_git_tree -1
47+
git show -p --pretty="tformat:"
48+
}
49+
50+
show_git_tree() {
51+
git log --graph --pretty="tformat:${FORMAT}" "$@" |
52+
# Replace (2 years ago) with (2 years)
53+
sed -Ee 's/(^[^<]*) ago)/\1)/' |
54+
# Replace (2 years, 5 months) with (2 years)
55+
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' |
56+
# Line columns up based on } delimiter
57+
column -s '}' -t |
58+
# Page only if we need to
59+
less -FXRS
60+
}
61+
62+
show_git_branches() {
63+
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/ | \
64+
while read -r local remote
65+
do
66+
if [ -x "$remote" ]; then
67+
branches=("$local")
68+
else
69+
branches=("$local" "$remote")
70+
fi;
71+
for branch in "${branches[@]}"; do
72+
if [ "$branch" != "origin/master" ]; then
73+
master="origin/master"
74+
git rev-list --left-right ${branch}...${master} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue
75+
76+
LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta)
77+
RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)
78+
79+
if [[ $LEFT_AHEAD -gt 0 || $RIGHT_AHEAD -gt 0 ]]; then
80+
printf " - \033[1m%-50s\033[0m (" $branch
81+
else
82+
printf " - %-50s (" $branch
83+
fi;
84+
if [[ $LEFT_AHEAD -gt 0 ]]; then
85+
printf "\033[36mahead %3d\033[0m" $LEFT_AHEAD
86+
else
87+
printf "ahead %3d" $LEFT_AHEAD
88+
fi;
89+
echo -n ") | ("
90+
if [[ $RIGHT_AHEAD -gt 0 ]]; then
91+
printf "\033[31mbehind %3d\033[0m" $RIGHT_AHEAD
92+
else
93+
printf "behind %3d" $RIGHT_AHEAD
94+
fi;
95+
echo -e ") $master"
96+
fi;
97+
done
98+
done | sort -k5rn -k8n | uniq
99+
}
100+
101+
show_git_fat_files() {
102+
git rev-list --all --objects | \
103+
sed -n $(git rev-list --objects --all | \
104+
cut -f1 -d' ' | \
105+
git cat-file --batch-check | \
106+
grep blob | \
107+
sort -n -k 3 | \
108+
tail -n40 | \
109+
while read -r hash type size; do
110+
echo -n "-e s/$hash/$size/p ";
111+
done) | \
112+
sort -n -k1
113+
}
114+
115+
main() {
116+
[ ${#@} -gt 0 ] || usage
117+
118+
cmd=$(echo "$1" | tr "[:upper:]" "[:lower:]"); shift;
119+
case "$cmd" in
120+
[hH]ead|-h)
121+
show_git_head "${@:1}"
122+
;;
123+
[tT]ree|-t)
124+
show_git_tree "${@:1}"
125+
;;
126+
[fF]at|-f)
127+
show_git_fat_files "${@:1}"
128+
;;
129+
[bB]ranch|-b)
130+
show_git_branches "${@:1}"
131+
;;
132+
*)
133+
echo "ERROR: unrecognized option: $cmd"
134+
usage
135+
;;
136+
esac
137+
}
138+
139+
main "$@"

scripts/show_memory.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
# Copyright (C) 2022 SensibleMetrics, Inc. (http://sensiblemetrics.io/)
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Usage example: /bin/sh ./scripts/show_memory.sh
17+
18+
set -o errexit
19+
set -o nounset
20+
set -o pipefail
21+
22+
ps aux |
23+
awk '
24+
{
25+
seen[$11]++
26+
mem[$11] += $6
27+
n += 1
28+
ram += $6
29+
}
30+
END {
31+
printf t
32+
for (p in seen) {
33+
printf "%-65s %8d %8d %8.1f%%\n", p, seen[p], mem[p]/1024, mem[p]/ram*100
34+
}
35+
printf "%-65s %8s %8d %8.1f%%\n","Total:",n,ram/1024,100
36+
}' |
37+
sort -k3n |
38+
tail -20

scripts/show_swap.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Copyright (C) 2022 SensibleMetrics, Inc. (http://sensiblemetrics.io/)
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Usage example: /bin/sh ./scripts/show_swap.sh
17+
18+
set -o errexit
19+
set -o nounset
20+
set -o pipefail
21+
22+
# shellcheck disable=SC2044
23+
for DIR in $(find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+")
24+
do
25+
PID=$(echo "$DIR" | cut -d / -f 3)
26+
PROGNAME=$(ps -p "$PID" -o comm --no-headers)
27+
# shellcheck disable=SC2013
28+
for SWAP in $(grep VmSwap $DIR/status 2>/dev/null | awk '{ print $2 }')
29+
do
30+
# shellcheck disable=SC2219
31+
let SUM=$SUM+$SWAP
32+
done
33+
# shellcheck disable=SC2004
34+
if (( $SUM > 0 ))
35+
then
36+
echo "PID=$PID swapped $SUM KB ($PROGNAME)"
37+
fi
38+
# shellcheck disable=SC2219
39+
let OVERALL=$OVERALL+$SUM
40+
SUM=0
41+
done | sort -nk3

0 commit comments

Comments
 (0)