Browse Source

initial commit

pull/1/head
Sam Hunter 2 months ago
parent
commit
b3f6c70ca1
7 changed files with 343 additions and 0 deletions
  1. +20
    -0
      ahist
  2. +17
    -0
      dhist
  3. +41
    -0
      jot
  4. +101
    -0
      recent
  5. +7
    -0
      ruler
  6. +137
    -0
      stars
  7. +20
    -0
      uhist

+ 20
- 0
ahist View File

@ -0,0 +1,20 @@
#! /bin/sh
recent |\
awk '
function hist(x,m){
return sprintf("%-20s\n", substr("####################",0,int(20*(x/max))))
}
BEGIN{
#printf("%-10s %-20s\n","Date","Activity")
}
{
a[$3]++
max=a[$3]>max?a[$3]:max
}
END{
for (d in a) {
printf("%3d %15.15s %-20.20s\n",a[d], d,hist(a[d],max))
}
}'|\
sort -k1r,2n

+ 17
- 0
dhist View File

@ -0,0 +1,17 @@
#! /bin/sh
recent |\
awk '
function hist(x,m){
return sprintf("%-20s\n", substr("####################",0,int(20*(x/max))))
}
{
a[$1]++
max=a[$1]>max?a[$1]:max
}
END{
for (d in a) {
printf("%10s %8i %-20.20s\n",d, a[d],hist(a[d],max))
}
}'|\
sort -r

+ 41
- 0
jot View File

@ -0,0 +1,41 @@
#! /bin/bash
#
# jot - distributed note-taker
# Syntax:
# jot
# - read latest entries
# jot /string
# - look for entries containing 'string'
# jot something noteworthy
# jot "something noteworthy with #tag1 #tag2 #tag3"
# - take note
#
readonly JOTFILE="$HOME/.jot"
readonly PAT1='\/(.*)'
jot::printline () {
local D="$(date +"%s.%N")"
echo -e "${D:0:18}\t$*"
}
jot::write() {
jot::printline "$*" >> $JOTFILE || { echo "Cannot write $JOTFILE" > /dev/tty ; exit 1; }
chmod 0644 $JOTFILE
}
jot::read () {
local SENDER
for d in /home/*/.jot ; do
SENDER="${d##/home/}"
SENDER="${SENDER%%/.jot}"
if [[ "$1" =~ $PAT1 ]]; then
[ -r "$d" ] && egrep -e "${BASH_REMATCH[1]}" $d | awk 'BEGIN{FS="\t"}{printf("%s \x1b[1m%-14.14s\x1b[0m %s\n",strftime("%Y-%m-%d %H:%M:%S",$1),"'${SENDER:-"..."}'",$2)}'
else
[ -r "$d" ] && tail -20 $d | awk 'BEGIN{FS="\t"}{printf("%s \x1b[1m%-14.14s\x1b[0m %s\n",strftime("%Y-%m-%d %H:%M:%S",$1),"'${SENDER:-"..."}'",$2)}'
fi
done | sort -nr
}
[[ -z "$@" ]] && jot::read && exit 0
[[ "$1" =~ $PAT1 ]] && jot::read "$@" && exit 0
jot::write "$@"

+ 101
- 0
recent View File

@ -0,0 +1,101 @@
#!/bin/sh
# recent for rawtext.club by hannu / public domain
# https://git.rawtext.club/hannu/recent
limit=$(date --date="2 month ago" +%s)
printline() {
# printline <ts> <type> <user>
if [ "$1" != "" ] && [ "$1" -gt "$limit" ]; then
printf "%s %10s %s\n" "$(date --date="@$1" +'%Y-%m-%d %H:%M')" "$2" "$3"
fi
}
cd /home || exit
(for user in *
do
# gab
if [ -r "$user/.gab" ]; then
ts=$(head -n1 "$user/.gab" | sed 's/[.|].*//')
printline "$ts" gab "$user"
fi
# iris
if [ -r "$user/.iris.messages" ]; then
ts=$(stat -c %Y "$user/.iris.messages")
printline "$ts" iris "$user"
fi
# linkulator
if [ -r "$user/.linkulator/linkulator.data" ]; then
ts=$(tail -n1 "$user/.linkulator/linkulator.data" | sed 's/[.|].*//')
printline "$ts" linkulator "$user"
fi
# shlog
if [ -x "$user/.shlog" ]; then
# shellcheck disable=SC2012 # find doesn't easily work here
file=$(ls -t "$user/.shlog/" | head -n1)
if [ "$file" != "" ]; then
ts=$(stat -c %Y "$user/.shlog/$file")
printline "$ts" shlog "$user"
fi
fi
# who-is
if [ -r "$user/.who-is" ]; then
ts=$(stat -c %Y "$user/.who-is")
printline "$ts" who-is "$user"
fi
# gitbbs
if [ -r "$user/.gitbbs/.git/index" ]; then
ts=$(git -C "$user/.gitbbs" log --pretty=format:%at -n1)
printline "$ts" gitbbs "$user"
fi
# oneliner
if [ -r "$user/.oneliner" ]; then
ts=$(stat -c %Y "$user/.oneliner")
printline "$ts" oneliner "$user"
fi
# sl
if [ -r "$user/.vroom" ]; then
ts=$(stat -c %Y "$user/.vroom")
printline "$ts" sl "$user"
fi
# train
if [ -r "$user/.choochoo" ]; then
ts=$(stat -c %Y "$user/.choochoo")
printline "$ts" train "$user"
fi
# web
if [ -r "$user/public_html" ]; then
ts=$(stat -c %Y "$user/public_html")
printline "$ts" web "$user"
fi
# gemini
if [ -r "$user/public_gemini" ]; then
ts=$(stat -c %Y "$user/public_gemini")
printline "$ts" gemini "$user"
fi
# gopher
if [ -r "$user/public_gopher" ]; then
ts=$(stat -c %Y "$user/public_gopher")
printline "$ts" gopher "$user"
fi
# library
if [ -r "$user/books" ]; then
ts=$(stat -c %Y "$user/books")
printline "$ts" library "$user"
fi
done) | sort --reverse
# vim: ts=8 sw=8 noexpandtab :

