Initial commit
This commit is contained in:
commit
400186850e
21
README.md
Normal file
21
README.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Scripts and tools
|
||||
|
||||
A collection of various scripts and tools, found here and there in times of need.
|
||||
|
||||
## `colors.sh`
|
||||
|
||||
Display terminal colors.
|
||||
|
||||
CREDITS: [The Linux Documentation Project](http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html)
|
||||
|
||||
## `record_bandwidth.sh`
|
||||
|
||||
Measures the bandwidth consumed while the script is running.
|
||||
|
||||
CREDITS: [Luke Smith's video: *A demonstration of modern web bloat*](https://youtu.be/cvDyQUpaFf4)
|
||||
|
||||
## `slower.c`
|
||||
|
||||
Slow down the output of a command in the terminal.
|
||||
|
||||
CREDITS: [Landon Bland's answer on StackOverflow](https://unix.stackexchange.com/questions/290179/how-to-slow-down-the-scrolling-of-multipage-standard-output-on-terminal/290258#290258)
|
28
colors.sh
Executable file
28
colors.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This file echoes a bunch of color codes to the
|
||||
# terminal to demonstrate what's available. Each
|
||||
# line is the color code of one foreground color,
|
||||
# out of 17 (default + 16 escapes), followed by a
|
||||
# test use of that color on all nine background
|
||||
# colors (default + 8 escapes).
|
||||
#
|
||||
# Copied from http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
|
||||
|
||||
T='gYw' # The test text
|
||||
|
||||
echo -e "\n 40m 41m 42m 43m\
|
||||
44m 45m 46m 47m";
|
||||
|
||||
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
|
||||
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
|
||||
' 36m' '1;36m' ' 37m' '1;37m';
|
||||
do FG=${FGs// /}
|
||||
echo -en " $FGs \033[$FG $T "
|
||||
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
|
||||
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
|
||||
done
|
||||
echo;
|
||||
done
|
||||
echo
|
||||
|
9
record_bandwidth.sh
Executable file
9
record_bandwidth.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
init="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
|
||||
|
||||
# printf "Recording bandwidth. Press enter to stop."
|
||||
|
||||
read -r lol
|
||||
|
||||
fin="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
|
||||
|
||||
printf "%4sB of bandwidth used.\\n" $(numfmt --to=iec $(($fin-$init)))
|
27
slower.c
Normal file
27
slower.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int delay;
|
||||
char* rem;
|
||||
if (argc > 1) {
|
||||
delay = strtol(argv[1], &rem, 10);
|
||||
} else {
|
||||
delay = 500;
|
||||
}
|
||||
|
||||
char* line;
|
||||
size_t bufsize = 0;
|
||||
|
||||
struct timespec ts;
|
||||
ts.tv_sec = delay / 1000;
|
||||
ts.tv_nsec = (delay % 1000) * 1000000;
|
||||
|
||||
while (getline(&line, &bufsize, stdin) != -1) {
|
||||
printf("%s", line);
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
|
Loading…
Reference in a new issue