~kris/dots

srice

ref: b42b72dc2648499470b89418ac629e40f41d3149 srice/.local/bin/blog-stats -rwxr-xr-x 1.1 KiB
b42b72dc — Kris Yotam sb-battery: match macsmc-battery by type, add low-battery dunst alerts; xprofile: caps:super 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env sh
set -eu

files=$(find . \( -path '*/.git' -o -path '*/node_modules' -o -path '*/.next' -o -path '*/_site' \) -prune -o -type f \( -name '*.md' -o -name '*.mdx' -o -name '*.org' \) -print)
count=$(printf '%s\n' "$files" | sed '/^$/d' | wc -l | tr -d ' ')
words=$(printf '%s\n' "$files" | xargs -r wc -w | awk 'END{print $1+0}')
links=$(printf '%s\n' "$files" | xargs -r rg --no-filename -o 'https?://[^\]\[()<>"'\''[:space:]]+' 2>/dev/null | wc -l | tr -d ' ')
domains=$(printf '%s\n' "$files" | xargs -r rg --no-filename -o 'https?://[^\]\[()<>"'\''[:space:]]+' 2>/dev/null | awk -F/ '{print $3}' | sort -u | wc -l | tr -d ' ')
todos=$(printf '%s\n' "$files" | xargs -r rg -n 'TK|TODO|FIXME|XXX|SOURCE\?' 2>/dev/null | wc -l | tr -d ' ')

printf 'posts: %s\n' "$count"
printf 'words: %s\n' "$words"
printf 'links: %s\n' "$links"
printf 'domains: %s\n' "$domains"
printf 'flags: %s\n' "$todos"

printf '\nTop domains:\n'
printf '%s\n' "$files" | xargs -r rg --no-filename -o 'https?://[^\]\[()<>"'\''[:space:]]+' 2>/dev/null |
  awk -F/ '{print $3}' | sed 's/^www\.//' | sort | uniq -c | sort -nr | sed -n '1,25p'