+ 7
- 0
ruler View File

@ -0,0 +1,7 @@
#! /bin/bash
RULER=""
for ((i=0;i<$COLUMNS;i+=10)) ;do
RULER+="$(printf "%10.10d" $((i/10+1))|sed -e 's+^00000+0000:+g;s+0+.+g')"
done
echo -e "${RULER:0:COLUMNS}"

+ 137
- 0
stars View File

@ -0,0 +1,137 @@
#! /bin/bash
CACHE=$(mktemp "$HOME/tmp/starsXXXX")
declare -gA GAB=()
declare -gA IRIS=()
declare -gA LINKULATOR=()
declare -gA SHLOG=()
declare -gA WHOIS=()
declare -gA GITBBS=()
declare -gA ONELINER=()
declare -gA SL=()
declare -gA TRAIN=()
declare -gA WEB=()
declare -gA GEMINI=()
declare -gA GOPHER=()
declare -gA ELIBRARY=()
declare -gAi ACTIVE_USERS=()
declare -gAi TOTALS=()
recent -f |\
if_possible user::filter |\
sort -nr |\
while read DATE TIME WHAT WHO ; do
let ACTIVE_USERS[$WHO]+=1
case "$WHAT" in
"gab") GAB["$WHO"]="$DATE" ; ((++TOTALS["GAB"])) ;;
"iris") IRIS["$WHO"]="$DATE"; ((++TOTALS["IRIS"])) ;;
"linkulator") LINKULATOR["$WHO"]="$DATE"; ((++TOTALS["LINKULATOR"])) ;;
"shlog") SHLOG["$WHO"]="$DATE"; ((++TOTALS["SHLOG"])) ;;
"who-is") WHOIS["$WHO"]="$DATE"; ((++TOTALS["WHOIS"])) ;;
"gitbbs") GITBBS["$WHO"]="$DATE"; ((++TOTALS["GITBBS"])) ;;
"oneliner") ONELINER["$WHO"]="$DATE"; ((++TOTALS["ONELINER"])) ;;
"sl") SL["$WHO"]="$DATE"; ((++TOTALS["SL"])) ;;
"train") TRAIN["$WHO"]="$DATE"; ((++TOTALS["TRAIN"])) ;;
"web") WEB["$WHO"]="$DATE"; ((++TOTALS["WEB"])) ;;
"gemini") GEMINI["$WHO"]="$DATE"; ((++TOTALS["GEMINI"])) ;;
"gopher") GOPHER["$WHO"]="$DATE"; ((++TOTALS["GOPHER"])) ;;
"library") ELIBRARY["$WHO"]="$DATE"; ((++TOTALS["ELIBRARY"])) ;;
esac
typeset -p ACTIVE_USERS > "${CACHE}"
typeset -p GAB >> "${CACHE}"
typeset -p IRIS >> "${CACHE}"
typeset -p LINKULATOR >> "${CACHE}"
typeset -p SHLOG >> "${CACHE}"
typeset -p WHOIS >> "${CACHE}"
typeset -p GITBBS >> "${CACHE}"
typeset -p ONELINER >> "${CACHE}"
typeset -p SL >> "${CACHE}"
typeset -p TRAIN >> "${CACHE}"
typeset -p WEB >> "${CACHE}"
typeset -p GEMINI >> "${CACHE}"
typeset -p GOPHER >> "${CACHE}"
typeset -p ELIBRARY >> "${CACHE}"
typeset -p TOTALS >> "${CACHE}"
echo >> "${CACHE}"
done
. "${CACHE}"
if [ -n "$NO_FANCY_SHIT" ]; then
printf "%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\n" \
"user" "gab" "iris" "linkulator" "shlog" "who-is" "gitbbs" "oneliner" "sl" "train" "web" "gemini" "gopher" "library"
printf "%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\n" \
'-------------------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------'
else
printf "\x1b[7;1m%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\x1b[0m\n" \
"user" "gab" "iris" "linkulator" "shlog" "who-is" "gitbbs" "oneliner" "sl" "train" "web" "gemini" "gopher" "library"
fi
FILLER='..........'
for u in ${!ACTIVE_USERS[@]} ; do
printf "%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\n" \
"$u" ${GAB["$u"]:="${FILLER}"} ${IRIS["$u"]:="${FILLER}"} ${LINKULATOR["$u"]:="${FILLER}"} ${SHLOG["$u"]:="${FILLER}"} ${WHOIS["$u"]:="${FILLER}"} \
${GITBBS["$u"]:="${FILLER}"} ${ONELINER["$u"]:="${FILLER}"} ${SL["$u"]:="${FILLER}"} ${TRAIN["$u"]:="${FILLER}"} ${WEB["$u"]:="${FILLER}"} \
${GEMINI["$u"]:="${FILLER}"} ${GOPHER["$u"]:="${FILLER}"} ${ELIBRARY["$u"]:="${FILLER}"}
done | sort
if [ -n "$NO_FANCY_SHIT" ]; then
printf "%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\n" \
'-------------------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------' \
'----------'
printf "%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\n" \
"Totals" \
${TOTALS["GAB"]:-0} \
${TOTALS["IRIS"]:-0} \
${TOTALS["LINKULATOR"]:-0} \
${TOTALS["SHLOG"]:-0} \
${TOTALS["WHOIS"]:-0} \
${TOTALS["GITBBS"]:-0} \
${TOTALS["ONELINER"]:-0} \
${TOTALS["SL"]:-0} \
${TOTALS["TRAIN"]:-0} \
${TOTALS["WEB"]:-0} \
${TOTALS["GEMINI"]:-0} \
${TOTALS["GOPHER"]:-0} \
${TOTALS["ELIBRARY"]:-0}
else
printf "\x1b[7;1m%20.20s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s | %-10.10s |\x1b[0m\n" \
"Totals" \
${TOTALS["GAB"]:-0} \
${TOTALS["IRIS"]:-0} \
${TOTALS["LINKULATOR"]:-0} \
${TOTALS["SHLOG"]:-0} \
${TOTALS["WHOIS"]:-0} \
${TOTALS["GITBBS"]:-0} \
${TOTALS["ONELINER"]:-0} \
${TOTALS["SL"]:-0} \
${TOTALS["TRAIN"]:-0} \
${TOTALS["WEB"]:-0} \
${TOTALS["GEMINI"]:-0} \
${TOTALS["GOPHER"]:-0} \
${TOTALS["ELIBRARY"]:-0}
fi
rm -f "${CACHE}"

+ 20
- 0
uhist View File

@ -0,0 +1,20 @@
#! /bin/sh
recent |\
awk '
function hist(x,m){
return sprintf("%-20s\n", substr("####################",0,int(20*(x/max))))
}
BEGIN{
#printf("%-10s %-20s\n","Date","Activity")
}
{
a[$4]++
max=a[$4]>max?a[$4]:max
}
END{
for (d in a) {
printf("%3d %15.15s %-20.20s\n",a[d], d,hist(a[d],max))
}
}'|\
sort -k1r,2n

Loading…
Cancel
Save